var_location_switch_text_section ();
- set_cur_line_info_table (sect);
+ if (cold_text_section != NULL)
+ set_cur_line_info_table (sect);
}
\f
/* And now, the subset of the debugging information support code necessary
defines/undefines (and file start/end markers). */
static GTY (()) VEC (macinfo_entry, gc) * macinfo_table;
+/* True if .debug_macinfo or .debug_macros section is going to be
+ emitted. */
+#define have_macinfo \
+ (debug_info_level >= DINFO_LEVEL_VERBOSE \
+ && !VEC_empty (macinfo_entry, macinfo_table))
+
/* Array of dies for which we should generate .debug_ranges info. */
static GTY ((length ("ranges_table_allocated"))) dw_ranges_ref ranges_table;
static dw_die_ref clone_as_declaration (dw_die_ref);
static dw_die_ref clone_die (dw_die_ref);
static dw_die_ref clone_tree (dw_die_ref);
-static void copy_declaration_context (dw_die_ref, dw_die_ref);
+static dw_die_ref copy_declaration_context (dw_die_ref, dw_die_ref);
static void generate_skeleton_ancestor_tree (skeleton_chain_node *);
static void generate_skeleton_bottom_up (skeleton_chain_node *);
static dw_die_ref generate_skeleton (dw_die_ref);
static dw_die_ref remove_child_or_replace_with_skeleton (dw_die_ref,
+ dw_die_ref,
dw_die_ref);
static void break_out_comdat_types (dw_die_ref);
static dw_die_ref copy_ancestor_tree (dw_die_ref, dw_die_ref, htab_t);
return clone;
}
-/* Copy the declaration context to the new compile unit DIE. This includes
+/* Copy the declaration context to the new type unit DIE. This includes
any surrounding namespace or type declarations. If the DIE has an
AT_specification attribute, it also includes attributes and children
- attached to the specification. */
+ attached to the specification, and returns a pointer to the original
+ parent of the declaration DIE. Returns NULL otherwise. */
-static void
+static dw_die_ref
copy_declaration_context (dw_die_ref unit, dw_die_ref die)
{
dw_die_ref decl;
dw_die_ref new_decl;
+ dw_die_ref orig_parent = NULL;
decl = get_AT_ref (die, DW_AT_specification);
if (decl == NULL)
dw_die_ref c;
dw_attr_ref a;
+ /* The original DIE will be changed to a declaration, and must
+ be moved to be a child of the original declaration DIE. */
+ orig_parent = decl->die_parent;
+
/* Copy the type node pointer from the new DIE to the original
declaration DIE so we can forward references later. */
decl->die_id.die_type_node = die->die_id.die_type_node;
add_AT_specification (die, new_decl);
}
}
+
+ return orig_parent;
}
/* Generate the skeleton ancestor tree for the given NODE, then clone
return node.new_die;
}
-/* Remove the DIE from its parent, possibly replacing it with a cloned
- declaration. The original DIE will be moved to a new compile unit
- so that existing references to it follow it to the new location. If
- any of the original DIE's descendants is a declaration, we need to
- replace the original DIE with a skeleton tree and move the
- declarations back into the skeleton tree. */
+/* Remove the CHILD DIE from its parent, possibly replacing it with a cloned
+ declaration. The original DIE is moved to a new compile unit so that
+ existing references to it follow it to the new location. If any of the
+ original DIE's descendants is a declaration, we need to replace the
+ original DIE with a skeleton tree and move the declarations back into the
+ skeleton tree. */
static dw_die_ref
-remove_child_or_replace_with_skeleton (dw_die_ref child, dw_die_ref prev)
+remove_child_or_replace_with_skeleton (dw_die_ref unit, dw_die_ref child,
+ dw_die_ref prev)
{
- dw_die_ref skeleton;
+ dw_die_ref skeleton, orig_parent;
+
+ /* Copy the declaration context to the type unit DIE. If the returned
+ ORIG_PARENT is not NULL, the skeleton needs to be added as a child of
+ that DIE. */
+ orig_parent = copy_declaration_context (unit, child);
skeleton = generate_skeleton (child);
if (skeleton == NULL)
else
{
skeleton->die_id.die_type_node = child->die_id.die_type_node;
- replace_child (child, skeleton, prev);
+
+ /* If the original DIE was a specification, we need to put
+ the skeleton under the parent DIE of the declaration.
+ This leaves the original declaration in the tree, but
+ it will be pruned later since there are no longer any
+ references to it. */
+ if (orig_parent != NULL)
+ {
+ remove_child_with_prev (child, prev);
+ add_child_die (orig_parent, skeleton);
+ }
+ else
+ replace_child (child, skeleton, prev);
}
return skeleton;
generate_type_signature (c, type_node);
/* Copy the declaration context, attributes, and children of the
- declaration into the new compile unit DIE. */
- copy_declaration_context (unit, c);
-
- /* Remove this DIE from the main CU. */
- replacement = remove_child_or_replace_with_skeleton (c, prev);
+ declaration into the new type unit DIE, then remove this DIE
+ from the main CU (or replace it with a skeleton if necessary). */
+ replacement = remove_child_or_replace_with_skeleton (unit, c, prev);
/* Break out nested types into their own type units. */
break_out_comdat_types (c);
return copy;
}
+/* Like clone_tree, but additionally enter all the children into
+ the hash table decl_table. */
+
+static dw_die_ref
+clone_tree_hash (dw_die_ref die, htab_t decl_table)
+{
+ dw_die_ref c;
+ dw_die_ref clone = clone_die (die);
+ struct decl_table_entry *entry;
+ void **slot = htab_find_slot_with_hash (decl_table, die,
+ htab_hash_pointer (die), INSERT);
+ /* Assert that DIE isn't in the hash table yet. If it would be there
+ before, the ancestors would be necessarily there as well, therefore
+ clone_tree_hash wouldn't be called. */
+ gcc_assert (*slot == HTAB_EMPTY_ENTRY);
+ entry = XCNEW (struct decl_table_entry);
+ entry->orig = die;
+ entry->copy = clone;
+ *slot = entry;
+
+ FOR_EACH_CHILD (die, c,
+ add_child_die (clone, clone_tree_hash (c, decl_table)));
+
+ return clone;
+}
+
/* Walk the DIE and its children, looking for references to incomplete
or trivial types that are unmarked (i.e., that are not in the current
type_unit). */
else
{
dw_die_ref parent = unit;
- dw_die_ref copy = clone_tree (targ);
-
- /* Make sure the cloned tree is marked as part of the
- type unit. */
- mark_dies (copy);
+ dw_die_ref copy = clone_die (targ);
/* Record in DECL_TABLE that TARG has been copied.
Need to do this now, before the recursive call,
entry->copy = copy;
*slot = entry;
+ FOR_EACH_CHILD (targ, c,
+ add_child_die (copy,
+ clone_tree_hash (c, decl_table)));
+
+ /* Make sure the cloned tree is marked as part of the
+ type unit. */
+ mark_dies (copy);
+
/* If TARG has surrounding context, copy its ancestor tree
into the new type unit. */
if (targ->die_parent != NULL
useful source coordinates anyway. */
name = DECL_NAME (name);
add_name_attribute (mod_type_die, IDENTIFIER_POINTER (name));
- add_gnat_descriptive_type_attribute (mod_type_die, type, context_die);
- if (TYPE_ARTIFICIAL (type))
- add_AT_flag (mod_type_die, DW_AT_artificial, 1);
}
/* This probably indicates a bug. */
else if (mod_type_die && mod_type_die->die_tag == DW_TAG_base_type)
if (sub_die != NULL)
add_AT_die_ref (mod_type_die, DW_AT_type, sub_die);
+ add_gnat_descriptive_type_attribute (mod_type_die, type, context_die);
+ if (TYPE_ARTIFICIAL (type))
+ add_AT_flag (mod_type_die, DW_AT_artificial, 1);
+
return mod_type_die;
}
return 1;
}
+ if (targetm.const_not_ok_for_debug_p (rtl))
+ {
+ expansion_failed (NULL_TREE, rtl,
+ "Expression rejected for debug by the backend.\n");
+ return 1;
+ }
+
if (GET_CODE (rtl) != SYMBOL_REF)
return 0;
dtype_die = lookup_type_die (dtype);
if (!dtype_die)
{
- /* The descriptive type indirectly references TYPE if this is also the
- case for TYPE itself. Do not deal with the circularity here. */
- TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (type)) = 1;
gen_type_die (dtype, context_die);
- TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (type)) = 0;
dtype_die = lookup_type_die (dtype);
gcc_assert (dtype_die);
}
array_die = new_die (DW_TAG_array_type, scope_die, type);
add_name_attribute (array_die, type_tag (type));
- add_gnat_descriptive_type_attribute (array_die, type, context_die);
- if (TYPE_ARTIFICIAL (type))
- add_AT_flag (array_die, DW_AT_artificial, 1);
equate_type_number_to_die (type, array_die);
if (TREE_CODE (type) == VECTOR_TYPE)
add_type_attribute (array_die, element_type, 0, 0, context_die);
+ add_gnat_descriptive_type_attribute (array_die, type, context_die);
+ if (TYPE_ARTIFICIAL (type))
+ add_AT_flag (array_die, DW_AT_artificial, 1);
+
if (get_AT (array_die, DW_AT_name))
add_pubtype (type, array_die);
}
scope_die_for (type, context_die), type);
equate_type_number_to_die (type, type_die);
add_name_attribute (type_die, type_tag (type));
- add_gnat_descriptive_type_attribute (type_die, type, context_die);
- if (TYPE_ARTIFICIAL (type))
- add_AT_flag (type_die, DW_AT_artificial, 1);
if (dwarf_version >= 4 || !dwarf_strict)
{
if (ENUM_IS_SCOPED (type))
add_AT_int (enum_die, DW_AT_const_value,
tree_low_cst (value, tree_int_cst_sgn (value) > 0));
}
+
+ add_gnat_descriptive_type_attribute (type_die, type, context_die);
+ if (TYPE_ARTIFICIAL (type))
+ add_AT_flag (type_die, DW_AT_artificial, 1);
}
else
add_AT_flag (type_die, DW_AT_declaration, 1);
if (old_die)
add_AT_specification (type_die, old_die);
else
- {
- add_name_attribute (type_die, type_tag (type));
- add_gnat_descriptive_type_attribute (type_die, type, context_die);
- if (TYPE_ARTIFICIAL (type))
- add_AT_flag (type_die, DW_AT_artificial, 1);
- }
+ add_name_attribute (type_die, type_tag (type));
}
else
remove_AT (type_die, DW_AT_declaration);
gen_member_die (type, type_die);
pop_decl_scope ();
+ add_gnat_descriptive_type_attribute (type_die, type, context_die);
+ if (TYPE_ARTIFICIAL (type))
+ add_AT_flag (type_die, DW_AT_artificial, 1);
+
/* GNU extension: Record what type our vtable lives in. */
if (TYPE_VFIELD (type))
{
return;
/* For local statics lookup proper context die. */
- if (TREE_STATIC (decl) && decl_function_context (decl))
+ if (TREE_STATIC (decl)
+ && DECL_CONTEXT (decl)
+ && TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL)
context_die = lookup_decl_die (DECL_CONTEXT (decl));
/* If we are in terse mode, don't generate any DIEs to represent any
macinfo_entry e;
/* Insert a dummy first entry to be able to optimize the whole
predefined macro block using DW_MACRO_GNU_transparent_include. */
- if (VEC_empty (macinfo_entry, macinfo_table) && lineno == 0)
+ if (VEC_empty (macinfo_entry, macinfo_table) && lineno <= 1)
{
e.code = 0;
e.lineno = 0;
macinfo_entry e;
/* Insert a dummy first entry to be able to optimize the whole
predefined macro block using DW_MACRO_GNU_transparent_include. */
- if (VEC_empty (macinfo_entry, macinfo_table) && lineno == 0)
+ if (VEC_empty (macinfo_entry, macinfo_table) && lineno <= 1)
{
e.code = 0;
e.lineno = 0;
/* Optimize only if there are at least two consecutive define/undef ops,
and either all of them are before first DW_MACINFO_start_file
- with lineno 0 (i.e. predefined macro block), or all of them are
+ with lineno {0,1} (i.e. predefined macro block), or all of them are
in some included header file. */
if (second->code != DW_MACINFO_define && second->code != DW_MACINFO_undef)
return 0;
if (VEC_empty (macinfo_entry, files))
{
- if (first->lineno != 0 || second->lineno != 0)
+ if (first->lineno > 1 || second->lineno > 1)
return 0;
}
else if (first->lineno == 0)
for (i = idx; VEC_iterate (macinfo_entry, macinfo_table, i, cur); i++)
if (cur->code != DW_MACINFO_define && cur->code != DW_MACINFO_undef)
break;
- else if (first->lineno == 0 && cur->lineno != 0)
+ else if (VEC_empty (macinfo_entry, files) && cur->lineno > 1)
break;
else
{
/* From the containing include filename (if any) pick up just
usable characters from its basename. */
- if (first->lineno == 0)
+ if (VEC_empty (macinfo_entry, files))
base = "";
else
base = lbasename (VEC_last (macinfo_entry, files)->info);
for (node = deferred_asm_name; node; node = node->next)
{
tree decl = node->created_for;
- if (DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl))
+ /* When generating LTO bytecode we can not generate new assembler
+ names at this point and all important decls got theirs via
+ free-lang-data. */
+ if ((!flag_generate_lto || DECL_ASSEMBLER_NAME_SET_P (decl))
+ && DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl))
{
add_linkage_attr (node->die, decl);
move_linkage_attr (node->die);
add_AT_lineptr (comp_unit_die (), DW_AT_stmt_list,
debug_line_section_label);
- if (debug_info_level >= DINFO_LEVEL_VERBOSE)
+ if (have_macinfo)
add_AT_macptr (comp_unit_die (),
dwarf_strict ? DW_AT_macro_info : DW_AT_GNU_macros,
macinfo_section_label);
htab_delete (comdat_type_table);
/* Output the main compilation unit if non-empty or if .debug_macinfo
- will be emitted. */
- output_comp_unit (comp_unit_die (), debug_info_level >= DINFO_LEVEL_VERBOSE);
+ or .debug_macro will be emitted. */
+ output_comp_unit (comp_unit_die (), have_macinfo);
/* Output the abbreviation table. */
if (abbrev_die_table_in_use != 1)
}
/* Have to end the macro section. */
- if (debug_info_level >= DINFO_LEVEL_VERBOSE)
+ if (have_macinfo)
{
switch_to_section (debug_macinfo_section);
ASM_OUTPUT_LABEL (asm_out_file, macinfo_section_label);
- if (!VEC_empty (macinfo_entry, macinfo_table))
- output_macinfo ();
+ output_macinfo ();
dw2_asm_output_data (1, 0, "End compilation unit");
}