按 Enter 时停止 gdb 重复最后一个(第三方)命令

Rog*_*mbe 6 gdb

我在 gdb 中使用了一些第三方宏,这需要长时间才能运行。

我一直按 Enter,因为我的肌肉记忆就是这样做的。

这会导致宏再次运行。

有什么办法可以说服gdb 在按 Enter 时运行上一个命令?

我找到了 dont-repeat文档,但似乎必须将其添加到用户定义的命令中。这些是第三方命令,我并不特别想编辑所有这些命令。

有没有办法在全球范围内关闭这种行为?或者对于特定命令(可能带有通配符/正则表达式)?

ks1*_*322 7

这些是第三方命令,我并不特别想编辑所有这些命令。

对于特定命令,您可以定义预挂钩,关闭重复上一个命令。这将使您避免编辑它们。例如,您可以为continue命令定义这样的预挂钩:

(gdb) c
The program is not being run.
(gdb) 
The program is not being run.
(gdb) 
The program is not being run.
(gdb) 
The program is not being run.
(gdb) 
The program is not being run.
(gdb) define hook-continue
Type commands for definition of "hook-continue".
End with a line saying just "end".
>dont-repeat
>end
(gdb) c
The program is not being run.
(gdb) 
(gdb) 
(gdb) 
(gdb) 
(gdb) 
Run Code Online (Sandbox Code Playgroud)

请参阅钩子文档