相关疑难解决方法(0)

让gdb保存断点列表?

好的,info break列出了断点,但是没有使用在这个问题中使用--command重用它们的格式.gdb是否有一种方法可以将它们转储到可接受输入的文件中?有时在调试会话中,有必要在构建一组断点进行测试后重新启动gdb.

编辑: .gdbinit文件与--command具有相同的问题.info break命令不列出命令,而是列出供人消费的表.

详细说明,这是一个来自info break的示例:

(gdb) info break
Num Type           Disp Enb Address    What
1   breakpoint     keep y   0x08048517 <foo::bar(void)+7>

c c++ debugging gdb breakpoints

125
推荐指数
6
解决办法
4万
查看次数

如何在gdb脚本中确认操作(回答"Y")?

我使用gdb来调试我的cpp代码.我用这种方式设置断点:

(gdb) break ParseDriver.cc:60
No source file named ParseDriver.cc.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (ParseDriver.cc:60) pending.
Run Code Online (Sandbox Code Playgroud)

为了简化设置断点,我编写了一个简单的gdb脚本(名为breakpoints.gdb),它只包含一行:

break ParseDriver.cc:60
Run Code Online (Sandbox Code Playgroud)

我在gdb终端中获取此脚本,但它失败了.

(gdb) source ~/breakpoints.gdb
No source file named ParseDriver.cc.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
Run Code Online (Sandbox Code Playgroud)

似乎我们需要在脚本中回答Y以设置断点.

那么,我如何在gdb脚本中回答Y?先感谢您.

debugging gdb breakpoints

21
推荐指数
1
解决办法
6907
查看次数

如何从.gdbinit强制断点?

当我在.gdbinit使用中设置断点时:

b foobar
Run Code Online (Sandbox Code Playgroud)

我明白了:

Function "foobar" not defined.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
Run Code Online (Sandbox Code Playgroud)

现在第一行是可以理解的,因为该函数驻留在共享库中.但是,默认为no.

如何强制它在这种非交互式场景中设置断点?

gdb breakpoints

8
推荐指数
1
解决办法
3486
查看次数

关闭 GDB 中设置断点的确认

在共享库上设置断点:

(gdb) b file.c:278
 No symbol table is loaded.  Use the "file" command.
 Make breakpoint pending on future shared library load? (y or [n]) y
Run Code Online (Sandbox Code Playgroud)

我可以让 gdb 不问这个问题吗?(也就是说,跳过确认?)

c gdb

5
推荐指数
1
解决办法
1326
查看次数

gdb的"输入不是来自终端"消息可以被抑制吗?

我有一个gdb以命令结尾的脚本quit.

当我像这样运行脚本时:

gdb -x foo.gdb target_program
Run Code Online (Sandbox Code Playgroud)

最终输出始终具有:

Quit anyway? (y or n) [answered Y; input not from terminal]
Run Code Online (Sandbox Code Playgroud)

有没有办法抑制整个消息,甚至只是内部的部分[]

[answered Y; input not from terminal]
Run Code Online (Sandbox Code Playgroud)

gdb

5
推荐指数
1
解决办法
1049
查看次数

标签 统计

gdb ×5

breakpoints ×3

c ×2

debugging ×2

c++ ×1