This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Cann't print local vars when nesting functions


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]