I'm trying to write a GDB script (legacy, not Python) that will print information on members of a local variable (a C or C++ struct), but only if that local variable exists. Something like:
# 'magic' should be evaluate to "if 'info locals' has a variable named foo, then
# evaluate to true, otherwise evaluate to false.
if (magic)
print foo->member
end
I know this is somewhat contrived, because the locals are dependent on the stack frame (so I'm probably better off making it conditional on the frame), but I'd still like to know if something along these lines is possible.