建议执行系统库调用的源代码级调试的方法是什么? [英] What is the recommended way to perform source-level debugging of system library calls?
问题描述
我需要调试系统库中的某些调用,以了解这些调用之间的差异以及一个或另一个失败的原因.
I have a need to debug into some calls in system libraries, to understand how the calls differ, and why one or another would be failing.
现在,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
It is now common for Linux distros to provide stripped system libraries and separate debug symbol files. For example, /lib/libc-2.8.so is stripped of symbols, leaving behind a section named .gnu_debuglink that contains info to find a separate debug file. The separate debug files are installable through a debug package, and contain symbolic info needed by gdb. It's well described here http://www.technovelty.org/code/debug-info-symbols.html and http://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html
安装调试包和源代码之后,我期望GDB可以找到符号和源代码,并且能够查看列表并进入调用.相反,gdb告诉我"xyz没有已知的行号"
After installing the debug package and the sources, I was expecting that GDB would find the symbols and sources and I would be able to view listings and step into the calls. Instead, gdb tells me "no line number known for xyz"
我已经验证了debug-file-location是正确的,并且目录已设置为源目录.
I've verified that debug-file-location is correct, and directories is set to the source directories.
是否有可能做我想做的事情?我会以错误的方式处理吗?有没有更简单的方法?
Is it even possible to do what I want? Am I going about this the wrong way? Is there a simpler way?
推荐答案
您是否尝试在GDB中设置debug-file-directory
参数?根据您指出的文档,它应该执行您想要的操作:
Did you try to set the debug-file-directory
parameter in GDB? As per the documentation you pointed out, it should do what you want:
set debug-file-directory directories
设置gdb搜索单独调试的目录 信息文件到目录.可以有多个目录组件 设置通过目录分隔符将它们连接起来.
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
显示目录gdb搜索以进行单独的调试
信息文件.
show debug-file-directory
Show the directories gdb searches for separate debugging
information files.
例如在我的Fedora发行版中,目录为/usr/lib/debug
.
For instance in my Fedora distribution, the directory is /usr/lib/debug
.
您也可以在编译时使用
configure --with-separate-debug-dir=/usr/lib/debug ...
这篇关于建议执行系统库调用的源代码级调试的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!