GDB进入动态链接器(ld.so)代码 [英] GDB step into Dynamic linker(ld.so) code
问题描述
我想在我的普通 c
代码中使用ld.so代码。
我试图在 TUI 模式下通过GDB进行代码流可以看到代码和程序集。
为此,我还安装了 libc-dbg
binutils-source
来自ubuntu软件包管理器的软件包。
GDB可以找到 ld.so
本身的调试符号,我可以在指令级使用 si
但我无法步入源代码级别,因为GDB无法找到 ld.so
的源代码并且显示无可用源代码
。
如何让GDB找到 ld.so
的来源,以便我还可以看到 ld.so
源中的哪一行实际上正在执行中。
我正在使用 Ubuntu 12.10
64bit with GCC 4.8.2
如果你有libc的源代码可用,你可以使用 dir
命令将源代码添加到gdb的源代码路径中: Source_Path
编辑:调试libc相关文件(在Ubuntu发行版中),您需要:
- 通过安装libc6-dbg包获取libc的调试信息。
- 通过启用源代码库(通过运行
software-sources
并检查启用源代码存储库)并运行apt-get源libc6
- 将libc的调试信息添加到LD_LIBRARY_PATH中:
export LD_LIBRARY_PATH = / usr / lib / / code>或
LD_LIBRARY_PATH = / usr / lib / debug gdb< application>
- 添加c文件的完整路径到gdb的源路径,这是:
dir directory_path_libc_source / stdio-common
I wanted to step into the code of ld.so whenever it will be used in my normal c
code.
I am trying to code flow through GDB in the TUI mode where you can see both source code and assembly as you step over the code.
For this I also installed libc-dbg
binutils-source
package from ubuntu package manager.
GDB can find the debug symbols for the ld.so
itself and I can step at the instruction level that is using si
but I cant step at the source level as GDB is not able to find the source for ld.so
and shows NO Source Available
.
How can I make GDB find the source for ld.so
so that I can also see which line in the ld.so
source is actually being executed.
I am using Ubuntu 12.10
64bit with GCC 4.8.2
If you've libc's source code available, you can add sources to gdb's source path with dir
command: Source_Path
Edit: To debug libc related files (in a Ubuntu distro) you would need to:
- Get libc's debug information by installing libc6-dbg packet.
- Get libc's source code by enabling source repositories (by running
software-sources
and and checking "enable source code repositories") and runningapt-get source libc6
- Add libc's debug information into LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=/usr/lib/debug
orLD_LIBRARY_PATH=/usr/lib/debug gdb <application>
- Add full path to c file to gdb's source path, this is:
dir directory_path_libc_source/stdio-common
这篇关于GDB进入动态链接器(ld.so)代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!