我正在尝试调试 libc
在 Ubuntu 14.04 上,但无法使用 gdb
执行此操作因为库和源没有正确匹配。
gdb
无法正确放置断点。就像这样,我能够进入一个函数并查看源代码,但断点标记将位于函数内部的某个随机位置,而不是在开头。
当我使用 next
逐个语句进行处理时在 gdb
, 标记会一直上下跳动(原因是源文件和调试库没有正确匹配。
我的 glibc
版本根据 ldd
是
ldd --version
ldd (Ubuntu EGLIBC 2.19-0ubuntu6.6) 2.19
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
我已经下载了 libc
使用命令的来源:
sudo apt-get source libc6
以上将创建以下文件:
eglibc-2.19
eglibc_2.19-0ubuntu6.6.debian.tar.xz
eglibc_2.19-0ubuntu6.6.dsc
eglibc_2.19.orig.tar.xz
在gdb
我在做
dir <path-to-libc-source>/nptl
(nptl 因为我正在进入 pthread_create
)
我试过同时使用 eglibc-2.19
来源以及eglibc_2.19.orig.tar.xz
.
我也试过设置 LD_LIBRARY_PATH: export LD_LIBRARY_PATH=/usr/lib/debug
但以上也无济于事。
谁能成功调试libc
代码分享他/她的技术如何正确地做到这一点?
最佳答案
假设源代码版本和库版本相同....
'跳转'的根本原因是编译器优化经常改变可执行代码的顺序而不是源文件中的顺序。
当使用任何优化参数编译代码时会发生这种情况。
关于c - 无法在 Ubuntu 14.04 上调试 libc 源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33784699/