【问题标题】:How to save gdb setup information inside gdb session?如何在 gdb 会话中保存 gdb 设置信息?
【发布时间】:2016-10-20 04:04:25
【问题描述】:

我们可以使用 .gdbinit 或命令文件来启动带有预设命令和宏定义的 gdb。但我的情况是:

我已经启动 gdb 并定义了一些“断点”、“命令”、“定义”,如何通过 gdb 命令将这些调试会话信息保存到文件(.gdbinit 或命令文件)中?我不想追溯 gdb 命令历史并复制粘贴所有这些类型。

gdb 支持这个吗? 谢谢。

【问题讨论】:

    标签: session save gdb command breakpoints


    【解决方案1】:

    您可以使用 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 命令的输出,但不记录命令本身。
    【解决方案2】:

    您可以通过 gdb 部分完成此操作,但除此之外,您有点靠自己。

    您可以做的就是保存断点。很简单:

    (gdb) save breakpoints /tmp/whatever-file
    

    不幸的是,目前没有办法保存 define —— 有 a gdb bug 可以解决这个问题。

    在这种情况下,您可以做的一件事是使用show user 找到您的命令,然后将其剪切并粘贴到文件中。或者也许可以从 Python 实现假设的save user

    【讨论】:

      猜你喜欢
      • 2011-01-03
      • 1970-01-01
      • 2019-11-21
      • 1970-01-01
      • 1970-01-01
      • 2014-08-18
      • 2014-07-22
      • 2013-06-27
      • 2021-12-14
      相关资源
      最近更新 更多