debugging gdb找不到用于解析库的libc 6-dbg信息

o2g1uqev  于 2022-11-24  发布在  其他
关注(0)|答案(1)|浏览(115)

我正在WSL上调试busybox,为此我通过apt source busybox下载了busybox源代码,并通过make defconfigmake menuconfig(用于激活调试版本)、make使用调试符号编译了它。
对于libc调试符号,我安装了libc6-dgb;虽然调试符号似乎已经正确加载,但我仍然在处理resolve/ns_parse.c的符号,我希望libc6-dbg提供这些符号。
如何让gdb从(g)libc中找到./resolv/ns_parse.c的调试符号?

$ gdb --args ./busybox_unstripped nslookup management.azure.com
GNU gdb (Ubuntu 12.0.90-0ubuntu1) 12.0.90
[...]
Reading symbols from ./busybox_unstripped...
(gdb) set verbose on
(gdb) start
Reading in symbols for libbb/appletlib.c...
Temporary breakpoint 1 at 0x11b15: file libbb/appletlib.c, line 1034.
Starting program: /tmp/tmp.tJK9POgK2R/busybox-1.30.1/busybox_unstripped nslookup management.azure.com
Using PIE (Position Independent Executable) displacement 0x555555554000 for "/tmp/tmp.tJK9POgK2R/busybox-1.30.1/busybox_unstripped".
Reading symbols from /lib64/ld-linux-x86-64.so.2...
Reading symbols from /usr/lib/debug/.build-id/61/ef896a699bb1c2e4e231642b2e1688b2f1a61e.debug...
Reading symbols from system-supplied DSO at 0x7ffff7fc2000...
(No debugging symbols found in system-supplied DSO at 0x7ffff7fc2000)
Reading symbols from /lib/x86_64-linux-gnu/libm.so.6...
Reading symbols from /usr/lib/debug/.build-id/27/e82301dba6c3f644404d504e1bb1c97894b433.debug...
Reading symbols from /lib/x86_64-linux-gnu/libresolv.so.2...
Reading symbols from /usr/lib/debug/.build-id/7f/d7253c61aa6fce2b7e13851c15afa14a5ab160.debug...
Reading symbols from /lib/x86_64-linux-gnu/libc.so.6...
Reading symbols from /usr/lib/debug/.build-id/69/389d485a9793dbe873f0ea2c93e02efaa9aa3d.debug...
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Temporary breakpoint 1, main (Reading in symbols for ../sysdeps/x86/libc-start.c...
argc=3, argv=0x7fffffffe248) at libbb/appletlib.c:1034
1034    {
(gdb) break nslookup.c:336
Reading in symbols for networking/nslookup.c...
Breakpoint 2 at 0x555555592df0: file networking/nslookup.c, line 336.
(gdb) c
Continuing.
Server:         172.20.48.1
Address:        172.20.48.1:53

Breakpoint 2, parse_reply (len=<optimized out>, msg=0x7fffffffd967 "\335y\201") at networking/nslookup.c:348
348             if (!header->aa)
(gdb) n
349                     printf("Non-authoritative answer:\n");
(gdb) n
Reading in symbols for ioputs.c...
Non-authoritative answer:
351             if (ns_initparse(msg, len, &handle) != 0) {
(gdb) s
Reading in symbols for ns_parse.c...
__GI_ns_initparse (msg=msg@entry=0x7fffffffd967 "\335y\201", msglen=msglen@entry=512, handle=handle@entry=0x7fffffffd4d0) at ./resolv/ns_parse.c:90
90      ./resolv/ns_parse.c: No such file or directory.
bqucvtff

bqucvtff1#

哦,好吧,这似乎是相当愚蠢的:源代码和调试符号是不同的。:)
通过apt source libc6下载源并将其添加到directories * 后,现在显示源 *...

(gdb) set directories ../busybox-1.30.1/:../glibc-2.35/
(gdb) show directories
Source directories searched: /tmp/tmp.tJK9POgK2R/busybox-1.30.1/../busybox-1.30.1:/tmp/tmp.tJK9POgK2R/busybox-1.30.1/../glibc-2.35:$cdir:$cwd
(gdb) list
85              return (ptr - optr);
86      }
87      libresolv_hidden_def (ns_skiprr)
88
89      int
90      ns_initparse(const u_char *msg, int msglen, ns_msg *handle) {
91              const u_char *eom = msg + msglen;
92              int i;
93
94              memset(handle, 0x5e, sizeof *handle);
(gdb)

相关问题