我们可以使用.gdbinit或一个命令文件来启动带有预设命令和宏定义的gdb。但我的情况如下:如何在gdb会话中保存gdb设置信息?
我已经启动gdb并定义了几个“断点”,“命令”,“定义”,如何将这些调试会话信息保存到文件(.gdbinit或命令文件)中一个gdb命令?我不希望追溯gdb命令历史记录并复制粘贴所有这些类型。
gdb是否支持这个? 谢谢。
我们可以使用.gdbinit或一个命令文件来启动带有预设命令和宏定义的gdb。但我的情况如下:如何在gdb会话中保存gdb设置信息?
我已经启动gdb并定义了几个“断点”,“命令”,“定义”,如何将这些调试会话信息保存到文件(.gdbinit或命令文件)中一个gdb命令?我不希望追溯gdb命令历史记录并复制粘贴所有这些类型。
gdb是否支持这个? 谢谢。
您可以使用GDB日志记录功能。 以下说明可在GDB文档中找到。
https://sourceware.org/gdb/current/onlinedocs/gdb/Logging-Output.html#Logging-Output
set logging on
Enable logging.
set logging off
Disable logging.
set logging file file
Change the name of the current logfile. The default logfile is gdb.txt.
set logging overwrite [on|off]
By default, gdb will append to the logfile. Set overwrite if you want set logging on to overwrite the logfile instead.
set logging redirect [on|off]
By default, gdb output will go to both the terminal and the logfile. Set redirect if you want output to go only to the log file.
show logging
Show the current values of the logging settings.
GDB中可以部分地做到这一点,否则你只能靠自己了一下。
你可以做的是保存断点。这很容易:
(gdb) save breakpoints /tmp/whatever-file
不幸的是目前没有办法保存define
- 有a gdb bug这一点。
在这种情况下你可以做的一件事是使用show user
找到你的命令,然后剪切并粘贴到一个文件中。或者也许可以从Python实现假设的save user
。
日志记录记录gdb命令的输出,但不记录命令本身。 –