This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA 2/4] dwarf2_physname
- From: Keith Seitz <keiths at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 01 Feb 2010 13:52:27 -0800
- Subject: Re: [RFA 2/4] dwarf2_physname
- References: <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> <4B672C38.60007@redhat.com> <20100201193941.GA17445@caradoc.them.org>
On 02/01/2010 11:39 AM, Daniel Jacobowitz wrote:
DW_AT_specification is present for many variables in namespaces
(at least in current GCC output). But what significance does it
actually have? Can you explain the check above in terms of the DWARF
standard? If not, I don't think it's right.
I don't know if what gcc is doing is proper DWARF or not, but I don't
see any indication on reading the DWARF3 spec that it is.
If I may use namespace.exp as an example:
namespace
{
namespace G
{
int Xg;
};
};
For this code, gcc will output a type-like information DIE tree, telling
us ONLY about the composition of the anonymous namespace with namespace
G and variable Xg. Later gcc gives us a DIE with DW_AT_location (to
continue my (poor) type analogy: an instance of the variable). To
describe this DIE, we also get DW_AT_specification and nothing more.
Just DW_AT_location and DW_AT_specification.
If we do not follow DW_AT_specification, dwarf2_physname will put the
variable Xg in the global namespace instead of "(anonymous
namespace)::G::Xg", which is where it really is defined.
DW_AT_specification just says that there is a specification of this
variable in another DIE. The same variable could be written with
or without it.
In the case where DW_AT_specification is omitted, the physname
information is contained within the DIE's immediate ancestry. I would
expect to see, e.g.,
DW_TAG_namespace
-- DW_AT_name
-- DW_TAG_namespace
-- DW_AT_name
-- DW_TAG_variable
-- DW_AT_name
-- DW_AT_location
as opposed to (the below is what we actually get from gcc)
DW_TAG_namespace
-- DW_AT_name
-- DW_TAG_namespace
-- DW_AT_name
-- DW_TAG_variable
-- DW_AT_name
...
DW_AT_variable
-- DW_AT_specification (points to DW_TAG_variable above)
-- DW_AT_location
Keith