diff options
author | James E Wilson <wilson@specifixinc.com> | 2005-07-26 02:56:44 +0000 |
---|---|---|
committer | Jim Wilson <wilson@gcc.gnu.org> | 2005-07-25 19:56:44 -0700 |
commit | 3e2844cb07459014e55308e43ec26dd75e280f30 (patch) | |
tree | 21c55286c5bc2b5af118cad52bc71fa46c46a004 | |
parent | dd4f41c3775d2d554849efffc0cd5ef7e806d4a1 (diff) | |
download | gcc-3e2844cb07459014e55308e43ec26dd75e280f30.zip gcc-3e2844cb07459014e55308e43ec26dd75e280f30.tar.gz gcc-3e2844cb07459014e55308e43ec26dd75e280f30.tar.bz2 |
Better debug info for inlined functions.
* 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
-rw-r--r-- | gcc/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/dwarf2out.c | 25 | ||||
-rw-r--r-- | gcc/tree-inline.c | 3 | ||||
-rw-r--r-- | gcc/tree.h | 7 |
4 files changed, 45 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 11ef2a5..b3bf9d2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index dd3bd5f..970cbb5 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -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 = diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index a0e5a71..21d8ac0 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -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; @@ -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; }; /* Define fields and accessors for nodes representing data types. */ |