This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA 2/4] dwarf2_physname


On 02/05/2010 09:24 AM, Daniel Jacobowitz wrote:
Recursing to follow the specification makes sense.  I don't think
recursing onto the parent makes sense though.  Won't this cause
the wrong answer for:

DW_TAG_subprogram
   DW_TAG_variable

?  If that doesn't matter, then I'm totally confused again :-)
That's your basic local variable.

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:-)


I can certainly understand why this is not such a desirable solution.

But at least I now remember (or rather -- I am now reminded) why I originally wrote what I did for this (with DW_AT_external and checking the parent DIE's tag).

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);
	  }

	attr = dwarf2_attr (die, DW_AT_external, cu);
	if (attr || die->parent->tag == DW_TAG_namespace)
	  return 1;

	return 0;
      }

How does that look?

Keith


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]