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

hel*_*jie 21 debugging gdb breakpoints

我使用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?先感谢您.

mat*_*att 43

(gdb) set breakpoint pending on
Run Code Online (Sandbox Code Playgroud)

这将使gdb跳过要求确认,引用文档:

这表示无法识别的断点位置应自动导致创建挂起的断点.