991115.1 | B | R | J. Merrill | C++ | Template support |
The current dwarf2 spec basically treats template instantiations
like any
other function or class, just adding children to make the template parm
names meaningful in the debugger. But templates also have implications for
the nested structure of dwarf; a new instantiation can be generated at any
time. Under the current spec, it seems that all instantiations of a member
template must be children of the containing class; this can lead to
different translation units having different concepts of a type, since they
might have different groups of instantiations. This is a problem if you
want to share the type DIE between TUs.
It seems to me that it would make more sense for templates to get their own
DIEs, and have instantiations refer to that DIE, as we do with
AT_declaration/AT_specification and AT_inline/AT_abstract_origin already.
Another possibility would be to use nesting, and accept an AT_extension on
a later namespace DIE to indicate that you are reopening the namespace.
This would be smaller than putting a DIE ref attribute on each of the DIEs
in the namespace.
This proposal is incomplete.
On May 14, 2001, Jason Merrill added the following comments:
For future reference, it seems to me that templates/generics
should be
represented (or at least representable) using a mechanism like the
abstract/concrete duality for "inline" functions. Something like:
template <class T> struct A {
T t;
};
A<int> ai;
A<char> ac;
1 DW_TAG_class_template
DW_AT_name "A"
2 DW_TAG_template_type_parameter
DW_AT_name "T"
3 DW_TAG_member
DW_AT_type <2>
DW_AT_name "t"
4 DW_TAG_class_type
DW_AT_template_origin <1>
5 DW_TAG_template_type_parameter
DW_AT_template_origin <2>
DW_AT_type <int>
6 DW_TAG_class_type
DW_AT_template_origin <1>
7 DW_TAG_template_type_parameter
DW_AT_template_origin <2>
DW_AT_type <char>