This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
test availability of variables in context from user command
- From: Christophe Demarey <Christophe dot Demarey at inria dot fr>
- To: gdb at sourceware dot org
- Date: Fri, 23 Feb 2007 16:59:04 +0100
- Subject: test availability of variables in context from user command
Hello,
I want to check the availability of a variable (var1 for instance) in
the context from an user command but I don't find any way to do this.
Here is a (dummy) example of what I want to do :
void func1(void)
{
int var2 = 2;
...
}
int main(int argc, char **argv)
{
int var1 = 1;
...
func1();
}
My gdb command:
define myfunc
if defined(var1)
$res = $var1
else
$res = $var2
end
...
end
If I break into main, res should be equals to 1, else res should be
equals to 2.
Is there a way to do this with gdb?
Thanks,
Christophe.