Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Re: [RFA/stabs reader] Fix v3 duplicate constructors problem
@ 2001-12-04  1:09 Michael Elizabeth Chastain
  2001-12-04  5:27 ` Jason Merrill
  0 siblings, 1 reply; 17+ messages in thread
From: Michael Elizabeth Chastain @ 2001-12-04  1:09 UTC (permalink / raw)
  To: gdb-patches, jason; +Cc: gcc

Jason Merrill writes:
> The thing is, we want the debugger to treat them as the same function, so
> that setting a breakpoint on the signature actually sets one on each and
> the like.

I for one do not want that to happen at all!

There really are two bodies of code in the target program code.
The compiler emits two bodies of code; the linker recognizes two bodies
of code with different names.

Consider this code:

  class C1 { public: C1::C1(); };
  C1::C1 () { foo(); bar(); bletch(); }

Suppose the user sets a breakpoint in foo(), looks at the stack,
and sees the name C1::C1().  They decide they want to read the machine
language instructions for the constructor, so they type "disass C1::C1".
What do you want gdb to do?

I would like gdb to demangle different names differently.  Perhaps:

  (gdb) ptype C1
    ... C1::C1 ...
    ... C1::C1$base ...

... where the first line is for the in-charge constructor, and the second
line is for the not-in-charge constructor.  Then the user can disassemble,
breakpoint, and call whichever function they want (they better know what
they are doing if they call a not-in-charge constructor by hand though).
If they don't know what C1::C1$base is, they can read a document, where
they can learn that each constructor and destructor in the source code is
compiled to multiple object functions in the object code, with different
interfaces and purposes.

As to how this relates onto symbol handling, I don't know.  I just know
that I want names that reflect reality in ptype, disassmble, break,
and backtrace.

Michael C


^ permalink raw reply	[flat|nested] 17+ messages in thread
* [RFA/stabs reader] Fix v3 duplicate constructors problem
@ 2001-12-03 12:48 Daniel Jacobowitz
  2001-12-03 13:22 ` Daniel Berlin
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Daniel Jacobowitz @ 2001-12-03 12:48 UTC (permalink / raw)
  To: gdb-patches, libstdc++

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));


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

end of thread, other threads:[~2001-12-07 23:30 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-04  1:09 [RFA/stabs reader] Fix v3 duplicate constructors problem Michael Elizabeth Chastain
2001-12-04  5:27 ` Jason Merrill
2001-12-04  7:40   ` Daniel Berlin
2001-12-04  8:58   ` Daniel Jacobowitz
  -- strict thread matches above, loose matches on Subject: below --
2001-12-03 12:48 Daniel Jacobowitz
2001-12-03 13:22 ` Daniel Berlin
2001-12-03 13:25   ` Daniel Jacobowitz
2001-12-03 13:28     ` Daniel Berlin
2001-12-03 13:52 ` Jason Merrill
2001-12-03 14:29   ` Daniel Jacobowitz
2001-12-03 14:58     ` Jason Merrill
2001-12-03 15:25       ` Michael Snyder
2001-12-04  8:25         ` Jason Merrill
2001-12-04  8:53           ` Jim Blandy
2001-12-04  9:43             ` Joe Buck
2001-12-07 15:25 ` Jim Blandy
2001-12-07 15:30   ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox