/* Output Dwarf2 format symbol table information from GCC.
Copyright (C) 1992, 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
- 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+ 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
Free Software Foundation, Inc.
Contributed by Gary Funck (gary@intrepid.com).
Derived from DWARF 1 implementation of Ron Guilmette (rfg@monkeys.com).
static void dwarf2out_source_line (unsigned int, const char *, int, bool);
static rtx last_var_location_insn;
+static rtx cached_next_real_insn;
#ifdef VMS_DEBUGGING_INFO
int vms_file_stats_name (const char *, long long *, long *, char *, int *);
char label[MAX_ARTIFICIAL_LABEL_BYTES];
last_var_location_insn = NULL_RTX;
+ cached_next_real_insn = NULL_RTX;
if (dwarf2out_do_cfi_asm ())
fprintf (asm_out_file, "\t.cfi_endproc\n");
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
return DW_FORM_block1;
case 2:
return DW_FORM_block2;
+ case 4:
+ return DW_FORM_block4;
default:
gcc_unreachable ();
}
/* Don't output an entry that starts and ends at the same address. */
if (strcmp (curr->begin, curr->end) == 0 && !curr->force)
continue;
+ size = size_of_locs (curr->expr);
+ /* If the expression is too large, drop it on the floor. We could
+ perhaps put it into DW_TAG_dwarf_procedure and refer to that
+ in the expression, but >= 64KB expressions for a single value
+ in a single range are unlikely very useful. */
+ if (size > 0xffff)
+ continue;
if (!have_multiple_function_sections)
{
dw2_asm_output_delta (DWARF2_ADDR_SIZE, curr->begin, curr->section,
"Location list end address (%s)",
list_head->ll_symbol);
}
- size = size_of_locs (curr->expr);
/* Output the block length for this list of location operations. */
gcc_assert (size <= 0xffff);
tree item_type = NULL;
tree qualified_type;
tree name, low, high;
+ dw_die_ref mod_scope;
if (code == ERROR_MARK)
return NULL;
/* Else cv-qualified version of named type; fall through. */
}
+ mod_scope = scope_die_for (type, context_die);
+
if (is_const_type
/* If both is_const_type and is_volatile_type, prefer the path
which leads to a qualified type. */
|| get_qualified_type (type, TYPE_QUAL_CONST) == NULL_TREE
|| get_qualified_type (type, TYPE_QUAL_VOLATILE) != NULL_TREE))
{
- mod_type_die = new_die (DW_TAG_const_type, comp_unit_die (), type);
+ mod_type_die = new_die (DW_TAG_const_type, mod_scope, 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 (), type);
+ mod_type_die = new_die (DW_TAG_volatile_type, mod_scope, type);
sub_die = modified_type_die (type, is_const_type, 0, context_die);
}
else if (code == POINTER_TYPE)
{
- mod_type_die = new_die (DW_TAG_pointer_type, comp_unit_die (), type);
+ mod_type_die = new_die (DW_TAG_pointer_type, mod_scope, type);
add_AT_unsigned (mod_type_die, DW_AT_byte_size,
simple_type_size_in_bits (type) / BITS_PER_UNIT);
item_type = TREE_TYPE (type);
else if (code == REFERENCE_TYPE)
{
if (TYPE_REF_IS_RVALUE (type) && dwarf_version >= 4)
- mod_type_die = new_die (DW_TAG_rvalue_reference_type, comp_unit_die (),
+ mod_type_die = new_die (DW_TAG_rvalue_reference_type, mod_scope,
type);
else
- mod_type_die = new_die (DW_TAG_reference_type, comp_unit_die (), type);
+ mod_type_die = new_die (DW_TAG_reference_type, mod_scope, type);
add_AT_unsigned (mod_type_die, DW_AT_byte_size,
simple_type_size_in_bits (type) / BITS_PER_UNIT);
item_type = TREE_TYPE (type);
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)
- add_name_attribute (mod_type_die, "__unknown__");
+ {
+ name = TYPE_NAME (type);
+ if (name
+ && TREE_CODE (name) == TYPE_DECL)
+ name = DECL_NAME (name);
+ add_name_attribute (mod_type_die,
+ name ? IDENTIFIER_POINTER (name) : "__unknown__");
+ }
if (qualified_type)
equate_type_number_to_die (qualified_type, mod_type_die);
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;
}
}
}
- regno = DWARF_FRAME_REGNUM (REGNO (reg));
+ regno = REGNO (reg);
+#ifdef LEAF_REG_REMAP
+ if (current_function_uses_only_leaf_regs)
+ {
+ int leaf_reg = LEAF_REG_REMAP (regno);
+ if (leaf_reg != -1)
+ regno = (unsigned) leaf_reg;
+ }
+#endif
+ regno = DWARF_FRAME_REGNUM (regno);
if (!optimize && fde
&& (fde->drap_reg == regno || fde->vdrap_reg == regno))
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);
}
VEC_pop (tree, decl_scope_table);
}
+/* walk_tree helper function for uses_local_type, below. */
+
+static tree
+uses_local_type_r (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
+{
+ if (!TYPE_P (*tp))
+ *walk_subtrees = 0;
+ else
+ {
+ tree name = TYPE_NAME (*tp);
+ if (name && DECL_P (name) && decl_function_context (name))
+ return *tp;
+ }
+ return NULL_TREE;
+}
+
+/* If TYPE involves a function-local type (including a local typedef to a
+ non-local type), returns that type; otherwise returns NULL_TREE. */
+
+static tree
+uses_local_type (tree type)
+{
+ tree used = walk_tree_without_duplicates (&type, uses_local_type_r, NULL);
+ return used;
+}
+
/* Return the DIE for the scope that immediately contains this type.
- Non-named types get global scope. Named types nested in other
- types get their containing scope if it's open, or global scope
- otherwise. All other types (i.e. function-local named types) get
+ Non-named types that do not involve a function-local type get global
+ scope. Named types nested in namespaces or other types get their
+ containing scope. All other types (i.e. function-local named types) get
the current active scope. */
static dw_die_ref
{
dw_die_ref scope_die = NULL;
tree containing_scope;
- int i;
/* Non-types always go in the current scope. */
gcc_assert (TYPE_P (t));
- containing_scope = TYPE_CONTEXT (t);
+ /* Use the scope of the typedef, rather than the scope of the type
+ it refers to. */
+ if (TYPE_NAME (t) && DECL_P (TYPE_NAME (t)))
+ containing_scope = DECL_CONTEXT (TYPE_NAME (t));
+ else
+ containing_scope = TYPE_CONTEXT (t);
- /* Use the containing namespace if it was passed in (for a declaration). */
+ /* Use the containing namespace if there is one. */
if (containing_scope && TREE_CODE (containing_scope) == NAMESPACE_DECL)
{
if (context_die == lookup_decl_die (containing_scope))
/* OK */;
+ else if (debug_info_level > DINFO_LEVEL_TERSE)
+ context_die = get_context_die (containing_scope);
else
containing_scope = NULL_TREE;
}
containing_scope = NULL_TREE;
if (SCOPE_FILE_SCOPE_P (containing_scope))
- scope_die = comp_unit_die ();
+ {
+ /* If T uses a local type keep it local as well, to avoid references
+ to function-local DIEs from outside the function. */
+ if (current_function_decl && uses_local_type (t))
+ scope_die = context_die;
+ else
+ scope_die = comp_unit_die ();
+ }
else if (TYPE_P (containing_scope))
{
- /* For types, we can just look up the appropriate DIE. But
- first we check to see if we're in the middle of emitting it
- so we know where the new DIE should go. */
- for (i = VEC_length (tree, decl_scope_table) - 1; i >= 0; --i)
- if (VEC_index (tree, decl_scope_table, i) == containing_scope)
- break;
-
- if (i < 0)
+ /* For types, we can just look up the appropriate DIE. */
+ if (debug_info_level > DINFO_LEVEL_TERSE)
+ scope_die = get_context_die (containing_scope);
+ else
{
- gcc_assert (debug_info_level <= DINFO_LEVEL_TERSE
- || TREE_ASM_WRITTEN (containing_scope));
- /*We are not in the middle of emitting the type
- CONTAINING_SCOPE. Let's see if it's emitted already. */
- scope_die = lookup_type_die (containing_scope);
-
- /* If none of the current dies are suitable, we get file scope. */
+ scope_die = lookup_type_die_strip_naming_typedef (containing_scope);
if (scope_die == NULL)
scope_die = comp_unit_die ();
}
- else
- scope_die = lookup_type_die_strip_naming_typedef (containing_scope);
}
else
scope_die = context_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);
ASM_GENERATE_INTERNAL_LABEL (label, "L", CODE_LABEL_NUMBER (insn));
add_AT_lbl_id (lbl_die, DW_AT_low_pc, label);
}
+ else if (insn
+ && NOTE_P (insn)
+ && NOTE_KIND (insn) == NOTE_INSN_DELETED_DEBUG_LABEL
+ && CODE_LABEL_NUMBER (insn) != -1)
+ {
+ ASM_GENERATE_INTERNAL_LABEL (label, "LDL", CODE_LABEL_NUMBER (insn));
+ add_AT_lbl_id (lbl_die, DW_AT_low_pc, label);
+ }
}
}
language = DW_LANG_ObjC;
else if (strcmp (language_string, "GNU Objective-C++") == 0)
language = DW_LANG_ObjC_plus_plus;
+ else if (dwarf_version >= 5 || !dwarf_strict)
+ {
+ if (strcmp (language_string, "GNU Go") == 0)
+ language = DW_LANG_Go;
+ }
}
add_AT_unsigned (die, DW_AT_language, language);
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))
{
/* Prevent broken recursion; we can't hand off to the same type. */
gcc_assert (DECL_ORIGINAL_TYPE (TYPE_NAME (type)) != type);
- /* Use the DIE of the containing namespace as the parent DIE of
- the type description DIE we want to generate. */
- if (DECL_CONTEXT (TYPE_NAME (type))
- && TREE_CODE (DECL_CONTEXT (TYPE_NAME (type))) == NAMESPACE_DECL)
- context_die = get_context_die (DECL_CONTEXT (TYPE_NAME (type)));
+ /* Give typedefs the right scope. */
+ context_die = scope_die_for (type, context_die);
TREE_ASM_WRITTEN (type) = 1;
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
{
char loclabel[MAX_ARTIFICIAL_LABEL_BYTES + 2];
struct var_loc_node *newloc;
- rtx next_real;
+ rtx next_real, next_note;
static const char *last_label;
static const char *last_postcall_label;
static bool last_in_cold_section_p;
+ static rtx expected_next_loc_note;
tree decl;
bool var_loc_p;
if (var_loc_p && !DECL_P (NOTE_VAR_LOCATION_DECL (loc_note)))
return;
- next_real = next_real_insn (loc_note);
+ /* Optimize processing a large consecutive sequence of location
+ notes so we don't spend too much time in next_real_insn. If the
+ next insn is another location note, remember the next_real_insn
+ calculation for next time. */
+ next_real = cached_next_real_insn;
+ if (next_real)
+ {
+ if (expected_next_loc_note != loc_note)
+ next_real = NULL_RTX;
+ }
+
+ next_note = NEXT_INSN (loc_note);
+ if (! next_note
+ || INSN_DELETED_P (next_note)
+ || GET_CODE (next_note) != NOTE
+ || (NOTE_KIND (next_note) != NOTE_INSN_VAR_LOCATION
+ && NOTE_KIND (next_note) != NOTE_INSN_CALL_ARG_LOCATION))
+ next_note = NULL_RTX;
+
+ if (! next_real)
+ next_real = next_real_insn (loc_note);
+
+ if (next_note)
+ {
+ expected_next_loc_note = next_note;
+ cached_next_real_insn = next_real;
+ }
+ else
+ cached_next_real_insn = NULL_RTX;
/* If there are no instructions which would be affected by this note,
don't do anything. */
VEC_safe_push (dw_line_info_table_p, gc, separate_line_info, table);
}
+ if (DWARF2_ASM_LINE_DEBUG_INFO)
+ table->is_stmt = (cur_line_info_table
+ ? cur_line_info_table->is_stmt
+ : DWARF_LINE_DEFAULT_IS_STMT_START);
cur_line_info_table = table;
}
if (DWARF2_ASM_LINE_DEBUG_INFO)
{
/* Emit the .loc directive understood by GNU as. */
- fprintf (asm_out_file, "\t.loc %d %d 0", file_num, line);
+ /* "\t.loc %u %u 0 is_stmt %u discriminator %u",
+ file_num, line, is_stmt, discriminator */
+ fputs ("\t.loc ", asm_out_file);
+ fprint_ul (asm_out_file, file_num);
+ putc (' ', asm_out_file);
+ fprint_ul (asm_out_file, line);
+ putc (' ', asm_out_file);
+ putc ('0', asm_out_file);
+
if (is_stmt != table->is_stmt)
- fprintf (asm_out_file, " is_stmt %d", is_stmt ? 1 : 0);
+ {
+ fputs (" is_stmt ", asm_out_file);
+ putc (is_stmt ? '1' : '0', asm_out_file);
+ }
if (SUPPORTS_DISCRIMINATOR && discriminator != 0)
- fprintf (asm_out_file, " discriminator %d", discriminator);
- fputc ('\n', asm_out_file);
+ {
+ gcc_assert (discriminator > 0);
+ fputs (" discriminator ", asm_out_file);
+ fprint_ul (asm_out_file, (unsigned long) discriminator);
+ }
+ putc ('\n', asm_out_file);
}
else
{
macinfo_entry e;
e.code = DW_MACINFO_start_file;
e.lineno = lineno;
- e.info = xstrdup (filename);
+ e.info = ggc_strdup (filename);
VEC_safe_push (macinfo_entry, gc, macinfo_table, &e);
}
}
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;
}
e.code = DW_MACINFO_define;
e.lineno = lineno;
- e.info = xstrdup (buffer);;
+ e.info = ggc_strdup (buffer);
VEC_safe_push (macinfo_entry, gc, macinfo_table, &e);
}
}
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;
}
e.code = DW_MACINFO_undef;
e.lineno = lineno;
- e.info = xstrdup (buffer);
+ e.info = ggc_strdup (buffer);
VEC_safe_push (macinfo_entry, gc, macinfo_table, &e);
}
}
{
case DW_MACINFO_start_file:
fd = lookup_filename (ref->info);
- if (fd->filename == ref->info)
- fd->filename = ggc_strdup (fd->filename);
file_num = maybe_emit_file (fd);
dw2_asm_output_data (1, DW_MACINFO_start_file, "Start new file");
dw2_asm_output_data_uleb128 (ref->lineno,
/* 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);
linebuf_len = strlen (linebuf);
/* The group name format is: wmN.[<encoded filename>.]<lineno>.<md5sum> */
- grp_name = XNEWVEC (char, 4 + encoded_filename_len + linebuf_len + 1
- + 16 * 2 + 1);
+ grp_name = XALLOCAVEC (char, 4 + encoded_filename_len + linebuf_len + 1
+ + 16 * 2 + 1);
memcpy (grp_name, DWARF_OFFSET_SIZE == 4 ? "wm4." : "wm8.", 4);
tail = grp_name + 4;
if (encoded_filename_len)
inc = VEC_index (macinfo_entry, macinfo_table, idx - 1);
inc->code = DW_MACRO_GNU_transparent_include;
inc->lineno = 0;
- inc->info = grp_name;
+ inc->info = ggc_strdup (grp_name);
if (*macinfo_htab == NULL)
*macinfo_htab = htab_create (10, htab_macinfo_hash, htab_macinfo_eq, NULL);
/* Avoid emitting duplicates. */
slot = htab_find_slot (*macinfo_htab, inc, INSERT);
if (*slot != NULL)
{
- free (CONST_CAST (char *, inc->info));
inc->code = 0;
inc->info = NULL;
/* If such an entry has been used before, just emit
i++)
{
cur->code = 0;
- free (CONST_CAST (char *, cur->info));
cur->info = NULL;
}
}
break;
case DW_MACINFO_end_file:
if (!VEC_empty (macinfo_entry, files))
- {
- macinfo_entry *file = VEC_last (macinfo_entry, files);
- free (CONST_CAST (char *, file->info));
- VEC_pop (macinfo_entry, files);
- }
+ VEC_pop (macinfo_entry, files);
break;
case DW_MACINFO_define:
case DW_MACINFO_undef:
break;
}
output_macinfo_op (ref);
- /* For DW_MACINFO_start_file ref->info has been copied into files
- vector. */
- if (ref->code != DW_MACINFO_start_file)
- free (CONST_CAST (char *, ref->info));
ref->info = NULL;
ref->code = 0;
}
ref->lineno);
ASM_OUTPUT_LABEL (asm_out_file, label);
ref->code = 0;
- free (CONST_CAST (char *, ref->info));
ref->info = NULL;
dw2_asm_output_data (2, 4, "DWARF macro version number");
if (DWARF_OFFSET_SIZE == 8)
case DW_MACINFO_undef:
output_macinfo_op (ref);
ref->code = 0;
- free (CONST_CAST (char *, ref->info));
ref->info = NULL;
break;
default:
inlined and optimized out. In that case we are lost and
assign the empty child. This should not be big issue as
the function is likely unreachable too. */
- tree context = NULL_TREE;
-
gcc_assert (node->created_for);
if (DECL_P (node->created_for))
- context = DECL_CONTEXT (node->created_for);
+ origin = get_context_die (DECL_CONTEXT (node->created_for));
else if (TYPE_P (node->created_for))
- context = TYPE_CONTEXT (node->created_for);
-
- gcc_assert (context
- && (TREE_CODE (context) == FUNCTION_DECL
- || TREE_CODE (context) == NAMESPACE_DECL));
-
- origin = lookup_decl_die (context);
- if (origin)
- add_child_die (origin, die);
+ origin = scope_die_for (node->created_for, comp_unit_die ());
else
- add_child_die (comp_unit_die (), die);
+ origin = comp_unit_die ();
+
+ add_child_die (origin, die);
}
}
}
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");
}