linux - 执行系统库调用的源代码级调试的推荐方法是什么?

标签 linux glibc

我需要调试系统库中的一些调用,以了解这些调用有何不同,以及为什么一个或另一个会失败。

Linux 发行版现在普遍提供剥离的系统库和单独的调试符号文件。例如,/lib/libc-2.8.so 被剥离了符号,留下了一个名为 .gnu_debuglink 的部分,其中包含用于查找单独的调试文件的信息。单独的调试文件可通过调试包安装,并包含 gdb 所需的符号信息。这里描述得很好 http://www.technovelty.org/code/debug-info-symbols.htmlhttp://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/

相关文章:

c - 如何从 C 中检查目标文件是 COFF 还是 ELF 格式?

linux - 哪种线程更适合计算密集型并行应用和I/O密集型并行应用?

assembly - 如何在 Ubuntu 中动态链接到 glibc

找不到 GLIBCXX_3.4.15、GLIBC_2.15 和 GLIBC_2.14 - Centos 6.5

c - 检测到 glibc,realloc() : invalid pointer

linux - 通过&&运行命令时docker容器中进程的PID

linux - 对于 Linux 上的 Node v 4.4.2,获取 "Error: Cannot find module ' ./namegen.js'"

c - 配置文件 glib 中字符串键的引号

c - 如何知道编译器正在编译的函数的位置

linux - 着色 echo 在 Solaris 中有效,但在 Linux 中无效