测试是否定义了gdb便利变量 [英] Testing if a gdb convenience variable is defined

查看:217
本文介绍了测试是否定义了gdb便利变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



例如:

$ b是否有方法测试gdb中是否设置了便利变量?
$ b

 
(gdb)if $ _exitcode == 0
> quit
> end
相等测试中的无效类型组合。
(gdb)p $ _exitcode
$ 1 = void

$ _ exitcode void ,因为它在程序结束之前不会被设置。最接近的可用构造是 init-if-undefined ,但这需要将变量设置为某个标记值并进行测试。

解决方案

<由于正常的进程退出代码介于0到255之间,因此我建议如下:

pre $ init $ if $ undefined $ _exitcode = -1
if($ _exitcode!= -1)
quit
end


Is there a way to test if a convenience variable has been set in gdb?

For example:

(gdb) if $_exitcode == 0
 >quit
 >end
Invalid type combination in equality test.
(gdb) p $_exitcode
$1 = void

$_exitcode is void because it is not set until the program terminates. The closest available construct is init-if-undefined, but this would require setting the variable to some sentinel value and testing against that.

解决方案

Since normal process exit code is somewhere in between 0 and 255, I suggest following:

init-if-undefined $_exitcode = -1
if ($_exitcode != -1)
  quit
end

这篇关于测试是否定义了gdb便利变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆