[RFA/stabs reader] Fix v3 duplicate constructors problem

Daniel Jacobowitz
2001-12-03T20:48:14Z

I tracked down the annoying duplication of constructors using G++ 3.0 with
stabs. The problem is that all the clones of the constructor are emitted,
so there really are two of them.

The obvious thing to do to fix this in GCC (and I'd like it fixed in GCC)
would seem to be checking DECL_ABSTRACT_ORIGIN like the Dwarf frontend does
instead of DECL_ABSTRACT. That works for eliminating the duplicates and
creating the names we need, but the mangled name in debug info is the
"*INTERNAL*" version if we do that. I'd like to emit the name of the
constructor and the mangled name of the complete object constructor,
ideally. C++ people, does that sound right? Or feasible?

Unlike the vtable fixes, though, I can fix this in GDB too. I'm planning to
do both, since GCCs with this issue have been circulating for a long time.

I'm still running tests on this, but it looks pretty good so far. OK to
commit when they're done?

In addition, it nicely gets us:

XPASS: gdb.base/constvars.exp: ptype lecherous
XPASS: gdb.base/constvars.exp: ptype lectern

--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer

2001-12-03 Daniel Jacobowitz <drow@mvista.com>

* stabsread.c (read_member_functions): Skip member functions which
are duplicates of the callable constructor/destructor.

Index: stabsread.c
===================================================================
RCS file: /cvs/src/src/gdb/stabsread.c,v
retrieving revision 1.16
diff -u -p -r1.16 stabsread.c
--- stabsread.c 2001/09/24 17:16:53 1.16
+++ stabsread.c 2001/12/03 20:40:11
@@ -2953,6 +2953,7 @@ read_member_functions (struct field_info
{
int nfn_fields = 0;
int length = 0;
+ int skip_method;
/* Total number of member functions defined in this class. If the class
defines two `f' functions, and one `g' function, then this will have
the value 3. */
@@ -2991,6 +2992,36 @@ read_member_functions (struct field_info
sublist = NULL;
look_ahead_type = NULL;
length = 0;
+
+ skip_method = 0;
+ if (p - *pp == strlen ("__base_ctor")
+ && strncmp (*pp, "__base_ctor", strlen ("__base_ctor")) == 0)
+ skip_method = 1;
+ else if (p - *pp == strlen ("__base_dtor")
+ && strncmp (*pp, "__base_dtor", strlen ("__base_dtor")) == 0)
+ skip_method = 1;
+ else if (p - *pp == strlen ("__deleting_dtor")
+ && strncmp (*pp, "__deleting_dtor",
+ strlen ("__deleting_dtor")) == 0)
+ skip_method = 1;
+
+ if (skip_method)
+ {
+ /* Skip past '::'. */
+ *pp = p + 2;
+ /* Read the type. */
+ read_type (pp, objfile);
+ /* Skip past the colon, mangled name, semicolon, flags, and final
+ semicolon. */
+ while (**pp != ';')
+ (*pp) ++;
+ (*pp) ++;
+ while (**pp != ';')
+ (*pp) ++;
+ (*pp) ++;
+
+ continue;
+ }

new_fnlist = (struct next_fnfieldlist *)
xmalloc (sizeof (struct next_fnfieldlist));