[Dwarf-Discuss] [PING] [RFC] content of DW_AT_name for template instantiations

Dodji Seketeli dodji at redhat.com
Tue Jun 7 07:12:21 PDT 2011


Hello,

This is a follow-up to an RFC that I first sent on 20 October 2009 to
which nobody replied.

Now that G++ emits DW_AT_template_*_parameter* DIEs and that GDB
consumes that debugging information, it appears that the content of
the DW_AT_name attribute of a template instantiation could use some
clarifications.

Consider this short c++ code snippet:

~=~
template<class T>
struct S {};

S<int> s;
~=~

In quite a number of implementations - including G++ - The DW_TAG_class_type
DIE representing S<int> has a DW_AT_name that is set to the template-id string
"S<int>" today.

But then if the DW_TAG_class_type DIE has a
DW_TAG_template_type_parameter child DIE, setting the DW_AT_name
attribute of that DW_TAG_class_type DIE to the template-id "S<int>"
becomes redundant and slows down debug info consumers.  It would be more
orthogonal and efficient for consumers to just set that attribute to the
template name string "S" as the template parameters part can be
synthesized by the debugger from the DW_TAG_template_type_parameter DIE.

I believe the DWARF specification does not clearly states this.  In the
DWARF 4 version, neither "3.3.7 Function Template Instantiation" nor
"5.5.8 Class Template Instantiation" precisely states what the
DW_AT_name attribute of the template instantiation should contain.

Therefore, I would like to propose the following amendments to the two
sections mentionned above.

In "5.5.8 Class Template Instantiation", the paragraph that currently
reads:

    A class template instantiation is represented by a debugging
    information entry with the tag DW_TAG_class_type,
    DW_TAG_structure_type or DW_TAG_union_type. With five exceptions,
    such an entry will contain the same attributes and have the same
    types of child entries as would an entry for a class type defined
    explicitly using the instantiation types and values. The exceptions
    are:

would be changed into [note how the "five" is changed into "six"]:

    A class template instantiation is represented by a debugging
    information entry with the tag DW_TAG_class_type,
    DW_TAG_structure_type or DW_TAG_union_type. With six exceptions,
    such an entry will contain the same attributes and have the same
    types of child entries as would an entry for a class type defined
    explicitly using the instantiation types and values. The exceptions
    are:

A sixth exception would then be added and it would read:

    The value of the DW_AT_name attribute of the entry representing the
    class template instantiation is a null terminated string that
    contains the simple name of the template, without any template
    argument.

Similarly, in section "3.3.7 Function Template Instantiation", the
paragraph that currently reads:

    A template instantiation is represented by a debugging information
    entry with the tag DW_TAG_subprogram. With four exceptions, such an
    entry will contain the same attributes and will have the same types
    of child entries as would an entry for a subroutine defined
    explicitly using the instantiation types. The exceptions are:

would be changed into [note how the "four" is changed in to "five"]:

    A template instantiation is represented by a debugging information
    entry with the tag DW_TAG_subprogram. With five exceptions, such an
    entry will contain the same attributes and will have the same types
    of child entries as would an entry for a subroutine defined
    explicitly using the instantiation types. The exceptions are:

A fifth exception would then be added and it would read:

    The value of the DW_AT_name attribute of the entry representing the
    function template instantiation is a null terminated string that
    contains the simple name of the template, without any template
    argument.

Thoughts?

-- 
		Dodji



More information about the Dwarf-Discuss mailing list