===================================================================
@@ -31,7 +31,7 @@ struct gcc_debug_hooks
void (* finish) (const char *main_filename);
/* Run cleanups necessary after early debug generation. */
- void (* early_finish) (void);
+ void (* early_finish) (const char *main_filename);
/* Called from cgraph_optimize before starting to assemble
functions/variables/toplevel asms. */
===================================================================
@@ -354,7 +354,7 @@ const struct gcc_debug_hooks dbx_debug_h
{
dbxout_init,
dbxout_finish,
- debug_nothing_void,
+ debug_nothing_charstar,
debug_nothing_void,
debug_nothing_int_charstar,
debug_nothing_int_charstar,
===================================================================
@@ -28,7 +28,7 @@ const struct gcc_debug_hooks do_nothing_
{
debug_nothing_charstar,
debug_nothing_charstar,
- debug_nothing_void, /* early_finish */
+ debug_nothing_charstar, /* early_finish */
debug_nothing_void,
debug_nothing_int_charstar,
debug_nothing_int_charstar,
===================================================================
@@ -278,7 +278,7 @@ const struct gcc_debug_hooks sdb_debug_h
{
sdbout_init, /* init */
sdbout_finish, /* finish */
- debug_nothing_void, /* early_finish */
+ debug_nothing_charstar, /* early_finish */
debug_nothing_void, /* assembly_start */
debug_nothing_int_charstar, /* define */
debug_nothing_int_charstar, /* undef */
===================================================================
@@ -147,6 +147,7 @@ static int write_srccorrs (int);
static void vmsdbgout_init (const char *);
static void vmsdbgout_finish (const char *);
+static void vmsdbgout_early_finish (const char *);
static void vmsdbgout_assembly_start (void);
static void vmsdbgout_define (unsigned int, const char *);
static void vmsdbgout_undef (unsigned int, const char *);
@@ -174,7 +175,7 @@ static void vmsdbgout_abstract_function
const struct gcc_debug_hooks vmsdbg_debug_hooks
= {vmsdbgout_init,
vmsdbgout_finish,
- debug_nothing_void,
+ vmsdbgout_early_finish,
vmsdbgout_assembly_start,
vmsdbgout_define,
vmsdbgout_undef,
@@ -1549,6 +1550,16 @@ vmsdbgout_abstract_function (tree decl)
}
/* Output stuff that Debug requires at the end of every file and generate the
+ VMS Debug debugging info. */
+
+static void
+vmsdbgout_early_finish (const char *filename ATTRIBUTE_UNUSED)
+{
+ if (write_symbols == VMS_AND_DWARF2_DEBUG)
+ (*dwarf2_debug_hooks.early_finish) (filename);
+}
+
+/* Output stuff that Debug requires at the end of every file and generate the
VMS Debug debugging info. */
static void
===================================================================
@@ -2420,7 +2420,7 @@ build_cfa_aligned_loc (dw_cfa_location *
static void dwarf2out_init (const char *);
static void dwarf2out_finish (const char *);
-static void dwarf2out_early_finish (void);
+static void dwarf2out_early_finish (const char *);
static void dwarf2out_assembly_start (void);
static void dwarf2out_define (unsigned int, const char *);
static void dwarf2out_undef (unsigned int, const char *);
@@ -2494,7 +2494,7 @@ const struct gcc_debug_hooks dwarf2_line
{
dwarf2out_init,
debug_nothing_charstar,
- debug_nothing_void,
+ debug_nothing_charstar,
debug_nothing_void,
debug_nothing_int_charstar,
debug_nothing_int_charstar,
@@ -25128,46 +25128,77 @@ optimize_location_lists (dw_die_ref die)
optimize_location_lists_1 (die, &htab);
}
+/* Traverse the limbo die list, and add parent/child links. The only
+ dies without parents that should be here are concrete instances of
+ inline functions, and the comp_unit_die. We can ignore the comp_unit_die.
+ For concrete instances, we can get the parent die from the abstract
+ instance. */
+
+static void
+flush_limbo_die_list (void)
+{
+ limbo_die_node *node, *next_node;
+
+ for (node = limbo_die_list; node; node = next_node)
+ {
+ dw_die_ref die = node->die;
+ next_node = node->next;
+
+ if (die->die_parent == NULL)
+ {
+ dw_die_ref origin = get_AT_ref (die, DW_AT_abstract_origin);
+
+ if (origin && origin->die_parent)
+ add_child_die (origin->die_parent, die);
+ else if (is_cu_die (die))
+ ;
+ else if (seen_error ())
+ /* It's OK to be confused by errors in the input. */
+ add_child_die (comp_unit_die (), die);
+ else
+ {
+ /* 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.
+
+ It may happen that even the containing function got fully
+ 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. */
+ gcc_assert (node->created_for);
+
+ if (DECL_P (node->created_for))
+ origin = get_context_die (DECL_CONTEXT (node->created_for));
+ else if (TYPE_P (node->created_for))
+ origin = scope_die_for (node->created_for, comp_unit_die ());
+ else
+ origin = comp_unit_die ();
+
+ add_child_die (origin, die);
+ }
+ }
+ }
+
+ limbo_die_list = NULL;
+}
+
/* Output stuff that dwarf requires at the end of every file,
and generate the DWARF-2 debugging info. */
static void
-dwarf2out_finish (const char *filename)
+dwarf2out_finish (const char *)
{
comdat_type_node *ctnode;
dw_die_ref main_comp_unit_die;
/* Flush out any latecomers to the limbo party. */
- dwarf2out_early_finish ();
+ flush_limbo_die_list ();
- /* PCH might result in DW_AT_producer string being restored from the
- header compilation, so always fill it with empty string initially
- and overwrite only here. */
- dw_attr_ref producer = get_AT (comp_unit_die (), DW_AT_producer);
- producer_string = gen_producer_string ();
- producer->dw_attr_val.v.val_str->refcount--;
- producer->dw_attr_val.v.val_str = find_AT_string (producer_string);
-
- gen_scheduled_generic_parms_dies ();
- gen_remaining_tmpl_value_param_die_attribute ();
-
- /* Add the name for the main input file now. We delayed this from
- dwarf2out_init to avoid complications with PCH.
- For LTO produced units use a fixed artificial name to avoid
- leaking tempfile names into the dwarf. */
- if (!in_lto_p)
- add_name_attribute (comp_unit_die (), remap_debug_filename (filename));
- else
- add_name_attribute (comp_unit_die (), "<artificial>");
- if (!IS_ABSOLUTE_PATH (filename) || targetm.force_at_comp_dir)
- add_comp_dir_attribute (comp_unit_die ());
- else if (get_AT (comp_unit_die (), DW_AT_comp_dir) == NULL)
- {
- bool p = false;
- file_table->traverse<bool *, file_table_relative_p> (&p);
- if (p)
- add_comp_dir_attribute (comp_unit_die ());
- }
+ /* We shouldn't have any symbols with delayed asm names for
+ DIEs generated after early finish. */
+ gcc_assert (deferred_asm_name == NULL);
#if ENABLE_ASSERT_CHECKING
{
@@ -25482,9 +25513,9 @@ dwarf2out_finish (const char *filename)
has run. */
static void
-dwarf2out_early_finish (void)
+dwarf2out_early_finish (const char *filename)
{
- limbo_die_node *node, *next_node;
+ limbo_die_node *node;
/* Add DW_AT_linkage_name for all deferred DIEs. */
for (node = deferred_asm_name; node; node = node->next)
@@ -25502,57 +25533,38 @@ dwarf2out_early_finish (void)
}
deferred_asm_name = NULL;
- /* Traverse the limbo die list, and add parent/child links. The only
- dies without parents that should be here are concrete instances of
- inline functions, and the comp_unit_die. We can ignore the comp_unit_die.
- For concrete instances, we can get the parent die from the abstract
- instance.
-
- The point here is to flush out the limbo list so that it is empty
+ /* The point here is to flush out the limbo list so that it is empty
and we don't need to stream it for LTO. */
- for (node = limbo_die_list; node; node = next_node)
- {
- dw_die_ref die = node->die;
- next_node = node->next;
+ flush_limbo_die_list ();
- if (die->die_parent == NULL)
- {
- dw_die_ref origin = get_AT_ref (die, DW_AT_abstract_origin);
-
- if (origin && origin->die_parent)
- add_child_die (origin->die_parent, die);
- else if (is_cu_die (die))
- ;
- else if (seen_error ())
- /* It's OK to be confused by errors in the input. */
- add_child_die (comp_unit_die (), die);
- else
- {
- /* 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.
-
- It may happen that even the containing function got fully
- 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. */
- gcc_assert (node->created_for);
+ /* PCH might result in DW_AT_producer string being restored from the
+ header compilation, so always fill it with empty string initially
+ and overwrite only here. */
+ dw_attr_ref producer = get_AT (comp_unit_die (), DW_AT_producer);
+ producer_string = gen_producer_string ();
+ producer->dw_attr_val.v.val_str->refcount--;
+ producer->dw_attr_val.v.val_str = find_AT_string (producer_string);
- if (DECL_P (node->created_for))
- origin = get_context_die (DECL_CONTEXT (node->created_for));
- else if (TYPE_P (node->created_for))
- origin = scope_die_for (node->created_for, comp_unit_die ());
- else
- origin = comp_unit_die ();
+ gen_scheduled_generic_parms_dies ();
+ gen_remaining_tmpl_value_param_die_attribute ();
- add_child_die (origin, die);
- }
- }
+ /* Add the name for the main input file now. We delayed this from
+ dwarf2out_init to avoid complications with PCH.
+ For LTO produced units use a fixed artificial name to avoid
+ leaking tempfile names into the dwarf. */
+ if (!in_lto_p)
+ add_name_attribute (comp_unit_die (), remap_debug_filename (filename));
+ else
+ add_name_attribute (comp_unit_die (), "<artificial>");
+ if (!IS_ABSOLUTE_PATH (filename) || targetm.force_at_comp_dir)
+ add_comp_dir_attribute (comp_unit_die ());
+ else if (get_AT (comp_unit_die (), DW_AT_comp_dir) == NULL)
+ {
+ bool p = false;
+ file_table->traverse<bool *, file_table_relative_p> (&p);
+ if (p)
+ add_comp_dir_attribute (comp_unit_die ());
}
-
- limbo_die_list = NULL;
}
/* Reset all state within dwarf2out.c so that we can rerun the compiler
===================================================================
@@ -2490,7 +2490,7 @@ symbol_table::finalize_compilation_unit
/* Clean up anything that needs cleaning up after initial debug
generation. */
- (*debug_hooks->early_finish) ();
+ (*debug_hooks->early_finish) (main_input_filename);
/* Finally drive the pass manager. */
compile ();