Cann't print local vars when nesting functions

Jeff wd4nmq@comcast.net
Sat Feb 19 01:00:00 GMT 2005


I am having problems printing local stack variables when nesting 
functions. Here is a test app:
int main(int argc, char *argv[]){
  int i,j;
    i = 0;
    j = 1;
}

Now, run it to break on line:
    j = 1;
and then:
(gdb) p i
$2 = 0

and all is ok. but change to this:
int main(int argc, char *argv[]){
    int i,j;

    int inside(void){
       int k,l;
       k = 3;
       l = 4;
    }

    i = 0;
    j = 1;
}

Now set the break point to the same line, j =1, and this happens:
Breakpoint 1, main () at test.c:25
25        j = 1;
(gdb) p i
No symbol "i" in current context.
(gdb)

What gives? Is there something you need to special when nesting functions?

tj




More information about the Gdb mailing list