【发布时间】:2015-08-21 16:03:04
【问题描述】:
有没有办法将 gdb 日志保存在文件中。 我发现:
$gdb run.o
(gdb) set logging file mylog.txt
(gdb) set logging on
(gdb)r
但它只保留命令日志。 是否有任何选项可以将所有日志都保存在一个文件中?
【问题讨论】:
标签: linux debugging logging gdb
有没有办法将 gdb 日志保存在文件中。 我发现:
$gdb run.o
(gdb) set logging file mylog.txt
(gdb) set logging on
(gdb)r
但它只保留命令日志。 是否有任何选项可以将所有日志都保存在一个文件中?
【问题讨论】:
标签: linux debugging logging gdb
是的,也不是。
GDB 不能这样做,因为正在调试的程序的输出对它不可见。
穷人的做法是用tee:
gdb <blah> | tee logfile
这可行,但您会发现缺少 GDB 的交互功能(自动完成、分页等)。
我的首选方法是使用终端中的日志记录功能。我使用启用了“记录器”插件的“终结者”,但我确信还有其他选项。
【讨论】:
script(1)。
是否有任何选项可以将所有日志保存在一个文件中
来自man script:
script makes a typescript of everything printed on your terminal.
It is useful for students who need a hardcopy record of an interactive
session as proof of an assignment, as the typescript file can be
printed out later with lpr(1).
【讨论】: