也许,我误解了什么,但我不能让 Gdb 读取调试库。 我从命令行做的是:
gdb
file problem_exec
b main
r
GDB 停止于:
(gdb) r
Starting program: /Users/.../problem_exec
Breakpoint 1, main (argc=<error reading variable: Could not find the frame base for "main(int, char**)".>, argv=<error reading variable: Could not find the frame base for "main(int, char**)".>)
没有共享库:
(gdb) info shared
No shared libraries loaded at this time.
最后一条命令给出:“此时没有加载共享库。”
我的 .gdbinit 看起来像:
# file .gdbinit
set stop-on-solib-events 1
# stop gdb from stepping over functions and output diagnostics
set step-mode on
set breakpoint pending on
set env DYLD_LIBRARY_PATH path1:path2:path3
#automatically load shared libraries (on/off):
set auto-solib-add on
我确信可执行文件链接到共享库的调试版本(总共有大约 30 个库,但我感兴趣的肯定是在 Debug模式下编译的)。我用 otool -L problem_exec 检查了它
如果我运行程序,它会一直运行到我想调试的库中出现运行时错误,但我无法介入。
我错过了什么吗?
附注我在 os-x 上运行自编译版本的 Gdb。
更新:可能与此 problem 有关.
最佳答案
set stop-on-solib-events 1
使用该设置,GDB 应该在加载任何共享库之前停止。
当你这样做时:
file problem_exec
b main
r
... where is GDB stopped?
info shared
如果 GDB 在 main
处停止,则应该加载共享库。但是如果它在动态加载器中停止(如我所料),那么它们应该 加载。
关于gdb7.7 不加载共享库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22492686/