Aditya Chugh writes: > Hello Jtc, > Many thanks for your help. > The target I'm using is a Linux machine > running kernel version 2.2.16-22(Red Hat Linux release 7.0) > and the version of gdb is 5.0. > > Also the gdb output looked like this....? > (gdb) p u2IncarnId > $2 = 0 > (gdb) n > (gdb) p u2IncarnId > $3 = 1 > (gdb) p &u2IncarnId > Address requested for identifier "u2IncarnId" which is in a register. > (gdb) > > I found that one of the Makefiles I was using has > CCFLAGS  = -O2 -Wall.After removing the -O2 the problem seems to have been > resolved. > > But does this mean that if we complile using GNU CC with both `-g'  and `-O' > options > GDB will give us wrong results ?? Moreover the same code when run in Visual > Studio 6.0 > prints correct values for u2IncarnId.Does this mean that the debugger in > Visual Studio 6.0 > is better than GDB for optimized code ? Right now? Quite possibly. Optimized debugging support in GDB is only really possible through fully supporting things we don't fully support yet. --Dan