[PATCH] Fix debug info for block local namespace aliases for real (PR debug/37890)

Jakub Jelinek jakub@redhat.com
Fri Mar 20 15:38:00 GMT 2009


Hi!

I've misread the debug info, even after my earlier patch for this PR
we were emitting the block local namespace aliases always in the
compilation unit DIE (or in DW_TAG_namespace DIEs).

The following patch fixes this.  Bootstrapped/regtested on x86_64-linux, ok
for trunk?

2009-03-20  Jakub Jelinek  <jakub@redhat.com>

	PR debug/37890
	* dwarf2out.c (gen_namespace_die): Add context_die argument and use
	it for block local namespace aliases.
	(gen_decl_die): Pass context_die to gen_namespace_die.

--- gcc/dwarf2out.c.jj	2009-03-18 12:55:36.000000000 +0100
+++ gcc/dwarf2out.c	2009-03-20 13:40:39.000000000 +0100
@@ -5176,7 +5176,7 @@ static void gen_tagged_type_instantiatio
 static void gen_block_die (tree, dw_die_ref, int);
 static void decls_for_scope (tree, dw_die_ref, int);
 static int is_redundant_typedef (const_tree);
-static void gen_namespace_die (tree);
+static void gen_namespace_die (tree, dw_die_ref);
 static void gen_decl_die (tree, tree, dw_die_ref);
 static dw_die_ref force_decl_die (tree);
 static dw_die_ref force_type_die (tree);
@@ -15188,18 +15188,19 @@ declare_in_namespace (tree thing, dw_die
 /* Generate a DIE for a namespace or namespace alias.  */
 
 static void
-gen_namespace_die (tree decl)
+gen_namespace_die (tree decl, dw_die_ref context_die)
 {
-  dw_die_ref context_die = setup_namespace_context (decl, comp_unit_die);
+  dw_die_ref namespace_die;
 
   /* Namespace aliases have a DECL_ABSTRACT_ORIGIN of the namespace
      they are an alias of.  */
   if (DECL_ABSTRACT_ORIGIN (decl) == NULL)
     {
       /* Output a real namespace or module.  */
-      dw_die_ref namespace_die
-	= new_die (is_fortran () ? DW_TAG_module : DW_TAG_namespace,
-		   context_die, decl);
+      context_die = setup_namespace_context (decl, comp_unit_die);
+      namespace_die = new_die (is_fortran ()
+			       ? DW_TAG_module : DW_TAG_namespace,
+			       context_die, decl);
       /* For Fortran modules defined in different CU don't add src coords.  */
       if (namespace_die->die_tag == DW_TAG_module && DECL_EXTERNAL (decl))
 	add_name_attribute (namespace_die, dwarf2_name (decl, 0));
@@ -15217,9 +15218,11 @@ gen_namespace_die (tree decl)
       dw_die_ref origin_die
 	= force_decl_die (DECL_ABSTRACT_ORIGIN (decl));
 
+      if (DECL_CONTEXT (decl) == NULL_TREE
+	  || TREE_CODE (DECL_CONTEXT (decl)) == NAMESPACE_DECL)
+	context_die = setup_namespace_context (decl, comp_unit_die);
       /* Now create the namespace alias DIE.  */
-      dw_die_ref namespace_die
-	= new_die (DW_TAG_imported_declaration, context_die, decl);
+      namespace_die = new_die (DW_TAG_imported_declaration, context_die, decl);
       add_name_and_src_coords_attributes (namespace_die, decl);
       add_AT_die_ref (namespace_die, DW_AT_import, origin_die);
       equate_decl_number_to_die (decl, namespace_die);
@@ -15408,7 +15411,7 @@ gen_decl_die (tree decl, tree origin, dw
 
     case NAMESPACE_DECL:
     case IMPORTED_DECL:
-      gen_namespace_die (decl);
+      gen_namespace_die (decl, context_die);
       break;
 
     default:

	Jakub



More information about the Gcc-patches mailing list