This is the mail archive of the mailing list for the GCC 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]

PATCH: fix PR debug/11325

If we encounter an incomplete definition of a type when marking the
DIEs we want to keep in the debug output, we should also mark
the complete definition if it exists.

Bootstrapped and tested on linux/ia86.

2003-11-14  Scott Snyder  <>

	PR debug/11325
	* dwarf2out.c (struct die_struct): Add die_definition field.
	(add_AT_specification): New.
	(gen_subprogram_die, gen_variable_die,
	gen_struct_or_union_type_die): Use it.
	(prune_unused_types_mark): If we're marking a forward declaration,
	also mark the full definition, if it exists.

Index: dwarf2out.c
RCS file: /cvsroot/gcc/gcc/gcc/dwarf2out.c,v
retrieving revision 1.462
diff -u -p -r1.462 dwarf2out.c
--- dwarf2out.c	10 Nov 2003 23:45:44 -0000	1.462
+++ dwarf2out.c	14 Nov 2003 17:54:48 -0000
@@ -3332,6 +3332,7 @@ typedef struct die_struct GTY(())
   dw_die_ref die_parent;
   dw_die_ref die_child;
   dw_die_ref die_sib;
+  dw_die_ref die_definition; /* ref from a specification to its definition */
   dw_offset die_offset;
   unsigned long die_abbrev;
   int die_mark;
@@ -3599,6 +3600,7 @@ static void add_AT_string (dw_die_ref, e
 static inline const char *AT_string (dw_attr_ref);
 static int AT_string_form (dw_attr_ref);
 static void add_AT_die_ref (dw_die_ref, enum dwarf_attribute, dw_die_ref);
+static void add_AT_specification (dw_die_ref, dw_die_ref);
 static inline dw_die_ref AT_ref (dw_attr_ref);
 static inline int AT_ref_external (dw_attr_ref);
 static inline void set_AT_ref_external (dw_attr_ref, int);
@@ -4664,6 +4666,17 @@ add_AT_die_ref (dw_die_ref die, enum dwa
   add_dwarf_attr (die, attr);

+/* Add an AT_specification attribute to a DIE, and also make the back pointer
+   from the specification to the definition. */
+static inline void
+add_AT_specification (dw_die_ref die, dw_die_ref targ_die)
+  add_AT_die_ref (die, DW_AT_specification, targ_die);
+  if (targ_die->die_definition)
+    abort ();
+  targ_die->die_definition = die;
 static inline dw_die_ref
 AT_ref (dw_attr_ref a)
@@ -10629,7 +10642,7 @@ gen_subprogram_die (tree decl, dw_die_re
 	  subr_die = new_die (DW_TAG_subprogram, context_die, decl);
-	  add_AT_die_ref (subr_die, DW_AT_specification, old_die);
+	  add_AT_specification (subr_die, old_die);
 	  if (get_AT_unsigned (old_die, DW_AT_decl_file) != file_index)
 	    add_AT_unsigned (subr_die, DW_AT_decl_file, file_index);
 	  if (get_AT_unsigned (old_die, DW_AT_decl_line)
@@ -10849,7 +10862,7 @@ gen_variable_die (tree decl, dw_die_ref 
 	   && get_AT_flag (old_die, DW_AT_declaration) == 1)
       /* This is a definition of a C++ class level static.  */
-      add_AT_die_ref (var_die, DW_AT_specification, old_die);
+      add_AT_specification (var_die, old_die);
       if (DECL_NAME (decl))
 	  unsigned file_index = lookup_filename (DECL_SOURCE_FILE (decl));
@@ -11295,7 +11308,7 @@ gen_struct_or_union_type_die (tree type,
 			  scope_die, type);
       equate_type_number_to_die (type, type_die);
       if (old_die)
-	add_AT_die_ref (type_die, DW_AT_specification, old_die);
+	add_AT_specification (type_die, old_die);
 	add_name_attribute (type_die, type_tag (type));
@@ -12504,6 +12517,11 @@ prune_unused_types_mark (dw_die_ref die,
       /* Mark any referenced nodes.  */
       prune_unused_types_walk_attribs (die);
+      /* If this node is a specification,
+         also mark the definition, if it exists. */
+      if (get_AT_flag (die, DW_AT_declaration) && die->die_definition)
+        prune_unused_types_mark (die->die_definition, 1);
   if (dokids && die->die_mark != 2)

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