如何使用调试版的 libc [英] How to use debug version of libc
问题描述
问题的简短版本:如何让 gdb 使用 libc
的调试符号?
更长的版本:我正在使用 gdb 调试程序,我想查看有关 libc
使用的 futex 的信息.但是,在调试过程中的某个时刻,我得到如下输出:
Catchpoint 2(调用 syscall futex),0x00007ffff772b73e in ??() 来自/lib/libc.so.6(gdb) bt#0 0x00007ffff772b73e 在 ??() 来自/lib/libc.so.6#1 0x00007ffff767fb90 在 ??() 来自/lib/libc.so.6#2 0x00007ffff767a4c0 在来自/lib/libc.so.6 的 vfprintf ()#3 0x00007ffff768565a in printf () from/lib/libc.so.6....
当我在 gdb 中的断点处运行 info sharedlibrary
时,我看到:
(gdb) 信息共享库从到 Syms 读取共享对象库0x00007ffff7dddaf0 0x00007ffff7df6704 是 (*)/lib64/ld-linux-x86-64.so.20x00007ffff7bc53e0 0x00007ffff7bd1388 是 (*)/lib/libpthread.so.00x00007ffff79ba190 0x00007ffff79bd7d8 是 (*)/lib/librt.so.10x00007ffff76538c0 0x00007ffff7766c60 是 (*)/lib/libc.so.60x00007ffff6c1fd80 0x00007ffff6c303c8 是 (*)/lib/libgcc_s.so.1(*):共享库缺少调试信息.
当我运行 ldd
时,我看到:
linux-vdso.so.1 =>(0x00007ffff7fde000)libpthread.so.0 =>/lib/libpthread.so.0 (0x00007ffff7dbf000)librt.so.1 =>/lib/librt.so.1 (0x00007ffff7bb6000)libc.so.6 =>/lib/libc.so.6 (0x00007ffff7833000)/lib64/ld-linux-x86-64.so.2 (0x00007ffff7fdf000)
我使用的是 Ubuntu 10.04,我认为带有调试符号的 libc
版本在 /usr/lib/debug/lib
中.我尝试将我的 LD_LIBRARY_PATH
变量设置在路径的前面,但这似乎没有什么区别.
我不完全清楚程序如何选择要加载的共享库,是在运行时设置还是在编译时设置(我假设运行时,但现在我不确定).因此,我们非常感谢有关如何让 gdb 使用 libc
调试版本的信息.
我认为带有调试符号的 libc 版本在/usr/lib/debug/lib 中.我尝试将 LD_LIBRARY_PATH 变量设置为将其放在路径的前面,但这似乎没有什么区别.
这些不是您正在寻找的机器人.
您可以通过设置 更新: 例如我看到 这意味着您的 GDB 没有搜索 这是默认设置: Short version of question:
How can I get gdb to use the debugging symbols for Longer version:
I am debugging a program with gdb and I want to see information about a futex used by When I run And when I run I am using Ubuntu 10.04 and I think that the version of I'm not completely clear on how the program chooses which shared libraries to load, whether this is set at runtime or compile time (I sort of assumed runtime but now I'm not sure). So information on how to get gdb to use the debug version of I think that the version of libc with debug symbols is in /usr/lib/debug/lib. I tried setting my LD_LIBRARY_PATH variable to have this at the front of the path but that did not seem to make a difference. These are not the droids you are looking for. The libraries in The files in You can observe the files GDB is attempting to read by setting Update: For instance I see That implies that your GDB is not searching Here is the default setting:
这篇关于如何使用调试版的 libc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!/usr/lib/debug
中的库不是真正的 库.相反,它们仅包含调试信息,但不包含真正的 libc.so.6 的
.text
和 .data
部分代码>.您可以在此处阅读单独的调试信息文件.>/usr/lib/debug
中的文件来自 libc6-dbg
包,GDB 会自动加载它们,只要它们与您安装的 libc6
版本匹配.如果您的 libc6
和 libc6-dbg
不匹配,您应该收到 GDB 的警告.set verbose on
来观察 GDB 试图读取的文件.当 libc6
和 libc6-dbg
匹配时,您应该看到以下内容:(gdb) 设置详细信息(gdb) 运行thread_db_load_search 返回 0从/lib64/ld-linux-x86-64.so.2 读取符号...从/usr/lib/debug/lib/ld-2.11.1.so 读取符号...完成.thread_db_load_search 返回 0完毕.thread_db_load_search 返回 0为/lib64/ld-linux-x86-64.so.2 加载符号从系统提供的 DSO 读取符号 0x7ffff7ffb000...完成.警告:在系统提供的 DSO 中 0x7ffff7ffb000 处找不到调试符号.thread_db_load_search 返回 0读入 dl-debug.c 的符号...完成.读取 rtld.c 的符号...完成.从/lib/librt.so.1 读取符号...从/usr/lib/debug/lib/librt-2.11.1.so 读取符号...完成.thread_db_load_search 返回 0... 等等 ...
正在从/lib/libc.so.6 读取符号...(未找到调试符号)...完成
/usr/lib/debug
.一种可能发生的情况是,如果您在 .gdbinit
中错误地设置了 debug-file-directory
.(gdb) 显示调试文件目录搜索单独调试符号的目录是/usr/lib/debug".
libc
?libc
. However, at some point during debugging I get output such as:Catchpoint 2 (call to syscall futex), 0x00007ffff772b73e in ?? () from /lib/libc.so.6
(gdb) bt
#0 0x00007ffff772b73e in ?? () from /lib/libc.so.6
#1 0x00007ffff767fb90 in ?? () from /lib/libc.so.6
#2 0x00007ffff767a4c0 in vfprintf () from /lib/libc.so.6
#3 0x00007ffff768565a in printf () from /lib/libc.so.6
....
info sharedlibrary
in gdb at the breakpoint I see:(gdb) info sharedlibrary
From To Syms Read Shared Object Library
0x00007ffff7dddaf0 0x00007ffff7df6704 Yes (*) /lib64/ld-linux-x86-64.so.2
0x00007ffff7bc53e0 0x00007ffff7bd1388 Yes (*) /lib/libpthread.so.0
0x00007ffff79ba190 0x00007ffff79bd7d8 Yes (*) /lib/librt.so.1
0x00007ffff76538c0 0x00007ffff7766c60 Yes (*) /lib/libc.so.6
0x00007ffff6c1fd80 0x00007ffff6c303c8 Yes (*) /lib/libgcc_s.so.1
(*): Shared library is missing debugging information.
ldd
I see:linux-vdso.so.1 => (0x00007ffff7fde000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00007ffff7dbf000)
librt.so.1 => /lib/librt.so.1 (0x00007ffff7bb6000)
libc.so.6 => /lib/libc.so.6 (0x00007ffff7833000)
/lib64/ld-linux-x86-64.so.2 (0x00007ffff7fdf000)
libc
with debug symbols is in /usr/lib/debug/lib
. I tried setting my LD_LIBRARY_PATH
variable to have this at the front of the path but that did not seem to make a difference.libc
is appreciated.
/usr/lib/debug
are not real libraries. Rather, they contain only debug info, but do not contain .text
nor .data
sections of the real libc.so.6
. You can read about the separate debuginfo files here./usr/lib/debug
come from libc6-dbg
package, and GDB will load them automatically, so long as they match your installed libc6
version. If your libc6
and libc6-dbg
do not match, you should get a warning from GDB.set verbose on
. Here is what you should see when libc6
and libc6-dbg
do match:(gdb) set verbose on
(gdb) run
thread_db_load_search returning 0
Reading symbols from /lib64/ld-linux-x86-64.so.2...Reading symbols from /usr/lib/debug/lib/ld-2.11.1.so...done.
thread_db_load_search returning 0
done.
thread_db_load_search returning 0
Loaded symbols for /lib64/ld-linux-x86-64.so.2
Reading symbols from system-supplied DSO at 0x7ffff7ffb000...done.
WARNING: no debugging symbols found in system-supplied DSO at 0x7ffff7ffb000.
thread_db_load_search returning 0
Reading in symbols for dl-debug.c...done.
Reading in symbols for rtld.c...done.
Reading symbols from /lib/librt.so.1...Reading symbols from /usr/lib/debug/lib/librt-2.11.1.so...done.
thread_db_load_search returning 0
... etc ...
Reading symbols from /lib/libc.so.6...(no debugging symbols found)...done
/usr/lib/debug
. One way that could happen is if you set debug-file-directory
in your .gdbinit
incorrectly.(gdb) show debug-file-directory
The directory where separate debug symbols are searched for is "/usr/lib/debug".