Re: [RFA 2/4] dwarf2_physname

Daniel Jacobowitz
2010-02-05T20:57:12Z

On Fri, Feb 05, 2010 at 12:23:48PM -0800, Keith Seitz wrote:
> It might be a gcc-ism, but we actually get a DW_TAG_lexical_block
> between DW_TAG_subprogram and DW_TAG_variable. I presume this is to
> mark the prologue. It is a very nice way to know that a variable is
> not global. O:-)

It's a GCC-ism :-)

> After revisiting that, I think it clearer to understand if I invert
> the original test:
>
> case DW_TAG_variable:
> {
> struct attribute *attr;
>
> /* We only need to prefix "globally" visible variables. These include
> any variable marked with DW_AT_external or any variable that
> lives in a namespace. [Variables in anonymous namespaces
> require prefixing, but they are not DW_AT_external.] */
>
> if (dwarf2_attr (die, DW_AT_specification, cu))
> {
> struct dwarf2_cu *spec_cu = cu;
> return die_needs_namespace (die_specification (die, &spec_cu),
> spec_cu);
> }

On this part we are in complete agreement.

> attr = dwarf2_attr (die, DW_AT_external, cu);
> if (attr || die->parent->tag == DW_TAG_namespace)
> return 1;
>
> return 0;
> }
>
> How does that look?

I'm not sure, but I think it's close enough for now.

(Things I'm wondering about that we can sort out later: namespace X {
int f() { extern int y; } }, does y go in a namespace? What
namespace? It certainly doesn't go in X::f()::y but I don't know what
GCC emits. namespace X { class Y { static int x; } }, is that
DW_AT_extern?)

--
Daniel Jacobowitz
CodeSourcery