g++-4.0.1 (also reproduced with g++-3.4.4) fails to add the linkage name of the
class constructor to the debugging info, making it impossible to set
breakpoints in classes containing more than one constructor (e.g. with gdb).

How to reconstruct: Save the following as test.hpp:

class TestClass {
  int y;
public:
  int funcA(void);
  TestClass(int x);
  ~TestClass(void);
};

Save the following as test.cpp:

#include "test.hpp"

int TestClass::funcA(void)
{
  return y;
}

TestClass::TestClass(int x)
  : y(x)
{
}

TestClass::~TestClass(void)
{
}

int main(void)
{
  TestClass a(0);

  return a.funcA();
}

Compile g++ test.cpp -ggdb3 -O0, then check the debugging information with
dwarfdump. Here's the important section:
<2><  105>      DW_TAG_subprogram
                DW_AT_sibling               <153>
                DW_AT_external              yes(1)
                DW_AT_name                  funcA
                DW_AT_decl_file             2 /home/thor/test.hpp
                DW_AT_decl_line             4
                DW_AT_MIPS_linkage_name     _ZN9TestClass5funcAEv
                DW_AT_type                  <208>
                DW_AT_declaration           yes(1)
<3><  146>      DW_TAG_formal_parameter
                DW_AT_type                  <215>
                DW_AT_artificial            yes(1)
<2><  153>      DW_TAG_subprogram
                DW_AT_sibling               <178>
                DW_AT_external              yes(1)
                DW_AT_name                  TestClass
                DW_AT_decl_file             2 /home/thor/test.hpp
                DW_AT_decl_line             5
                DW_AT_declaration           yes(1)
<3><  166>      DW_TAG_formal_parameter
                DW_AT_type                  <215>
                DW_AT_artificial            yes(1)
<3><  172>      DW_TAG_formal_parameter
                DW_AT_type                  <208>

As seen from the above, member functions do get the full debugging info,
including the mangled name (linkage name), but the constructor does not. This
gets worse in case more than one constructor is available since gdb is then no
longer able to find the entry point.


-- 
           Summary: dwarf2 debug info lacks linkage names for constructors &
                    destructors
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: thor at math dot tu-berlin dot de
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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

Reply via email to