public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/37237]  New: Debug information for virtual destructors omits DW_AT_vtable_elem_location
@ 2008-08-25 19:54 drow at gcc dot gnu dot org
  2010-02-11 18:44 ` [Bug debug/37237] " dodji at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: drow at gcc dot gnu dot org @ 2008-08-25 19:54 UTC (permalink / raw)
  To: gcc-bugs

Compile a C++ file containing a class with a virtual destructor.  Example from
gdb's class2.cc test:

struct A
{
  virtual ~A ();
  int a1;
};

A::~A()
{
  a1 = 800;
}

>From the DWARF:

 <2><270>: Abbrev Number: 10 (DW_TAG_subprogram)
  <271>     DW_AT_external    : 1
  <272>     DW_AT_name        : ~A
  <275>     DW_AT_decl_file   : 1
  <276>     DW_AT_decl_line   : 25
  <277>     DW_AT_virtuality  : 1       (virtual)
  <278>     DW_AT_containing_type: <221>
  <27c>     DW_AT_declaration : 1

There's a DIE for the member function definition which refers to this
(DW_AT_specification), too.  But neither of them has
DW_AT_vtable_elem_location; this is not optional for virtual methods.

I assume this is related to the fact that the destructor is cloned (whole
object and partial object).  That's why it doesn't get a
DW_AT_MIPS_linkage_name.  I believe there are two vtable slots for the two
clones; the most practical thing would be to describe the whole-object version
in the DWARF since that's what a debugger will be looking up.

I can't think of a better way to handle this; maybe someone else can.


-- 
           Summary: Debug information for virtual destructors omits
                    DW_AT_vtable_elem_location
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: drow at gcc dot gnu dot org


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


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

* [Bug debug/37237] Debug information for virtual destructors omits DW_AT_vtable_elem_location
  2008-08-25 19:54 [Bug debug/37237] New: Debug information for virtual destructors omits DW_AT_vtable_elem_location drow at gcc dot gnu dot org
@ 2010-02-11 18:44 ` dodji at gcc dot gnu dot org
  2010-02-12 15:48 ` dodji at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dodji at gcc dot gnu dot org @ 2010-02-11 18:44 UTC (permalink / raw)
  To: gcc-bugs



-- 

dodji at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |dodji at gcc dot gnu dot org
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-02-11 18:44:13
               date|                            |


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


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

* [Bug debug/37237] Debug information for virtual destructors omits DW_AT_vtable_elem_location
  2008-08-25 19:54 [Bug debug/37237] New: Debug information for virtual destructors omits DW_AT_vtable_elem_location drow at gcc dot gnu dot org
  2010-02-11 18:44 ` [Bug debug/37237] " dodji at gcc dot gnu dot org
@ 2010-02-12 15:48 ` dodji at gcc dot gnu dot org
  2010-02-12 15:52 ` drow at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dodji at gcc dot gnu dot org @ 2010-02-12 15:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from dodji at gcc dot gnu dot org  2010-02-12 15:48 -------
There are actually up to three destructors:

- an in-charge one (or complete-object one)
- a not-in-charge one
- a deleting in-charge one

The three of them are useful in different ways and in different circumstances. 

The destructor being represented in the DWARF output right now is the
"abstract" one, i.e. the one that got cloned (at most) 3 times into the 3
different types of destructors. It doesn't have any DW_AT_vtable_elem_location
precisely because that abstract version of destructor is not present in the
vtable. The destructors present in vtable are the clones. We do not output
those in the debug info today.

Daniel, why would you prefer having the DW_AT_vtable_elem_location only for the
in-charge one?

We could chose to have all three of them being represented in the DWARF output
but then there should be a way to say that they are different concrete
instances of the abstract ~A destructor. Maybe by using the extension
DW_AT_MIPS_clone_origin to make it point to the abstract constructor/destructor
instance which a particular constructor/destructor clone implements?


-- 

dodji at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dodji at gcc dot gnu dot org
         AssignedTo|dodji at gcc dot gnu dot org|unassigned at gcc dot gnu
                   |                            |dot org
             Status|ASSIGNED                    |NEW


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


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

* [Bug debug/37237] Debug information for virtual destructors omits DW_AT_vtable_elem_location
  2008-08-25 19:54 [Bug debug/37237] New: Debug information for virtual destructors omits DW_AT_vtable_elem_location drow at gcc dot gnu dot org
  2010-02-11 18:44 ` [Bug debug/37237] " dodji at gcc dot gnu dot org
  2010-02-12 15:48 ` dodji at gcc dot gnu dot org
@ 2010-02-12 15:52 ` drow at gcc dot gnu dot org
  2010-02-21 16:47 ` dodji at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: drow at gcc dot gnu dot org @ 2010-02-12 15:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from drow at gcc dot gnu dot org  2010-02-12 15:52 -------
The type of the class only contains one destructor.  If you have to pick one
for a debugger to call, in-charge makes the most sense.  For other debugger
purposes they all make equal sense (or nonsense).

If you want to represent all three in the debug info, then not only do we need
to know that they are clones of the same function, we also need to know which
one is the in-charge versus not-in-charge versus deleting destructor to call
the right one for debugger implementation of the delete statement.

I'm pretty sure that would require new debug info extensions and new debugger
support.


-- 


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


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

* [Bug debug/37237] Debug information for virtual destructors omits DW_AT_vtable_elem_location
  2008-08-25 19:54 [Bug debug/37237] New: Debug information for virtual destructors omits DW_AT_vtable_elem_location drow at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2010-02-12 15:52 ` drow at gcc dot gnu dot org
@ 2010-02-21 16:47 ` dodji at gcc dot gnu dot org
  2010-02-23 16:56 ` tromey at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dodji at gcc dot gnu dot org @ 2010-02-21 16:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from dodji at gcc dot gnu dot org  2010-02-21 16:47 -------
Okay Daniel, your POV makes sense to me. Thank you.
I am preparing a patch.


-- 

dodji at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |dodji at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2010-02-11 18:44:13         |2010-02-21 16:47:24
               date|                            |


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


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

* [Bug debug/37237] Debug information for virtual destructors omits DW_AT_vtable_elem_location
  2008-08-25 19:54 [Bug debug/37237] New: Debug information for virtual destructors omits DW_AT_vtable_elem_location drow at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2010-02-21 16:47 ` dodji at gcc dot gnu dot org
@ 2010-02-23 16:56 ` tromey at gcc dot gnu dot org
  2010-02-26 12:59 ` dodji at gcc dot gnu dot org
  2010-02-26 20:48 ` jason at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: tromey at gcc dot gnu dot org @ 2010-02-23 16:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from tromey at gcc dot gnu dot org  2010-02-23 16:55 -------
It seems to me that, by analogy with constructors, we would want debuginfo
for all the destructors, so that "break X::~X" would put breakpoints in all
the clones.
Then we would need additional information to distinguish the destructors
so that we can implement "delete x".


-- 


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


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

* [Bug debug/37237] Debug information for virtual destructors omits DW_AT_vtable_elem_location
  2008-08-25 19:54 [Bug debug/37237] New: Debug information for virtual destructors omits DW_AT_vtable_elem_location drow at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2010-02-23 16:56 ` tromey at gcc dot gnu dot org
@ 2010-02-26 12:59 ` dodji at gcc dot gnu dot org
  2010-02-26 20:48 ` jason at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: dodji at gcc dot gnu dot org @ 2010-02-26 12:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from dodji at gcc dot gnu dot org  2010-02-26 12:58 -------
Created an attachment (id=19968)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19968&action=view)
Candidate patch

Here is what I think is happening, at least on gcc 4.5.

A/ The deleting dtor's DIE *is* being generated
  but:
  1/ not as a member of struct A's DIE
  2/ no DW_AT_vtable_elem_location was being generated for it.

  But there is (and I believe, rightfully so) a DW_AT_abstract_origin 
  attribute pointing back to the abstract dtor that is part of the 
  struct A's DIE members.

B/ The complete destructor was not being generated.

   That was because the complete dtor is not only a clone of the  
   abstract destructor, but also an *alias* (i.e it shares the same 
   body) of the base dtor (the not-in charge one).

   Note that the base dtor is not part of the vtable, but the complete 
   dtor is.

   So the complete dtor is an alias. But for a reason, cgraph 
   forgets to emit debug info for aliases. It emits debug info only for 
   the *target* of an alias.

Independently of this, and after chatting with Tom Tromey and Jason   
Merrill, it looks like we ought to generate debug info for all variants 
of destructors, even if only the abstract dtor is part of the members 
DIEs of the struct.

The most natural way of doing this would be to stay compatible with 
what's done already and fix issues A.1/ and B/ described above.

The debugger would be able to tell that a given function is a destructor 
variant if it has a DW_AT_abstract_origin pointing back to the abstract 
destructor of the type.

Now a problem remains which is how to let the debugger know that a 
given destructor is either a base, complete or deleting one. It looks 
like a new attribute (GNU extension) would address that issue.

The attached patch fixes A.1/ and B/ but doesn't add the new attribute 
yet. I wanted to have your input before.

I am cc-ing Jason too, as I notice he is not in the CC list.


-- 


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


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

* [Bug debug/37237] Debug information for virtual destructors omits DW_AT_vtable_elem_location
  2008-08-25 19:54 [Bug debug/37237] New: Debug information for virtual destructors omits DW_AT_vtable_elem_location drow at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2010-02-26 12:59 ` dodji at gcc dot gnu dot org
@ 2010-02-26 20:48 ` jason at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-02-26 20:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jason at gcc dot gnu dot org  2010-02-26 20:47 -------
The patch looks good.  I don't think we want to add an extension for this; if
we need an additional feature, it should be standardized.


-- 


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


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

end of thread, other threads:[~2010-02-26 20:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-25 19:54 [Bug debug/37237] New: Debug information for virtual destructors omits DW_AT_vtable_elem_location drow at gcc dot gnu dot org
2010-02-11 18:44 ` [Bug debug/37237] " dodji at gcc dot gnu dot org
2010-02-12 15:48 ` dodji at gcc dot gnu dot org
2010-02-12 15:52 ` drow at gcc dot gnu dot org
2010-02-21 16:47 ` dodji at gcc dot gnu dot org
2010-02-23 16:56 ` tromey at gcc dot gnu dot org
2010-02-26 12:59 ` dodji at gcc dot gnu dot org
2010-02-26 20:48 ` jason at gcc dot gnu dot org

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