以下是直接来自gdb控制台的示例会话
Starting program:
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Breakpoint 1, 0x00000000025654f0 in ~F()
(gdb) bt
#0 0x00000000025654f0 in ~F()
at hello.cpp:123
(gdb) c
Continuing.
foo.cpp:122:12: runtime error: member call on null pointer of type 'Object'
这是我的.gdbinit
文件
set pagination off
set language c++
set print pretty on
set logging file gdb.txt
set logging on
break ~F()
info breakpoints
r
bt
c
set logging off
quit
生成的gdb.txt看起来像这样:
Breakpoint 1 at 0x25654f0
Num Type Disp Enb Address What
1 breakpoint keep y 0x00000000025654f0 <~F()>
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Breakpoint 1, 0x00000000025654f0 in ~F()
#0 0x00000000025654f0 in ~F()
....
Breakpoint 1, 0x00000000025654f0 in ~F()
我没有在日志中看到foo.cpp:122:12: runtime error: member call on null pointer of type 'Object'
。我如何将其纳入我的日志?
由于
答案 0 :(得分:0)
该消息来自您的程序,而不是来自gdb。
使其工作的一种方法是让您的程序和gdb写入同一个日志。这里唯一的技巧是确保它们都以“追加”模式写入。这有一个“set logging”子命令,对于你的程序,你可以运行:
(gdb) run >> log