This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA 2/4] dwarf2_physname
- From: Tom Tromey <tromey at redhat dot com>
- To: Keith Seitz <keiths at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 04 Feb 2010 10:21:44 -0700
- Subject: Re: [RFA 2/4] dwarf2_physname
- References: <m38wd1gxp6.fsf@fleche.redhat.com> <20091217202843.GA11961@caradoc.them.org> <m3eimm7t7g.fsf@fleche.redhat.com> <20091222192444.GB15339@caradoc.them.org> <4B576983.2090808@redhat.com> <20100126211733.GA17877@caradoc.them.org> <4B609019.1090807@redhat.com> <4B61F20B.7070908@redhat.com> <20100128202429.GA29835@caradoc.them.org> <4B622047.7020503@redhat.com> <20100201164837.GF21339@caradoc.them.org>
- Reply-to: tromey at redhat dot com
>>>>> "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