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
Im having the same problem.. you can't check if a variable has been set or not as far as I know in GDB.. you could run it through python, probably, and have the whole script run that way, but I am unsure of it the python scripts in GDB are persistent or running all the time. You could do something like..
init-if-undefined $_exitcode = 1
if $_exitcode == 0
quit
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With