1 http://sourceware.org/ml/gdb-patches/2011-04/msg00154.html
2 Subject: [patch] Workaround buggy GCC PR 47510 produced code
6 GCC PR debug/47510 is already fixed and GDB has the proper support for it:
7 RFC: update for GCC PR 47510
8 http://sourceware.org/ml/gdb-patches/2011-03/msg00916.html
10 Still FSF GDB HEAD will crash on a binary produced by older/buggy GCC:
11 Reading symbols from .../gcc46.o...dwarf2read.c:9329: internal-error: could not find partial DIE 0x9a in cache [from module .../gcc46.o]
13 Which may not give much clue to the user.
15 The proposed patch could make false warnings if any code out there has
16 DW_TAG_typedef with children, it does not check for specific GCC versions.
17 Still such DWARF is invalid, although in such case complaint() would be more
18 appropriate than warning(). Does it make sense to differentiate it?
20 No regressions on {x86_64,x86_64-m32,i686}-fedora15-linux-gnu.
28 2011-04-11 Jan Kratochvil <jan.kratochvil@redhat.com>
30 * dwarf2read.c (struct dwarf2_per_objfile): New field
31 typedef_children_warning_printed.
32 (load_partial_dies): Read in any children of DW_TAG_typedef with
33 a warning in such case.
36 2011-04-11 Jan Kratochvil <jan.kratochvil@redhat.com>
38 * gdb.dwarf2/dw2-typedef-children.S: New file.
39 * gdb.dwarf2/dw2-typedef-children.exp: New file.
41 --- a/gdb/dwarf2read.c
42 +++ b/gdb/dwarf2read.c
43 @@ -209,6 +209,9 @@ struct dwarf2_per_objfile
44 or we are faking it for OBJF_READNOW's sake. */
45 unsigned char using_index;
47 + /* Print the GCC PR debug/47510 warning only once per objfile. */
48 + unsigned typedef_children_warning_printed : 1;
50 /* The mapped index, or NULL if .gdb_index is missing or not being used. */
51 struct mapped_index *index_table;
53 @@ -8951,7 +8954,7 @@ load_partial_dies (bfd *abfd, gdb_byte *buffer, gdb_byte *info_ptr,
54 if (parent_die == NULL
55 && part_die->has_specification == 0
56 && part_die->is_declaration == 0
57 - && (part_die->tag == DW_TAG_typedef
58 + && ((part_die->tag == DW_TAG_typedef && !part_die->has_children)
59 || part_die->tag == DW_TAG_base_type
60 || part_die->tag == DW_TAG_subrange_type))
62 @@ -8964,6 +8967,20 @@ load_partial_dies (bfd *abfd, gdb_byte *buffer, gdb_byte *info_ptr,
66 + /* The exception for DW_TAG_typedef with has_children above is
67 + a workaround of GCC PR debug/47510. GDB crashed on broken GCC output
68 + as it skipped children of DW_TAG_typedef by the shortcut above and
69 + then it could not find the child DIEs referenced later. */
71 + if (!dwarf2_per_objfile->typedef_children_warning_printed
72 + && part_die->tag == DW_TAG_typedef && part_die->has_children)
74 + warning (_("DW_TAG_typedef has childen - GCC PR debug/47510 bug "
75 + "- DIE at 0x%x [in module %s]"),
76 + part_die->offset, cu->objfile->name);
77 + dwarf2_per_objfile->typedef_children_warning_printed = 1;
80 /* If we're at the second level, and we're an enumerator, and
81 our parent has no specification (meaning possibly lives in a
82 namespace elsewhere), then we can add the partial symbol now
84 +++ b/gdb/testsuite/gdb.dwarf2/dw2-typedef-children.S
86 +/* This testcase is part of GDB, the GNU debugger.
88 + Copyright 2011 Free Software Foundation, Inc.
90 + This program is free software; you can redistribute it and/or modify
91 + it under the terms of the GNU General Public License as published by
92 + the Free Software Foundation; either version 3 of the License, or
93 + (at your option) any later version.
95 + This program is distributed in the hope that it will be useful,
96 + but WITHOUT ANY WARRANTY; without even the implied warranty of
97 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
98 + GNU General Public License for more details.
100 + You should have received a copy of the GNU General Public License
101 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
103 +/* Debug information */
105 + .section .debug_info
108 + .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
110 + .2byte 2 /* DWARF Version */
111 + .4byte .Labbrev1_begin /* Offset into abbrev section */
112 + .byte 4 /* Pointer size */
115 + .uleb128 1 /* Abbrev: DW_TAG_compile_unit */
116 + .ascii "file1.txt\0" /* DW_AT_name */
117 + .ascii "GNU C 3.3.3\0" /* DW_AT_producer */
118 + .byte 1 /* DW_AT_language (C) */
121 + .uleb128 2 /* Abbrev: DW_TAG_base_type */
122 + .ascii "int\0" /* DW_AT_name */
123 + .byte 4 /* DW_AT_byte_size */
124 + .byte 5 /* DW_AT_encoding */
126 + .uleb128 0x3 /* (DIE (0x38) DW_TAG_typedef) */
127 + .ascii "new\0" /* DW_AT_name */
128 + .long .Ltype_int - .Lcu1_begin /* DW_AT_type */
130 + .uleb128 2 /* Abbrev: DW_TAG_base_type */
131 + .ascii "int\0" /* DW_AT_name */
132 + .byte 4 /* DW_AT_byte_size */
133 + .byte 5 /* DW_AT_encoding */
135 + .uleb128 0 /* End of DW_TAG_typedef */
136 + .uleb128 0 /* End of DW_TAG_compile_unit */
140 + .section .debug_abbrev
142 + .uleb128 1 /* Abbrev code */
143 + .uleb128 0x11 /* DW_TAG_compile_unit */
144 + .byte 1 /* has_children */
145 + .uleb128 0x3 /* DW_AT_name */
146 + .uleb128 0x8 /* DW_FORM_string */
147 + .uleb128 0x25 /* DW_AT_producer */
148 + .uleb128 0x8 /* DW_FORM_string */
149 + .uleb128 0x13 /* DW_AT_language */
150 + .uleb128 0xb /* DW_FORM_data1 */
151 + .byte 0x0 /* Terminator */
152 + .byte 0x0 /* Terminator */
154 + .uleb128 2 /* Abbrev code */
155 + .uleb128 0x24 /* DW_TAG_base_type */
156 + .byte 0 /* has_children */
157 + .uleb128 0x3 /* DW_AT_name */
158 + .uleb128 0x8 /* DW_FORM_string */
159 + .uleb128 0xb /* DW_AT_byte_size */
160 + .uleb128 0xb /* DW_FORM_data1 */
161 + .uleb128 0x3e /* DW_AT_encoding */
162 + .uleb128 0xb /* DW_FORM_data1 */
163 + .byte 0x0 /* Terminator */
164 + .byte 0x0 /* Terminator */
166 + .uleb128 0x3 /* (abbrev code) */
167 + .uleb128 0x16 /* (TAG: DW_TAG_typedef) */
168 + .byte 0x1 /* DW_children_yes */
169 + .uleb128 0x3 /* (DW_AT_name) */
170 + .uleb128 0x8 /* (DW_FORM_string) */
171 + .uleb128 0x49 /* (DW_AT_type) */
172 + .uleb128 0x13 /* (DW_FORM_ref4) */
176 + .byte 0x0 /* Terminator */
177 + .byte 0x0 /* Terminator */
179 +++ b/gdb/testsuite/gdb.dwarf2/dw2-typedef-children.exp
181 +# Copyright 2011 Free Software Foundation, Inc.
183 +# This program is free software; you can redistribute it and/or modify
184 +# it under the terms of the GNU General Public License as published by
185 +# the Free Software Foundation; either version 3 of the License, or
186 +# (at your option) any later version.
188 +# This program is distributed in the hope that it will be useful,
189 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
190 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
191 +# GNU General Public License for more details.
193 +# You should have received a copy of the GNU General Public License
194 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
197 +# Note: Inspired from dw2-basic.exp.
199 +# This test can only be run on targets which support DWARF-2 and use gas.
200 +if {![dwarf2_support]} {
204 +set testfile "dw2-typedef-children"
205 +set srcfile ${testfile}.S
206 +set binfile ${objdir}/${subdir}/${testfile}.x
208 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {nodebug}] != "" } {
215 +gdb_test "file $binfile" \
216 + "warning: DW_TAG_typedef has childen - GCC PR debug/47510 bug - DIE at .*" \