c - why gdb show wrong variable value? -
this question has answer here:
i have simple program:
#include <stdio.h> void func(int i) { = 1; printf("%d\n", i); } int main(int argc, char *argv[]){ func(0); return 0; }
and now:
gcc test.c -g -o test gdb test (gdb) b main breakpoint 1 @ 0x400543: file test.c, line 9. (gdb) run starting program: /tmp/test breakpoint 1, main (argc=1, argv=0x7fffffffe458) @ test.c:9 9 func(0); (gdb) s func (i=0) @ test.c:4 4 =1; (gdb) p $1 = 0 (gdb) n 5 printf("%d\n", i); (gdb) p $2 = 0 (gdb)
program works fine, shows "1", why gdb shows me "0" value?
debian wheezy.
i observed on gcc-4.7, gcc-4.6. on gcc-4.4 ok.
this bug fixed if compile -fvar-tracking
. question tighter version of this question, references bug report on gcc 4.8.0 suggesting above compile flag.
Comments
Post a Comment