This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH RFC: Fix PR debug/26964: Avoid duplicate debug info for enums
- From: Ian Lance Taylor <iant at google dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: 21 Dec 2006 16:48:05 -0800
- Subject: PATCH RFC: Fix PR debug/26964: Avoid duplicate debug info for enums
This is a patch for PR debug/26964, which I reported about generating
duplicate debug info for enum constants defined in a namespace. From
the PR, a case like this
namespace { enum x { i = 1 }; }
x y;
generates duplicate information for the enum constant 'i'. This type
of enum definition occurs quite a lot in libstdc++ header files. If
you look at readelf --debug-dump of a file with libstdc++ debugging
info, you will see a lot of duplication in the DW_TAG_enumerator
lists.
I plan to check this in a couple of days to mainline. I'm waiting to
see if anybody has any comments before I commit it.
I believe this is appropriate for the 4.1 and 4.2 branches as well.
It is arguably a regression in debug info size. I will commit it to
those branches as well unless somebody objects.
Tested with bootstrap and testsuite run on i686-pc-linux-gnu.
Ian
2006-12-21 Ian Lance Taylor <iant@google.com>
PR debug/26964
* dwarf2out.c (gen_type_die): Don't write out a DIE for
ENUMERAL_TYPE if it was already written out.
Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c (revision 120114)
+++ gcc/dwarf2out.c (working copy)
@@ -12727,7 +12727,12 @@ gen_type_die (tree type, dw_die_ref cont
}
if (TREE_CODE (type) == ENUMERAL_TYPE)
- gen_enumeration_type_die (type, context_die);
+ {
+ /* This might have been written out by the call to
+ declare_in_namespace. */
+ if (!TREE_ASM_WRITTEN (type))
+ gen_enumeration_type_die (type, context_die);
+ }
else
gen_struct_or_union_type_die (type, context_die);