Bug 34767 - trouble debugging C++ programs: info locals => No locals.
Summary: trouble debugging C++ programs: info locals => No locals.
Status: RESOLVED DUPLICATE of bug 27574
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.1.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-13 12:59 UTC by toomas@rosin.pri.ee
Modified: 2008-01-13 13:02 UTC (History)
8 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description toomas@rosin.pri.ee 2008-01-13 12:59:44 UTC

Here is the minimal test case exhibiting my trouble:

   $ cat bug.cc
   #include <iostream>
   
   class c { public: c (); };
   
   c::c ()
   {
     int i = 42;
     std::cout << i << std::endl;
   }
   
   int
   main (int argc, char** argv)
   {
     c* C = new c;
   }

I compile it with the following command:

   $ g++ -g -O0 bug.cc

With g++ 3.* or 4.0.*, everything's fine:

   (gdb) start
   Breakpoint 1 at 0x4008d8: file /home/toomas/bug.cc, line 14.
   warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7fff193fd000
   main (argc=1, argv=0x7fff19283c78) at /home/toomas/bug.cc:14
   14        c* C = new c;
   (gdb) s
   c (this=0x602010) at /home/toomas/bug.cc:7
   7         int i = 42;
   (gdb) s
   8         std::cout << i << std::endl;
   (gdb) p i
   $1 = 42
   (gdb) info locals
   i = 42

But with version 4.1.0 and above, I cannot inspect local symbols
in c::c():

   (gdb) start
   Breakpoint 1 at 0x4008d8: file /home/toomas/bug.cc, line 14.
   warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff13fd000
   main (argc=1, argv=0x7ffff1261c58) at /home/toomas/bug.cc:14
   14        c* C = new c;
   (gdb) s
   c (this=0x602010) at /home/toomas/bug.cc:7
   7         int i = 42;
   (gdb) s
   8         std::cout << i << std::endl;
   (gdb) p i
   No symbol "i" in current context.
   (gdb) info locals
   No locals.

At the same time, there is nothing wrong with the local symbols of
main().

Experimenting with sources co'd from SVN (trunk), I found out that
the last revision that behaves correctly is -r96653.  There was
one change in -r96654:

   2005-03-18  Jan Hubicka  <jh@suse.cz>

          * cgraph.c (cgraph_remove_node): Avoid loop in code deciding whether
          function body should be released; do not proactively release function
          bodies in non-unit-at-a-time mode.

Here I turned out to have arrived at the seat of the end of my
wits.

Output of `objdump -lSd' was exactly the same in both cases, but
there were many differences in the `.debug_info' section.

This seems not to be a hardware- or distribution-specific issue,
because I have the same situation on two Debian systems and on a
hand-crafted system, with both AMD64 and Pentium 4 hardware.  (All
of them GNU/Linux.)

Thanks in advance,
Toomas.

Environment:
System: Linux toomas 2.6.23.1 #1 SMP Sun Nov 4 13:54:34 EET 2007 x86_64 GNU/Linux
host: x86_64-unknown-linux-gnu
build: x86_64-unknown-linux-gnu
target: x86_64-unknown-linux-gnu
configured with: /INCOMING/misc/gcc-96654/configure --disable-multilib --disable-bootstrap --enable-languages=c,c++

How-To-Repeat:

cat > bug.cc << EOF
#include <iostream>

class c { public: c (); };

c::c ()
{
  int i = 42;
  std::cout << i << std::endl;
}

int
main (int argc, char** argv)
{
  c* C = new c;
}
EOF

g++ -g -O0 bug.cc

{ echo start; echo s; echo s; echo info locals; } | gdb --batch -x - ./a.out
Comment 1 Andrew Pinski 2008-01-13 13:02:20 UTC

*** This bug has been marked as a duplicate of 27574 ***