Fix PR48703: segfault in mangler due to -g
Michael Matz
matz@suse.de
Wed Apr 20 16:35:00 GMT 2011
Hi,
as noted in the bug trail the fix for PR48207 broke compilation of C++
programs with -g. This variant fixes the bug too without breaking -g.
Basically we have to set assembler names early also for TYPE_DECLs, we
can't rely on the frontends langhook to do that after free_lang_data.
Okay for trunk assuming regstrapping on x86_64-linux works?
Ciao,
Michael.
------------------------
PR debug/48703
* dwarf2out.c (retry_incomplete_types): Export. Clear
incomplete_types.
* dwarf2out.h (retry_incomplete_types): Declare.
* tree.c (need_assembler_name_p): Also handle TYPE_DECLs.
(free_lang_data_in_cgraph): Call retry_incomplete_types.
(free_lang_data): Reset set_decl_assembler_name langhook.
* Makefile.in (tree.o): Depend on dwarf2out.h.
Index: tree.c
===================================================================
--- tree.c (revision 172769)
+++ tree.c (working copy)
@@ -61,6 +61,7 @@ along with GCC; see the file COPYING3.
#include "except.h"
#include "debug.h"
#include "intl.h"
+#include "dwarf2out.h"
/* Tree code classes. */
@@ -4500,7 +4501,8 @@ need_assembler_name_p (tree decl)
{
/* Only FUNCTION_DECLs and VAR_DECLs are considered. */
if (TREE_CODE (decl) != FUNCTION_DECL
- && TREE_CODE (decl) != VAR_DECL)
+ && TREE_CODE (decl) != VAR_DECL
+ && TREE_CODE (decl) != TYPE_DECL)
return false;
/* If DECL already has its assembler name set, it does not need a
@@ -4538,6 +4540,11 @@ need_assembler_name_p (tree decl)
return false;
}
+ if (TREE_CODE (decl) == TYPE_DECL)
+ {
+ if (TYPE_DECL_SUPPRESS_DEBUG (decl))
+ return false;
+ }
return true;
}
@@ -5111,6 +5118,8 @@ free_lang_data_in_cgraph (void)
FOR_EACH_VEC_ELT (tree, fld.decls, i, t)
assign_assembler_name_if_neeeded (t);
+ retry_incomplete_types ();
+
/* Traverse every decl found freeing its language data. */
FOR_EACH_VEC_ELT (tree, fld.decls, i, t)
free_lang_data_in_decl (t);
@@ -5182,6 +5191,7 @@ free_lang_data (void)
name and only produce assembler names for local symbols. Or rather
make sure we never call decl_assembler_name on local symbols and
devise a separate, middle-end private scheme for it. */
+ lang_hooks.set_decl_assembler_name = lhd_set_decl_assembler_name;
/* Reset diagnostic machinery. */
diagnostic_starter (global_dc) = default_tree_diagnostic_starter;
Index: dwarf2out.c
===================================================================
--- dwarf2out.c (revision 172769)
+++ dwarf2out.c (working copy)
@@ -6575,7 +6575,6 @@ static dw_die_ref force_type_die (tree);
static dw_die_ref setup_namespace_context (tree, dw_die_ref);
static dw_die_ref declare_in_namespace (tree, dw_die_ref);
static struct dwarf_file_data * lookup_filename (const char *);
-static void retry_incomplete_types (void);
static void gen_type_die_for_member (tree, tree, dw_die_ref);
static void gen_generic_params_dies (tree);
static void gen_tagged_type_die (tree, dw_die_ref, enum debug_info_usage);
@@ -18497,15 +18496,17 @@ gen_entry_point_die (tree decl, dw_die_r
/* Walk through the list of incomplete types again, trying once more to
emit full debugging info for them. */
-static void
+void
retry_incomplete_types (void)
{
int i;
-
- for (i = VEC_length (tree, incomplete_types) - 1; i >= 0; i--)
- if (should_emit_struct_debug (VEC_index (tree, incomplete_types, i),
+ VEC(tree,gc) *types = incomplete_types;
+ incomplete_types = NULL;
+ for (i = VEC_length (tree, types) - 1; i >= 0; i--)
+ if (should_emit_struct_debug (VEC_index (tree, types, i),
DINFO_USAGE_DIR_USE))
- gen_type_die (VEC_index (tree, incomplete_types, i), comp_unit_die ());
+ gen_type_die (VEC_index (tree, types, i), comp_unit_die ());
+ types = NULL;
}
/* Determine what tag to use for a record type. */
Index: dwarf2out.h
===================================================================
--- dwarf2out.h (revision 172769)
+++ dwarf2out.h (working copy)
@@ -25,6 +25,8 @@ extern void dwarf2out_cfi_begin_epilogue
extern void dwarf2out_frame_debug_restore_state (void);
extern void dwarf2out_flush_queued_reg_saves (void);
+extern void retry_incomplete_types (void);
+
extern void debug_dwarf (void);
struct die_struct;
extern void debug_dwarf_die (struct die_struct *);
Index: Makefile.in
===================================================================
--- Makefile.in (revision 172769)
+++ Makefile.in (working copy)
@@ -2354,7 +2354,7 @@ langhooks.o : langhooks.c $(CONFIG_H) $(
tree.o: tree.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
all-tree.def $(FLAGS_H) $(FUNCTION_H) $(PARAMS_H) \
toplev.h $(DIAGNOSTIC_CORE_H) $(GGC_H) $(HASHTAB_H) $(TARGET_H) output.h $(TM_P_H) \
- langhooks.h gt-tree.h $(TREE_INLINE_H) tree-iterator.h \
+ langhooks.h gt-tree.h $(TREE_INLINE_H) tree-iterator.h dwarf2out.h \
$(BASIC_BLOCK_H) $(TREE_FLOW_H) $(OBSTACK_H) pointer-set.h \
tree-pass.h $(LANGHOOKS_DEF_H) $(DIAGNOSTIC_H) $(CGRAPH_H) $(TIMEVAR_H) \
$(EXCEPT_H) debug.h intl.h tree-diagnostic.h tree-pretty-print.h
More information about the Gcc-patches
mailing list