gdb7.7 不加载共享库

标签 gdb

也许,我误解了什么,但我不能让 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/

相关文章:

c - 临时 C 字符串具有相同的地址

c++ - std string对象的内部结构

c - memset 没有设置 num 个字节?

C++ 程序在执行 std::string 分配时总是崩溃

linux - 如何从 gdb 中自动重新连接到由 valgrind 控制的进程?

c++ - 任意类型上的 GDB 条件断点,例如 C++ std::string 相等性

linux - 如何将多个输入从文件重定向到正在 gdb 中调试的二进制文件?

c - gdb 回溯显示 malloc

c - 使用 sigaction 实现 ctr-c

gdb - 使用 gdb 列出加载的模块