[RFA 2/4] dwarf2_physname
Tom Tromey
tromey@redhat.com
Thu Feb 4 17:21:00 GMT 2010
>>>>> "Daniel" == Daniel Jacobowitz <dan@codesourcery.com> writes:
>> +die_needs_namespace (struct die_info *die, struct dwarf2_cu *cu)
>> {
[...]
>> + case DW_TAG_variable:
>> + {
>> + struct attribute *attr;
>> + attr = dwarf2_attr (die, DW_AT_specification, cu);
>> + if (attr)
>> + return 1;
>> + attr = dwarf2_attr (die, DW_AT_external, cu);
>> + if (attr == NULL && die->parent->tag != DW_TAG_namespace)
>> + return 0;
>> + return 1;
Daniel> What's this about? It needs an explanation, and I don't think
Daniel> DW_AT_specification has anything to do with die_needs_namespace.
I read through this sub-thread a little, and looked at the DWARF spec
too.
Here is what I believe to be the relevant text from the spec:
If a type, variable, or function declared in a namespace is defined
outside of the body of the namespace declaration, that type, variable,
or function definition entry has a DW_AT_specification attribute whose
value is a reference to the debugging information entry representing the
declaration of the type, variable or function. Type, variable, or
function entries with a DW_AT_specification attribute do not need to
duplicate information provided by the declaration entry referenced by
the specification attribute.
So, if a DIE has a DW_AT_specification, then we must use the namespace
indicated by the referenced DIE. If it does not have DW_AT_specification,
then we use its own parentage.
It is not clear to me whether it is possible for a DIE to have a
DW_AT_specification referring to another DIE which is not in a
namespace. Offhand this seems invalid, but if it does occur, it could
be supported in this function with just a little more effort.
I don't understand why die_needs_namespace only does this for
DW_TAG_variable and not other things. I also don't understand why it
unconditionally returns 1 for enumerators, functions, and the like.
However, I didn't look to see how it is used, so perhaps it doesn't
matter.
After reading more of the thread, maybe I am missing the point.
Tom
More information about the Gdb-patches
mailing list