]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Better debug info for inlined functions.
authorJames E Wilson <wilson@specifixinc.com>
Tue, 26 Jul 2005 02:56:44 +0000 (02:56 +0000)
committerJim Wilson <wilson@gcc.gnu.org>
Tue, 26 Jul 2005 02:56:44 +0000 (19:56 -0700)
* dwarf2out.c (add_call_src_coords_attributes): New.
(gen_inlined_subroutine_die): Call it.
(maybe_emit_file, init_file_table): Add comments.
(prune_unused_types_walk_attribs): Pass DW_AT_call_file through
maybe_emit_file.
* tree-inline.c (remap_block): Copy BLOCK_SOURCE_LOCATION.
(expand_call_inline): Set BLOCK_SOURCE_LOCATION.
* tree.h (BLOCK_SOURCE_LOCATION): New.
(struct tree_block): New field locus.

From-SVN: r102379

gcc/ChangeLog
gcc/dwarf2out.c
gcc/tree-inline.c
gcc/tree.h

index 11ef2a555763dae0f60ae7b77c6cc3202f09736d..b3bf9d29f5b8c286b8a5294e13b101d2a66c9fec 100644 (file)
@@ -1,3 +1,15 @@
+2005-07-25  James E Wilson  <wilson@specifixinc.com>
+
+       * dwarf2out.c (add_call_src_coords_attributes): New.
+       (gen_inlined_subroutine_die): Call it.
+       (maybe_emit_file, init_file_table): Add comments.
+       (prune_unused_types_walk_attribs): Pass DW_AT_call_file through
+       maybe_emit_file.
+       * tree-inline.c (remap_block): Copy BLOCK_SOURCE_LOCATION.
+       (expand_call_inline): Set BLOCK_SOURCE_LOCATION.
+       * tree.h (BLOCK_SOURCE_LOCATION): New.
+       (struct tree_block): New field locus.
+
 2005-07-26  Andreas Schwab  <schwab@suse.de>
 
        PR rtl-optimization/23043
index dd3bd5fb5af7d9a1fdc386cfa2d00faa8678ecb1..970cbb5a82d8a0dd97f86d7ee3f1dd65228a4c5b 100644 (file)
@@ -11757,6 +11757,20 @@ gen_label_die (tree decl, dw_die_ref context_die)
     }
 }
 
+/* A helper function for gen_inlined_subroutine_die.  Add source coordinate
+   attributes to the DIE for a block STMT, to describe where the inlined
+   function was called from.  This is similar to add_src_coords_attributes.  */
+
+static inline void
+add_call_src_coords_attributes (tree stmt, dw_die_ref die)
+{
+  expanded_location s = expand_location (BLOCK_SOURCE_LOCATION (stmt));
+  unsigned file_index = lookup_filename (s.file);
+
+  add_AT_unsigned (die, DW_AT_call_file, file_index);
+  add_AT_unsigned (die, DW_AT_call_line, s.line);
+}
+
 /* A helper function for gen_lexical_block_die and gen_inlined_subroutine_die.
    Add low_pc and high_pc attributes to the DIE for a block STMT.  */
 
@@ -11824,6 +11838,7 @@ gen_inlined_subroutine_die (tree stmt, dw_die_ref context_die, int depth)
 
       add_abstract_origin_attribute (subr_die, decl);
       add_high_low_attributes (stmt, subr_die);
+      add_call_src_coords_attributes (stmt, subr_die);
 
       decls_for_scope (stmt, subr_die, depth);
       current_function_has_inlines = 1;
@@ -13247,6 +13262,12 @@ lookup_filename (const char *file_name)
   return i;
 }
 
+/* If the assembler will construct the file table, then translate the compiler
+   internal file table number into the assembler file table number, and emit
+   a .file directive if we haven't already emitted one yet.  The file table
+   numbers are different because we prune debug info for unused variables and
+   types, which may include filenames.  */
+
 static int
 maybe_emit_file (int fileno)
 {
@@ -13267,6 +13288,8 @@ maybe_emit_file (int fileno)
     return fileno;
 }
 
+/* Initialize the compiler internal file table.  */
+
 static void
 init_file_table (void)
 {
@@ -13644,7 +13667,7 @@ prune_unused_types_walk_attribs (dw_die_ref die)
             Make sure that it will get emitted.  */
          prune_unused_types_mark (a->dw_attr_val.v.val_die_ref.die, 1);
        }
-      else if (a->dw_attr == DW_AT_decl_file)
+      else if (a->dw_attr == DW_AT_decl_file || a->dw_attr == DW_AT_call_file)
        {
          /* A reference to a file.  Make sure the file name is emitted.  */
          a->dw_attr_val.v.val_unsigned =
index a0e5a71d194db0cbc11837606e7100808f0d2dfe..21d8ac003ed196caf0ee1ed9a2f30e8fa7536ca2 100644 (file)
@@ -421,6 +421,7 @@ remap_block (tree *block, inline_data *id)
   new_block = make_node (BLOCK);
   TREE_USED (new_block) = TREE_USED (old_block);
   BLOCK_ABSTRACT_ORIGIN (new_block) = old_block;
+  BLOCK_SOURCE_LOCATION (new_block) = BLOCK_SOURCE_LOCATION (old_block);
   *block = new_block;
 
   /* Remap its variables.  */
@@ -2025,9 +2026,9 @@ expand_call_inline (basic_block bb, tree stmt, tree *tp, void *data)
      statement expression is the return type of the function call.  */
   id->block = make_node (BLOCK);
   BLOCK_ABSTRACT_ORIGIN (id->block) = fn;
+  BLOCK_SOURCE_LOCATION (id->block) = input_location;
   add_lexical_block (TREE_BLOCK (stmt), id->block);
 
-
   /* Local declarations will be replaced by their equivalents in this
      map.  */
   st = id->decl_map;
index df730a54af260d78c41b3ebe6886b624578bdc3b..cae0c8b12d62afe0a7cdde08a35561ec3bfcf085 100644 (file)
@@ -1570,6 +1570,12 @@ struct varray_head_tag;
 #define BLOCK_FRAGMENT_ORIGIN(NODE) (BLOCK_CHECK (NODE)->block.fragment_origin)
 #define BLOCK_FRAGMENT_CHAIN(NODE) (BLOCK_CHECK (NODE)->block.fragment_chain)
 
+/* For an inlined function, this gives the location where it was called
+   from.  This is only set in the top level block, which corresponds to the
+   inlined function scope.  This is used in the debug output routines.  */
+
+#define BLOCK_SOURCE_LOCATION(NODE) (BLOCK_CHECK (NODE)->block.locus)
+
 struct tree_block GTY(())
 {
   struct tree_common common;
@@ -1584,6 +1590,7 @@ struct tree_block GTY(())
   tree abstract_origin;
   tree fragment_origin;
   tree fragment_chain;
+  location_t locus;
 };
 \f
 /* Define fields and accessors for nodes representing data types.  */