public inbox for gcc@gcc.gnu.org
 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; 11+ 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] 11+ messages in thread

* Re: [RFA/stabs reader] Fix v3 duplicate constructors problem
  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
  0 siblings, 2 replies; 11+ messages in thread
From: Jason Merrill @ 2001-12-04  5:27 UTC (permalink / raw)
  To: Michael Elizabeth Chastain; +Cc: gdb-patches, gcc

>>>>> "Michael" == Michael Elizabeth Chastain <mec@shout.net> writes:

> I would like gdb to demangle different names differently.

Which brings me to a question: Why don't we demangle them differently?
Currently, flag_verbose in cp-demangle.c defaults to 0, so the two
functions are demangled identically.  I think this is wrong, and have
changed flag_verbose to 1 for my own use.  What do other people think?

Jason

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

* Re: [RFA/stabs reader] Fix v3 duplicate constructors problem
  2001-12-04  5:27 ` Jason Merrill
@ 2001-12-04  7:40   ` Daniel Berlin
  2001-12-04  8:58   ` Daniel Jacobowitz
  1 sibling, 0 replies; 11+ messages in thread
From: Daniel Berlin @ 2001-12-04  7:40 UTC (permalink / raw)
  To: Jason Merrill; +Cc: Michael Elizabeth Chastain, gdb-patches, gcc



On Tue, 4 Dec 2001, Jason Merrill wrote:

> >>>>> "Michael" == Michael Elizabeth Chastain <mec@shout.net> writes:
>
> > I would like gdb to demangle different names differently.
>
> Which brings me to a question: Why don't we demangle them differently?
> Currently, flag_verbose in cp-demangle.c defaults to 0, so the two
> functions are demangled identically.  I think this is wrong, and have
> changed flag_verbose to 1 for my own use.  What do other people think?

IIRC, the reason was that ptype output should be directly usable in the
target language.
We had a large discussion about this sometime in the past year, i can't
quite remember the outcome.
I had a patch to gdb/libiberty that passed DMGL_VERBOSE along (and added
DMGL_VERBOSE to the flags) for this purpose.

>
> Jason
>

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

* Re: [RFA/stabs reader] Fix v3 duplicate constructors problem
  2001-12-04  5:27 ` Jason Merrill
  2001-12-04  7:40   ` Daniel Berlin
@ 2001-12-04  8:58   ` Daniel Jacobowitz
  1 sibling, 0 replies; 11+ messages in thread
From: Daniel Jacobowitz @ 2001-12-04  8:58 UTC (permalink / raw)
  To: Jason Merrill; +Cc: Michael Elizabeth Chastain, gdb-patches, gcc

On Tue, Dec 04, 2001 at 01:26:47PM +0000, Jason Merrill wrote:
> >>>>> "Michael" == Michael Elizabeth Chastain <mec@shout.net> writes:
> 
> > I would like gdb to demangle different names differently.
> 
> Which brings me to a question: Why don't we demangle them differently?
> Currently, flag_verbose in cp-demangle.c defaults to 0, so the two
> functions are demangled identically.  I think this is wrong, and have
> changed flag_verbose to 1 for my own use.  What do other people think?

Strongly agree.  I was boggled to find two names for obviously
different constructors that were demangled to the same thing; after
figuring out what all the different variants were, of course, it made
sense - but it violates least surprise quite badly.

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

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

* Re: [RFA/stabs reader] Fix v3 duplicate constructors problem
  2001-12-04  8:53           ` Jim Blandy
@ 2001-12-04  9:43             ` Joe Buck
  0 siblings, 0 replies; 11+ messages in thread
From: Joe Buck @ 2001-12-04  9:43 UTC (permalink / raw)
  To: Jim Blandy; +Cc: Jason Merrill, Michael Snyder, gdb-patches, gcc

> 
> 
> Jason Merrill <jason@redhat.com> writes:
> > Constructors and destructors have traditionally had a special calling
> > convention.  Though I suppose that as of v3, we've gone to clones rather
> > than extra hidden parameters, so it would be more feasible to allow users
> > to call them directly from the debugger.  In any case, it needs some sort
> > of special handling.
> 
> Wouldn't it be reasonable for GDB to support `new' expressions?

Yes, if the gdb user can call placement new, s/he can call a constructor
and place an object whereever desired.  Something like

(gdb) call new(ptr) SomeClass(1, "Hello")


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

* Re: [RFA/stabs reader] Fix v3 duplicate constructors problem
  2001-12-04  8:25         ` Jason Merrill
@ 2001-12-04  8:53           ` Jim Blandy
  2001-12-04  9:43             ` Joe Buck
  0 siblings, 1 reply; 11+ messages in thread
From: Jim Blandy @ 2001-12-04  8:53 UTC (permalink / raw)
  To: Jason Merrill; +Cc: Michael Snyder, gdb-patches, gcc


Jason Merrill <jason@redhat.com> writes:
> Constructors and destructors have traditionally had a special calling
> convention.  Though I suppose that as of v3, we've gone to clones rather
> than extra hidden parameters, so it would be more feasible to allow users
> to call them directly from the debugger.  In any case, it needs some sort
> of special handling.

Wouldn't it be reasonable for GDB to support `new' expressions?

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

* Re: [RFA/stabs reader] Fix v3 duplicate constructors problem
  2001-12-03 15:25       ` Michael Snyder
@ 2001-12-04  8:25         ` Jason Merrill
  2001-12-04  8:53           ` Jim Blandy
  0 siblings, 1 reply; 11+ messages in thread
From: Jason Merrill @ 2001-12-04  8:25 UTC (permalink / raw)
  To: Michael Snyder; +Cc: gdb-patches, gcc

>>>>> "Michael" == Michael Snyder <msnyder@cygnus.com> writes:

> Jason Merrill wrote:

>> You can't call a constructor directly in C++; no reason to allow it from
>> GDB. 

> OTOH, there are a lot of things that you can do from GDB
> that you cannot do programmatically.  Accessing private data
> would be an example.  Since GDB can call any other function, 
> is there a strong reason why it should not be able to call
> the constructors?  

Constructors and destructors have traditionally had a special calling
convention.  Though I suppose that as of v3, we've gone to clones rather
than extra hidden parameters, so it would be more feasible to allow users
to call them directly from the debugger.  In any case, it needs some sort
of special handling.

Jason

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

* Re: [RFA/stabs reader] Fix v3 duplicate constructors problem
  2001-12-03 14:58     ` Jason Merrill
@ 2001-12-03 15:25       ` Michael Snyder
  2001-12-04  8:25         ` Jason Merrill
  0 siblings, 1 reply; 11+ messages in thread
From: Michael Snyder @ 2001-12-03 15:25 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gdb-patches, gcc

Jason Merrill wrote:
> 
> >>>>> "Daniel" == Daniel Jacobowitz <drow@mvista.com> writes:
> 
> >> What does GDB actually use the member function information for?  What
> >> impact would this change have, other than the output of ptype?
> 
> > Right now, the big thing is probably member function calls.  If the
> > constructor is called from GDB, we want to get the complete object
> > constructor.  I'm not 100% sure this is even possible, though.
> 
> You can't call a constructor directly in C++; no reason to allow it from
> GDB. 

OTOH, there are a lot of things that you can do from GDB
that you cannot do programmatically.  Accessing private data
would be an example.  Since GDB can call any other function, 
is there a strong reason why it should not be able to call
the constructors?  

If constructors are a special case type of function which 
GDB cannot call, we ought to document that fact.

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

* Re: [RFA/stabs reader] Fix v3 duplicate constructors problem
  2001-12-03 14:29   ` Daniel Jacobowitz
@ 2001-12-03 14:58     ` Jason Merrill
  2001-12-03 15:25       ` Michael Snyder
  0 siblings, 1 reply; 11+ messages in thread
From: Jason Merrill @ 2001-12-03 14:58 UTC (permalink / raw)
  To: gdb-patches; +Cc: gcc

>>>>> "Daniel" == Daniel Jacobowitz <drow@mvista.com> writes:

>> What does GDB actually use the member function information for?  What
>> impact would this change have, other than the output of ptype?

> Right now, the big thing is probably member function calls.  If the
> constructor is called from GDB, we want to get the complete object
> constructor.  I'm not 100% sure this is even possible, though.

You can't call a constructor directly in C++; no reason to allow it from
GDB.  Destructors are a different matter, though; an explicit call should
go to the non-deleting, in-charge version.

> I hadn't considered setting breakpoints on all of them.  That's very
> difficult; suppose I look at an assembly listing for a constructor and
> tell it to break on a particular line.  How can I figure out source
> line information for every constructor?

With Dwarf, all clones/inlines point to the abstract version; the internal
representation could keep track of all instances of a particular abstract
function.

> Perhaps it is best to continue emitting them and ignore them until we
> support them in GDB.

Seems reasonable.

Jason

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

* Re: [RFA/stabs reader] Fix v3 duplicate constructors problem
  2001-12-03 13:52 ` Jason Merrill
@ 2001-12-03 14:29   ` Daniel Jacobowitz
  2001-12-03 14:58     ` Jason Merrill
  0 siblings, 1 reply; 11+ messages in thread
From: Daniel Jacobowitz @ 2001-12-03 14:29 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gdb-patches, gcc

On Mon, Dec 03, 2001 at 09:49:39PM +0000, Jason Merrill wrote:
> >>>>> "Daniel" == Daniel Jacobowitz <drow@mvista.com> writes:
> 
> [redirected to gcc list, rather than 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.
> 
> Yep.
> 
> > 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?
> 
> It's certainly feasible; when we see the abstract version, look ahead for a
> clone and use its mangled name.
> 
> 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 suppose that ideal will not be affected by your change, both
> because (I assume) it doesn't work now and because we use the demangled
> names for most purposes anyway.
> 
> What does GDB actually use the member function information for?  What
> impact would this change have, other than the output of ptype?

Right now, the big thing is probably member function calls.  If the
constructor is called from GDB, we want to get the complete object
constructor.  I'm not 100% sure this is even possible, though.

I hadn't considered setting breakpoints on all of them.  That's very
difficult; suppose I look at an assembly listing for a constructor and
tell it to break on a particular line.  How can I figure out source
line information for every constructor?  I've no idea what happens in
this case.

Perhaps it is best to continue emitting them and ignore them until we
support them in GDB.

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

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

* Re: [RFA/stabs reader] Fix v3 duplicate constructors problem
       [not found] <20011203154836.A28821@nevyn.them.org>
@ 2001-12-03 13:52 ` Jason Merrill
  2001-12-03 14:29   ` Daniel Jacobowitz
  0 siblings, 1 reply; 11+ messages in thread
From: Jason Merrill @ 2001-12-03 13:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: gcc, Jason Merrill

>>>>> "Daniel" == Daniel Jacobowitz <drow@mvista.com> writes:

[redirected to gcc list, rather than 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.

Yep.

> 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?

It's certainly feasible; when we see the abstract version, look ahead for a
clone and use its mangled name.

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 suppose that ideal will not be affected by your change, both
because (I assume) it doesn't work now and because we use the demangled
names for most purposes anyway.

What does GDB actually use the member function information for?  What
impact would this change have, other than the output of ptype?

Jason

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

end of thread, other threads:[~2001-12-04 17:43 UTC | newest]

Thread overview: 11+ 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
     [not found] <20011203154836.A28821@nevyn.them.org>
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

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