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]

Still problems with gdb and nested functions.


I posted before about gdb not printing local variables when within nested functions and I thought the problem had been solved when it was mentioned my demo worked when using gdb 6.1, which I upgraded to.
BUt, now I have discovered even it has a problem.
Sample file:
#include <stdio.h>


int main(int argc, char *argv[]){

int i,j;

 int inside(void){
   int k,l;

   k = 1;
   l = k;
   printf("inside, k = %d, l = %d\n", k,l);
   return 0;

}

 inside();
 i = 0;
 j = 1;
}

Now, run gdb and do the following:
(gdb) b test.c:12
Breakpoint 1 at 0x8048352: file test.c, line 12.
(gdb) b test.c:19
Breakpoint 2 at 0x804838d: file test.c, line 19.
(gdb) run
Starting program: /home/wd4nmq/src/test/test/a.out

Breakpoint 1, inside.0 () at test.c:12
12          printf("inside, k = %d, l = %d\n", k,l);
(gdb) p k
No symbol "k" in current context.
(gdb) continue
Continuing.
inside, k = 1, l = 1

Breakpoint 2, main (argc=1, argv=0xbffff964) at test.c:19
19        j = 1;
(gdb) p i
$1 = 0
(gdb)

While it now prints the value of i, which it wasn't pre v6.1, but it still doesn't print the k value when stopped within the inside() function, where it is in scope.
Oh well, at least is some progress :-).


gcc 3.23
gdb 6.1

tj



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