public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53797] New: Not able to print local variable while debugging at -O0
@ 2012-06-28 11:33 shafitvm at gmail dot com
  2012-06-28 11:58 ` [Bug c++/53797] " rguenth at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: shafitvm at gmail dot com @ 2012-06-28 11:33 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/53797] Not able to print local variable while debugging at -O0
  2012-06-28 11:33 [Bug c++/53797] New: Not able to print local variable while debugging at -O0 shafitvm at gmail dot com
@ 2012-06-28 11:58 ` rguenth at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-06-28 11:58 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53797

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-06-28
     Ever Confirmed|0                           |1
      Known to fail|                            |4.8.0

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-06-28 11:58:22 UTC ---
Confirmed.  Works with the C frontend.  The difference is different location
info for the BLOCK:

-func (int in)
-[t.C : 9:1] {
+void func(int) (int in)
+[t.C : 20:6] {
   int a;
...
-  [t.C : 19:5] a = in;
-  [t.C : 20:4] a = a + 1;
+  [t.C : 19:9] a = in;
+  [t.C : 20:6] a = a + 1;
 }

for -C +C++.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-06-28 11:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-28 11:33 [Bug c++/53797] New: Not able to print local variable while debugging at -O0 shafitvm at gmail dot com
2012-06-28 11:58 ` [Bug c++/53797] " rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).