http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53797
Bug #: 53797 Summary: Not able to print local variable while debugging at -O0 Classification: Unclassified Product: gcc Version: 4.6.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: shafi...@gmail.com I tried debugging the following function with arm,i686 and ppc C and C++ compiler. void func (int); int main () { func (20); return 0; } void func(int in) { int a; in++; { int k, j; k = 10; j = k + 44; in = j + 1; a = in; } <------ Line 1 a = in; a++; } <--------- Line 2 Invocation line : g++ main.cpp -g3 -gdwarf-2 --save-temps -dA -o main.elf When i try to print the value of 'a' when the execution reaches "line 2" i get the message "No symbol "a" in current context.". Here is the gdb output: (gdb) l 15 j = k + 44; 16 in = j + 1; 17 a = in; 18 } 19 a = in; 20 a++; 21 } 22 23 int main() 24 { (gdb) s 21 } (gdb) p a No symbol "a" in current context. (gdb) p in $1 = 55 (gdb) For the same program i am able to view the value of 'a' if i compile this as a C program. This happens because DW_TAG_lexical_block which is generated only for in C++ debug info marks the scope of variable 'a' between prologue and epilogue of the code. Since the epilogue is not present in the scope, the variable cannot be viewed when the control reaches the closing brace of the function.