/* Output Dwarf2 format symbol table information from the GNU C compiler.
- Copyright (C) 1992, 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+ Copyright (C) 1992, 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
Free Software Foundation, Inc.
Contributed by Gary Funck (gary@intrepid.com).
Derived from DWARF 1 implementation of Ron Guilmette (rfg@monkeys.com).
typedef struct limbo_die_struct
{
dw_die_ref die;
+ tree created_for;
struct limbo_die_struct *next;
}
limbo_die_node;
static inline void free_die PARAMS ((dw_die_ref));
static void remove_children PARAMS ((dw_die_ref));
static void add_child_die PARAMS ((dw_die_ref, dw_die_ref));
-static dw_die_ref new_die PARAMS ((enum dwarf_tag, dw_die_ref));
+static dw_die_ref new_die PARAMS ((enum dwarf_tag, dw_die_ref,
+ tree));
static dw_die_ref lookup_type_die PARAMS ((tree));
static void equate_type_number_to_die PARAMS ((tree, dw_die_ref));
static dw_die_ref lookup_decl_die PARAMS ((tree));
const char *, const char *, const char *));
static void output_loc_list PARAMS ((dw_loc_list_ref));
static char *gen_internal_sym PARAMS ((const char *));
+static void mark_limbo_die_list PARAMS ((void *));
/* Section names used to hold DWARF debugging information. */
#ifndef DEBUG_INFO_SECTION
/* Return a pointer to a newly created DIE node. */
static inline dw_die_ref
-new_die (tag_value, parent_die)
+new_die (tag_value, parent_die, t)
enum dwarf_tag tag_value;
dw_die_ref parent_die;
+ tree t;
{
dw_die_ref die = (dw_die_ref) xcalloc (1, sizeof (die_node));
limbo_node = (limbo_die_node *) xmalloc (sizeof (limbo_die_node));
limbo_node->die = die;
+ limbo_node->created_for = t;
limbo_node->next = limbo_die_list;
limbo_die_list = limbo_node;
}
abort ();
}
- base_type_result = new_die (DW_TAG_base_type, comp_unit_die);
+ base_type_result = new_die (DW_TAG_base_type, comp_unit_die, type);
if (demangle_name_func)
type_name = (*demangle_name_func) (type_name);
;
else if (is_const_type)
{
- mod_type_die = new_die (DW_TAG_const_type, comp_unit_die);
+ mod_type_die = new_die (DW_TAG_const_type, comp_unit_die, type);
sub_die = modified_type_die (type, 0, is_volatile_type, context_die);
}
else if (is_volatile_type)
{
- mod_type_die = new_die (DW_TAG_volatile_type, comp_unit_die);
+ mod_type_die = new_die (DW_TAG_volatile_type, comp_unit_die, type);
sub_die = modified_type_die (type, 0, 0, context_die);
}
else if (code == POINTER_TYPE)
{
- mod_type_die = new_die (DW_TAG_pointer_type, comp_unit_die);
+ mod_type_die = new_die (DW_TAG_pointer_type, comp_unit_die, type);
add_AT_unsigned (mod_type_die, DW_AT_byte_size, PTR_SIZE);
#if 0
add_AT_unsigned (mod_type_die, DW_AT_address_class, 0);
}
else if (code == REFERENCE_TYPE)
{
- mod_type_die = new_die (DW_TAG_reference_type, comp_unit_die);
+ mod_type_die = new_die (DW_TAG_reference_type, comp_unit_die, type);
add_AT_unsigned (mod_type_die, DW_AT_byte_size, PTR_SIZE);
#if 0
add_AT_unsigned (mod_type_die, DW_AT_address_class, 0);
&& (! optimize || GET_CODE (SAVE_EXPR_RTL (bound)) == MEM))
{
dw_die_ref ctx = lookup_decl_die (current_function_decl);
- dw_die_ref decl_die = new_die (DW_TAG_variable, ctx);
+ dw_die_ref decl_die = new_die (DW_TAG_variable, ctx, bound);
rtx loc = SAVE_EXPR_RTL (bound);
/* If the RTL for the SAVE_EXPR is memory, handle the case where
else
ctx = lookup_decl_die (current_function_decl);
- decl_die = new_die (DW_TAG_variable, ctx);
+ decl_die = new_die (DW_TAG_variable, ctx, bound);
add_AT_flag (decl_die, DW_AT_artificial, 1);
add_type_attribute (decl_die, TREE_TYPE (bound), 1, 0, ctx);
add_AT_loc (decl_die, DW_AT_location, loc);
/* Arrays come in three flavors: Unspecified bounds, fixed bounds,
and (in GNU C only) variable bounds. Handle all three forms
here. */
- subrange_die = new_die (DW_TAG_subrange_type, type_die);
+ subrange_die = new_die (DW_TAG_subrange_type, type_die, NULL);
if (domain)
{
/* We have an array type with specified bounds. */
gen_type_die (TREE_TYPE (type), context_die);
#endif
- array_die = new_die (DW_TAG_array_type, scope_die);
+ array_die = new_die (DW_TAG_array_type, scope_die, type);
#if 0
/* We default the array ordering. SDB will probably do
dw_die_ref context_die;
{
dw_die_ref type_die
- = new_die (DW_TAG_set_type, scope_die_for (type, context_die));
+ = new_die (DW_TAG_set_type, scope_die_for (type, context_die), type);
equate_type_number_to_die (type, type_die);
add_type_attribute (type_die, TREE_TYPE (type), 0, 0, context_die);
dw_die_ref context_die;
{
tree origin = decl_ultimate_origin (decl);
- dw_die_ref decl_die = new_die (DW_TAG_entry_point, context_die);
+ dw_die_ref decl_die = new_die (DW_TAG_entry_point, context_die, decl);
if (origin != NULL)
add_abstract_origin_attribute (decl_die, origin);
tree type;
dw_die_ref context_die;
{
- dw_die_ref type_die = new_die (DW_TAG_enumeration_type, context_die);
+ dw_die_ref type_die = new_die (DW_TAG_enumeration_type, context_die, type);
/* We do not check for TREE_ASM_WRITTEN (type) being set, as the type may
be incomplete and such types are not marked. */
tree type;
dw_die_ref context_die;
{
- dw_die_ref type_die = new_die (DW_TAG_structure_type, context_die);
+ dw_die_ref type_die = new_die (DW_TAG_structure_type, context_die, type);
/* We do not check for TREE_ASM_WRITTEN (type) being set, as the type may
be incomplete and such types are not marked. */
tree type;
dw_die_ref context_die;
{
- dw_die_ref type_die = new_die (DW_TAG_union_type, context_die);
+ dw_die_ref type_die = new_die (DW_TAG_union_type, context_die, type);
/* We do not check for TREE_ASM_WRITTEN (type) being set, as the type may
be incomplete and such types are not marked. */
if (type_die == NULL)
{
type_die = new_die (DW_TAG_enumeration_type,
- scope_die_for (type, context_die));
+ scope_die_for (type, context_die), type);
equate_type_number_to_die (type, type_die);
add_name_attribute (type_die, type_tag (type));
}
for (link = TYPE_FIELDS (type);
link != NULL; link = TREE_CHAIN (link))
{
- dw_die_ref enum_die = new_die (DW_TAG_enumerator, type_die);
+ dw_die_ref enum_die = new_die (DW_TAG_enumerator, type_die, link);
add_name_attribute (enum_die,
IDENTIFIER_POINTER (TREE_PURPOSE (link)));
dw_die_ref context_die;
{
dw_die_ref parm_die
- = new_die (DW_TAG_formal_parameter, context_die);
+ = new_die (DW_TAG_formal_parameter, context_die, node);
tree origin;
switch (TREE_CODE_CLASS (TREE_CODE (node)))
static void
gen_unspecified_parameters_die (decl_or_type, context_die)
- tree decl_or_type ATTRIBUTE_UNUSED;
+ tree decl_or_type;
dw_die_ref context_die;
{
- new_die (DW_TAG_unspecified_parameters, context_die);
+ new_die (DW_TAG_unspecified_parameters, context_die, decl_or_type);
}
/* Generate a list of nameless DW_TAG_formal_parameter DIEs (and perhaps a
if (old_die && old_die->die_parent == NULL)
add_child_die (context_die, old_die);
- subr_die = new_die (DW_TAG_subprogram, context_die);
+ subr_die = new_die (DW_TAG_subprogram, context_die, decl);
add_abstract_origin_attribute (subr_die, origin);
}
else if (old_die)
}
else
{
- subr_die = new_die (DW_TAG_subprogram, context_die);
+ subr_die = new_die (DW_TAG_subprogram, context_die, decl);
add_AT_die_ref (subr_die, DW_AT_specification, 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);
}
else
{
- subr_die = new_die (DW_TAG_subprogram, context_die);
+ subr_die = new_die (DW_TAG_subprogram, context_die, decl);
if (TREE_PUBLIC (decl))
add_AT_flag (subr_die, DW_AT_external, 1);
dw_die_ref context_die;
{
tree origin = decl_ultimate_origin (decl);
- dw_die_ref var_die = new_die (DW_TAG_variable, context_die);
+ dw_die_ref var_die = new_die (DW_TAG_variable, context_die, decl);
dw_die_ref old_die = lookup_decl_die (decl);
int declaration = (DECL_EXTERNAL (decl)
dw_die_ref context_die;
{
tree origin = decl_ultimate_origin (decl);
- dw_die_ref lbl_die = new_die (DW_TAG_label, context_die);
+ dw_die_ref lbl_die = new_die (DW_TAG_label, context_die, decl);
rtx insn;
char label[MAX_ARTIFICIAL_LABEL_BYTES];
dw_die_ref context_die;
int depth;
{
- dw_die_ref stmt_die = new_die (DW_TAG_lexical_block, context_die);
+ dw_die_ref stmt_die = new_die (DW_TAG_lexical_block, context_die, stmt);
char label[MAX_ARTIFICIAL_LABEL_BYTES];
if (! BLOCK_ABSTRACT (stmt))
if (! BLOCK_ABSTRACT (stmt))
{
dw_die_ref subr_die
- = new_die (DW_TAG_inlined_subroutine, context_die);
+ = new_die (DW_TAG_inlined_subroutine, context_die, stmt);
tree decl = block_ultimate_origin (stmt);
char label[MAX_ARTIFICIAL_LABEL_BYTES];
tree decl;
dw_die_ref context_die;
{
- dw_die_ref decl_die = new_die (DW_TAG_member, context_die);
+ dw_die_ref decl_die = new_die (DW_TAG_member, context_die, decl);
add_name_and_src_coords_attributes (decl_die, decl);
add_type_attribute (decl_die, member_declared_type (decl),
dw_die_ref context_die;
{
dw_die_ref ptr_die
- = new_die (DW_TAG_pointer_type, scope_die_for (type, context_die));
+ = new_die (DW_TAG_pointer_type, scope_die_for (type, context_die), type);
equate_type_number_to_die (type, ptr_die);
add_type_attribute (ptr_die, TREE_TYPE (type), 0, 0, context_die);
dw_die_ref context_die;
{
dw_die_ref ref_die
- = new_die (DW_TAG_reference_type, scope_die_for (type, context_die));
+ = new_die (DW_TAG_reference_type, scope_die_for (type, context_die), type);
equate_type_number_to_die (type, ref_die);
add_type_attribute (ref_die, TREE_TYPE (type), 0, 0, context_die);
dw_die_ref context_die;
{
dw_die_ref ptr_die
- = new_die (DW_TAG_ptr_to_member_type, scope_die_for (type, context_die));
+ = new_die (DW_TAG_ptr_to_member_type,
+ scope_die_for (type, context_die), type);
equate_type_number_to_die (type, ptr_die);
add_AT_die_ref (ptr_die, DW_AT_containing_type,
const char *language_string = lang_hooks.name;
int language;
- die = new_die (DW_TAG_compile_unit, NULL);
+ die = new_die (DW_TAG_compile_unit, NULL, NULL);
add_name_attribute (die, filename);
if (wd != NULL && filename[0] != DIR_SEPARATOR)
dw_die_ref context_die;
{
dw_die_ref type_die
- = new_die (DW_TAG_string_type, scope_die_for (type, context_die));
+ = new_die (DW_TAG_string_type, scope_die_for (type, context_die), type);
equate_type_number_to_die (type, type_die);
tree binfo;
dw_die_ref context_die;
{
- dw_die_ref die = new_die (DW_TAG_inheritance, context_die);
+ dw_die_ref die = new_die (DW_TAG_inheritance, context_die, binfo);
add_type_attribute (die, BINFO_TYPE (binfo), 0, 0, context_die);
add_data_member_location_attribute (die, binfo);
type_die = new_die (TREE_CODE (type) == RECORD_TYPE
? DW_TAG_structure_type : DW_TAG_union_type,
- scope_die);
+ 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);
{
tree return_type = TREE_TYPE (type);
dw_die_ref subr_die
- = new_die (DW_TAG_subroutine_type, scope_die_for (type, context_die));
+ = new_die (DW_TAG_subroutine_type,
+ scope_die_for (type, context_die), type);
equate_type_number_to_die (type, subr_die);
add_prototyped_attribute (subr_die, type);
return;
TREE_ASM_WRITTEN (decl) = 1;
- type_die = new_die (DW_TAG_typedef, context_die);
+ type_die = new_die (DW_TAG_typedef, context_die, decl);
origin = decl_ultimate_origin (decl);
if (origin != NULL)
add_abstract_origin_attribute (type_die, origin);
abort ();
}
}
+
+static void
+mark_limbo_die_list (ptr)
+ void *ptr ATTRIBUTE_UNUSED;
+{
+ limbo_die_node *node;
+ for (node = limbo_die_list; node ; node = node->next)
+ ggc_mark_tree (node->created_for);
+}
\f
/* Add Ada "use" clause information for SGI Workshop debugger. */
if (filename != NULL)
{
- dw_die_ref unit_die = new_die (DW_TAG_module, comp_unit_die);
+ dw_die_ref unit_die = new_die (DW_TAG_module, comp_unit_die, NULL);
tree context_list_decl
= build_decl (LABEL_DECL, get_identifier (context_list),
void_type_node);
if (flag_eliminate_dwarf2_dups)
{
/* Record the beginning of the file for break_out_includes. */
- dw_die_ref bincl_die = new_die (DW_TAG_GNU_BINCL, comp_unit_die);
+ dw_die_ref bincl_die = new_die (DW_TAG_GNU_BINCL, comp_unit_die, NULL);
add_AT_string (bincl_die, DW_AT_name, filename);
}
{
if (flag_eliminate_dwarf2_dups)
/* Record the end of the file for break_out_includes. */
- new_die (DW_TAG_GNU_EINCL, comp_unit_die);
+ new_die (DW_TAG_GNU_EINCL, comp_unit_die, NULL);
if (debug_info_level >= DINFO_LEVEL_VERBOSE)
{
VARRAY_RTX_INIT (used_rtx_varray, 32, "used_rtx_varray");
ggc_add_rtx_varray_root (&used_rtx_varray, 1);
+ ggc_add_root (&limbo_die_list, 1, 1, mark_limbo_die_list);
+
ASM_GENERATE_INTERNAL_LABEL (text_end_label, TEXT_END_LABEL, 0);
ASM_GENERATE_INTERNAL_LABEL (abbrev_section_label,
DEBUG_ABBREV_SECTION_LABEL, 0);
if (die->die_parent == NULL)
{
dw_die_ref origin = get_AT_ref (die, DW_AT_abstract_origin);
+ tree context;
if (origin)
add_child_die (origin->die_parent, die);
else if (die == comp_unit_die)
;
+ else if (node->created_for
+ && ((DECL_P (node->created_for)
+ && (context = DECL_CONTEXT (node->created_for)))
+ || (TYPE_P (node->created_for)
+ && (context = TYPE_CONTEXT (node->created_for))))
+ && TREE_CODE (context) == FUNCTION_DECL)
+ {
+ /* In certain situations, the lexical block containing a
+ nested function can be optimized away, which results
+ in the nested function die being orphaned. Likewise
+ with the return type of that nested function. Force
+ this to be a child of the containing function. */
+ origin = lookup_decl_die (context);
+ if (! origin)
+ abort ();
+ add_child_die (origin, die);
+ }
else if (errorcount > 0 || sorrycount > 0)
/* It's OK to be confused by errors in the input. */
add_child_die (comp_unit_die, die);