Re: [RFA 2/4] dwarf2_physname

Daniel Jacobowitz
2010-02-01T22:19:25Z

On Mon, Feb 01, 2010 at 01:52:27PM -0800, Keith Seitz wrote:
> 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.

Right. The issue is not the presence or absence of the
DW_AT_specification; the issue is whether to follow this DIE's
parents, or its specification's parents. The reader handles this in a
couple of other places already. For instance, see the comment in
determine_prefix.

I think this code has evolved a couple of times since the referenced
block was added. Certainly all callers of the old pdi_needs_namespace
are removed; the callers of die_needs_namespace are new. It may
no longer be right.

What're we trying to answer? For instance, is it the distinction
between local variables and global variables? This is interesting
because I believe that function-local classes get the enclosing
function as a prefix, but obviously function-local automatic variables
should not.

Judging from some examples, you can not distinguish function local and
function static variables without decoding DW_AT_location. But that's
not the most important case; we don't need to qualify function local
variables in the symbol table and things will work out OK.

I'm not sure how DW_TAG_member comes into this either, that doesn't
entirely make sense for non-static class members. Be careful about
this one: GCC sometimes incorrectly uses DW_TAG_variable, when the
DWARF standard says they should be DW_TAG_member.

--
Daniel Jacobowitz
CodeSourcery