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: [rfc] Fix some cases of "using" declarations with older G++ versions


Jan Kratochvil wrote:

> On Thu, 25 Mar 2010 17:27:00 +0100, Ulrich Weigand wrote:
> > @@ -3940,6 +3940,30 @@ read_func_scope (struct die_info *die, s
> >  
> >    inherit_abstract_dies (die, cu);
> >  
> > +  /* If we have a DW_AT_specification, we might need to import using
> > +     directives from the context of the specification DIE.  See the
> > +     comment in determine_prefix.  */
> > +  if (cu->language == language_cplus)
> > +    {
> > +      struct dwarf2_cu *spec_cu = cu;
> > +      struct die_info *spec_die = die_specification (die, &spec_cu);
> 
> This may also fetch DW_AT_abstract_origin which has been already imported by
> inherit_abstract_dies.  But duplicate DW_TAG_imported_module should not hurt.

Hmmm, good point.  I've added a check that we actually have a 
DW_AT_specification here.

> > +	{
> > +	  child_die = spec_die->child;
> > +	  while (child_die && child_die->tag)
> > +	    {
> > +	      if (child_die->tag == DW_TAG_imported_module)
> > +		process_die (child_die, cu);
>                                         spec_cu probably?

Indeed.

Updated patch is below.  Retested on powerpc64-linux.

Thanks,
Ulrich


ChangeLog:

	* dwarf2read.c (read_func_scope): Also scan specification DIEs
	for DW_TAG_imported_module children.


Index: gdb/dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.372
diff -u -p -r1.372 dwarf2read.c
--- gdb/dwarf2read.c	22 Mar 2010 13:21:39 -0000	1.372
+++ gdb/dwarf2read.c	25 Mar 2010 18:47:59 -0000
@@ -3940,6 +3940,31 @@ read_func_scope (struct die_info *die, s
 
   inherit_abstract_dies (die, cu);
 
+  /* If we have a DW_AT_specification, we might need to import using
+     directives from the context of the specification DIE.  See the
+     comment in determine_prefix.  */
+  if (cu->language == language_cplus
+      && dwarf2_attr (die, DW_AT_specification, cu))
+    {
+      struct dwarf2_cu *spec_cu = cu;
+      struct die_info *spec_die = die_specification (die, &spec_cu);
+
+      while (spec_die)
+	{
+	  child_die = spec_die->child;
+	  while (child_die && child_die->tag)
+	    {
+	      if (child_die->tag == DW_TAG_imported_module)
+		process_die (child_die, spec_cu);
+	      child_die = sibling_die (child_die);
+	    }
+
+	  /* In some cases, GCC generates specification DIEs that
+	     themselves contain DW_AT_specification attributes.  */
+	  spec_die = die_specification (spec_die, &spec_cu);
+	}
+    }
+
   new = pop_context ();
   /* Make a block for the local symbols within.  */
   block = finish_block (new->name, &local_symbols, new->old_blocks,


-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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