Blame SOURCES/gcc34-dwarf2-inline-details.patch

6fdc0f
2005-07-25  James E Wilson  <wilson@specifixinc.com>
6fdc0f
6fdc0f
	* dwarf2out.c (add_call_src_coords_attributes): New.
6fdc0f
	(gen_inlined_subroutine_die): Call it.
6fdc0f
	(maybe_emit_file, init_file_table): Add comments.
6fdc0f
	(prune_unused_types_walk_attribs): Pass DW_AT_call_file through
6fdc0f
	maybe_emit_file.
6fdc0f
	* tree-inline.c (remap_block): Copy BLOCK_SOURCE_LOCATION.
6fdc0f
	(expand_call_inline): Set BLOCK_SOURCE_LOCATION.
6fdc0f
	* tree.h (BLOCK_SOURCE_LOCATION): New.
6fdc0f
	(struct tree_block): New field locus.
6fdc0f
6fdc0f
--- gcc/dwarf2out.c.orig	2005-11-17 23:37:43.000000000 -0200
6fdc0f
+++ gcc/dwarf2out.c	2005-11-17 23:38:25.000000000 -0200
6fdc0f
@@ -11509,6 +11509,20 @@
6fdc0f
     }
6fdc0f
 }
6fdc0f
 
6fdc0f
+/* A helper function for gen_inlined_subroutine_die.  Add source coordinate
6fdc0f
+   attributes to the DIE for a block STMT, to describe where the inlined
6fdc0f
+   function was called from.  This is similar to add_src_coords_attributes.  */
6fdc0f
+
6fdc0f
+static inline void
6fdc0f
+add_call_src_coords_attributes (tree stmt, dw_die_ref die)
6fdc0f
+{
6fdc0f
+  unsigned file_index = BLOCK_SOURCE_LOCATION (stmt).file
6fdc0f
+    ? lookup_filename (BLOCK_SOURCE_LOCATION (stmt).file) : 0;
6fdc0f
+
6fdc0f
+  add_AT_unsigned (die, DW_AT_call_file, file_index);
6fdc0f
+  add_AT_unsigned (die, DW_AT_call_line, BLOCK_SOURCE_LOCATION (stmt).line);
6fdc0f
+}
6fdc0f
+
6fdc0f
 /* A helper function for gen_lexical_block_die and gen_inlined_subroutine_die.
6fdc0f
    Add low_pc and high_pc attributes to the DIE for a block STMT.  */
6fdc0f
 
6fdc0f
@@ -11576,6 +11590,7 @@
6fdc0f
 
6fdc0f
       add_abstract_origin_attribute (subr_die, decl);
6fdc0f
       add_high_low_attributes (stmt, subr_die);
6fdc0f
+      add_call_src_coords_attributes (stmt, subr_die);
6fdc0f
 
6fdc0f
       decls_for_scope (stmt, subr_die, depth);
6fdc0f
       current_function_has_inlines = 1;
6fdc0f
@@ -12824,6 +12839,12 @@
6fdc0f
   return i;
6fdc0f
 }
6fdc0f
 
6fdc0f
+/* If the assembler will construct the file table, then translate the compiler
6fdc0f
+   internal file table number into the assembler file table number, and emit
6fdc0f
+   a .file directive if we haven't already emitted one yet.  The file table
6fdc0f
+   numbers are different because we prune debug info for unused variables and
6fdc0f
+   types, which may include filenames.  */
6fdc0f
+
6fdc0f
 static int
6fdc0f
 maybe_emit_file (int fileno)
6fdc0f
 {
6fdc0f
@@ -12844,6 +12865,8 @@
6fdc0f
     return fileno;
6fdc0f
 }
6fdc0f
 
6fdc0f
+/* Initialize the compiler internal file table.  */
6fdc0f
+
6fdc0f
 static void
6fdc0f
 init_file_table (void)
6fdc0f
 {
6fdc0f
@@ -13207,7 +13230,7 @@
6fdc0f
 	     Make sure that it will get emitted.  */
6fdc0f
 	  prune_unused_types_mark (a->dw_attr_val.v.val_die_ref.die, 1);
6fdc0f
 	}
6fdc0f
-      else if (a->dw_attr == DW_AT_decl_file)
6fdc0f
+      else if (a->dw_attr == DW_AT_decl_file || a->dw_attr == DW_AT_call_file)
6fdc0f
 	{
6fdc0f
 	  /* A reference to a file.  Make sure the file name is emitted.  */
6fdc0f
 	  a->dw_attr_val.v.val_unsigned =
6fdc0f
--- gcc/tree-inline.c.orig	2005-11-17 23:37:02.000000000 -0200
6fdc0f
+++ gcc/tree-inline.c	2005-11-17 23:37:46.000000000 -0200
6fdc0f
@@ -346,6 +346,7 @@
6fdc0f
       new_block = make_node (BLOCK);
6fdc0f
       TREE_USED (new_block) = TREE_USED (old_block);
6fdc0f
       BLOCK_ABSTRACT_ORIGIN (new_block) = old_block;
6fdc0f
+      BLOCK_SOURCE_LOCATION (new_block) = BLOCK_SOURCE_LOCATION (old_block);
6fdc0f
       SCOPE_STMT_BLOCK (scope_stmt) = new_block;
6fdc0f
 
6fdc0f
       /* Remap its variables.  */
6fdc0f
@@ -420,6 +421,7 @@
6fdc0f
   new_block = make_node (BLOCK);
6fdc0f
   TREE_USED (new_block) = TREE_USED (old_block);
6fdc0f
   BLOCK_ABSTRACT_ORIGIN (new_block) = old_block;
6fdc0f
+  BLOCK_SOURCE_LOCATION (new_block) = BLOCK_SOURCE_LOCATION (old_block);
6fdc0f
   BLOCK_SUBBLOCKS (new_block) = BLOCK_SUBBLOCKS (old_block);
6fdc0f
   TREE_SIDE_EFFECTS (new_block) = TREE_SIDE_EFFECTS (old_block);
6fdc0f
   TREE_TYPE (new_block) = TREE_TYPE (old_block);
6fdc0f
--- gcc/tree.h.orig	2005-11-17 23:37:02.000000000 -0200
6fdc0f
+++ gcc/tree.h	2005-11-17 23:37:46.000000000 -0200
6fdc0f
@@ -903,6 +903,12 @@
6fdc0f
 #define BLOCK_FRAGMENT_ORIGIN(NODE) (BLOCK_CHECK (NODE)->block.fragment_origin)
6fdc0f
 #define BLOCK_FRAGMENT_CHAIN(NODE) (BLOCK_CHECK (NODE)->block.fragment_chain)
6fdc0f
 
6fdc0f
+/* For an inlined function, this gives the location where it was called
6fdc0f
+   from.  This is only set in the top level block, which corresponds to the
6fdc0f
+   inlined function scope.  This is used in the debug output routines.  */
6fdc0f
+
6fdc0f
+#define BLOCK_SOURCE_LOCATION(NODE) (BLOCK_CHECK (NODE)->block.locus)
6fdc0f
+
6fdc0f
 struct tree_block GTY(())
6fdc0f
 {
6fdc0f
   struct tree_common common;
6fdc0f
@@ -917,6 +923,7 @@
6fdc0f
   tree abstract_origin;
6fdc0f
   tree fragment_origin;
6fdc0f
   tree fragment_chain;
6fdc0f
+  location_t locus;
6fdc0f
 };
6fdc0f
 
6fdc0f
 /* Define fields and accessors for nodes representing data types.  */