我需要调试系统库中的一些调用,以了解这些调用有何不同,以及为什么一个或另一个会失败。
Linux 发行版现在普遍提供剥离的系统库和单独的调试符号文件。例如,/lib/libc-2.8.so 被剥离了符号,留下了一个名为 .gnu_debuglink 的部分,其中包含用于查找单独的调试文件的信息。单独的调试文件可通过调试包安装,并包含 gdb 所需的符号信息。这里描述得很好 http://www.technovelty.org/code/debug-info-symbols.html和 http://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html
安装调试包和源代码后,我希望 GDB 能够找到符号和源代码,并且我能够查看列表并进入调用。相反,gdb 告诉我“没有已知的 xyz 行号”
我已验证 debug-file-location 是正确的,并且目录设置为源目录。
有没有可能做我想做的事?我会以错误的方式解决这个问题吗?有没有更简单的方法?
最佳答案
您是否尝试在 GDB 中设置 debug-file-directory
参数?根据您指出的文档,它应该做您想要的:
set debug-file-directory directories
Set the directories which gdb searches for separate debugging information files to directory. Multiple directory components can be set concatenating them by a directory separator.
show debug-file-directory
Show the directories gdb searches for separate debugging information files.
例如在我的 Fedora 发行版中,目录是 /usr/lib/debug
。
你也可以在编译时定义它
configure --with-separate-debug-dir=/usr/lib/debug ...
关于linux - 执行系统库调用的源代码级调试的推荐方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7275995/