考虑:
(gdb) q
A debugging session is active.
Inferior 1 [process 9018] will be killed.
Quit anyway? (y or n) y
Run Code Online (Sandbox Code Playgroud)
什么是.gdbinit使GDB始终在退出请求时终止正在运行的进程的选项?
我知道,GDB能够连接到已经运行的进程,所以这将是糟糕的杀了他们的退出.但是,对于一个过程,从它开始,需要确认你的行动开始于第二个退出骚扰.
Eri*_*ric 62
关闭全局禁用确认提示会禁用许多其他有用的检查,例如在您键入"删除"时询问您是否确实要删除所有断点的检查.
最好只为quit命令禁用提示符.您可以通过将此挂钩添加到〜/ .gdbinit(对于当前用户)或/ etc/gdb/gdbinit(对于所有用户)来执行此操作:
define hook-quit
set confirm off
end
Run Code Online (Sandbox Code Playgroud)
ks1*_*322 29
set confirm off
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅gdb doc
Jon*_*ely 11
另一种选择是定义一个退出而不要求确认的新命令:
define qquit
set confirm off
quit
end
document qquit
Quit without asking for confirmation.
end
Run Code Online (Sandbox Code Playgroud)
现在您可以使用qquit或只是qq快速退出,而无需更改默认行为quit
总之,这将直接运行程序并且不要求退出确认:
gdb -ex="set confirm off" -ex=r --args ...
Run Code Online (Sandbox Code Playgroud)