What is the recommended way to perform source-level debugging of system library calls?

此生再无相见时 提交于 2019-12-18 07:14:27

问题


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.

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

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"

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?


回答1:


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 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.

For instance in my Fedora distribution, the directory is /usr/lib/debug.

You can also define it at compile time with

configure --with-separate-debug-dir=/usr/lib/debug ...


来源:https://stackoverflow.com/questions/7275693/what-is-the-recommended-way-to-perform-source-level-debugging-of-system-library

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!