如何确保GDB终止命令文件错误?
我想使用命令文件自动化GDB调试会话,但要确保GDB每次终止。
这是文档中描述的问题:
任何命令中的错误终止了命令文件的执行和 控制返回控制台。
就我而言,如果有错误,我希望脚本继续或终止GDB。即不要让它返回控制台(并让我手动退出)。例如,请参见下面
echo Starting GDB script\n
set confirm off
set pagination off
echo Connecting to target\n
target remote localhost:1234
thread 1
thread 2 # <-- This command will produce an error, and stop the script from terminating GDB
k
q
I want to automate a GDB debug session using command files but want to make sure GDB terminates every time.
This is a problem as described in the documentation :
An error in any command terminates execution of the command file and
control is returned to the console.
In my case I want the script to either continue or terminate GDB if there is an error. I.e. dont let it return to console (and make me quit manually). E.g. see below
echo Starting GDB script\n
set confirm off
set pagination off
echo Connecting to target\n
target remote localhost:1234
thread 1
thread 2 # <-- This command will produce an error, and stop the script from terminating GDB
k
q
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
-batch
参数调用GDB,它将忽略脚本错误。例子:
Invoke GDB with
-batch
argument, and it will ignore script errors.Example: