This is the mail archive of the
mailing list for the GDB project.
Re: Checking variable scope
"Rob Quill" <firstname.lastname@example.org> writes:
> The aim would be to add a command to gdb, in_scope (or similar) which
> can be used from a GDB script to check if a variable is in scope
> without throwing an error if is isn't. As currently if I do "print a"
> and a is not in scope then I get an error and the script stops, which
> is fine. But even better would be if I were able to check if a was in
> scope and only print (or do other things with it) if it was.
Why don't you add a new expression operator, $in_scope(a), which
evaluates to zero or one? You could just imitate the other code in
the parser and expression evaluator, so this should be straightforward
to implement, and then you could use it in GDB script conditional