[Dwarf-discuss] class members and DW_AT_specification

Michael Eager eager@eagercon.com
Tue Feb 27 18:21:04 GMT 2007


Chris Quenelle wrote:
> g++ seems to generate two dies for each member function.
> A declaration die inside the class scope, and a definition
> die at the compilation-unit scope.  The definition is hooked
> to the declaration with a DW_AT_specification, which seems fine.
> 
> Is there some reading of the dwarf standard that might make this
> the required or recommended way of doing things?  Or was this
> done for some kind of implementation-specific reason in
> either g++ or gdb?
> 
> Anyone have any ideas?

Where is the member function defined?  Within the class
definition, or outside of the class definition?

If the member function is declared within the class definition
but defined at compilation scope, then there should be two DIEs,
one for each, as you describe.

If the member function is defined within the class definition,
then there should be only a single declaration DIE within the
class definition (or both definition and declaration DIEs should
appear within the class definition).  Moving the declaration to
compilation scope may be intended to help gdb resolve a reference
to the member function, but it describes a different source file.

-- 
Michael Eager	 eager at eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077




More information about the Dwarf-discuss mailing list