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

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