From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7050 invoked by alias); 28 Jun 2012 11:33:21 -0000 Received: (qmail 7042 invoked by uid 22791); 28 Jun 2012 11:33:21 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_GD X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 28 Jun 2012 11:33:04 +0000 From: "shafitvm at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/53797] New: Not able to print local variable while debugging at -O0 Date: Thu, 28 Jun 2012 11:33:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: shafitvm at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-06/txt/msg01869.txt.bz2 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: unassigned@gcc.gnu.org ReportedBy: shafitvm@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.