This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA Fission supplement #1] Handle debug_info inter-cu type references
- From: dje at google dot com (Doug Evans)
- To: gdb-patches at sourceware dot org
- Cc: ccoutant at google dot com, saugustine at google dot com
- Date: Mon, 23 Apr 2012 13:11:48 -0700 (PDT)
- Subject: [RFA Fission supplement #1] Handle debug_info inter-cu type references
Hi.
This bug was caught by testing an update of my Go language port
on top of the Fission patch.
Now that the CU is used in the die type lookup hash,
inter-cu references in .debug_info are missed and the assert triggers.
Note that using the CU in the die type hash is more than just a bug
fix for .debug_types (ref: PR 13627).
A follow on Fission patch will support combined DWO files into one file
(a "DWP" file), and it may have multiple .debug_info sections
(thus they'll have the same problem).
This patch tweaks dw2-intercu.{S,exp} to expose the bug.
2012-04-23 Doug Evans <dje@google.com>
* dwarf2read.c (lookup_die_type): Remove assert. Condition can
legimately happen for inter-cu type references.
testsuite/
* gdb.dwarf2/dw2-intercu.S (.Ltype_int2_in_cu2): Renamed from
.Ltype_int_in_cu2. Use name "int2" instead of "int".
All uses updated.
* gdb.dwarf2/dw2-intercu.exp: Add "ptype int2" ahead of
"ptype func_cu1" to expand cu2 before cu1.
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.638
diff -u -p -r1.638 dwarf2read.c
--- dwarf2read.c 23 Apr 2012 16:46:02 -0000 1.638
+++ dwarf2read.c 23 Apr 2012 20:08:55 -0000
@@ -12344,9 +12344,12 @@ lookup_die_type (struct die_info *die, s
struct dwarf2_cu *type_cu = cu;
type_die = follow_die_ref_or_sig (die, attr, &type_cu);
- /* If the type is cached, we should have found it above. */
- gdb_assert (get_die_type (type_die, type_cu) == NULL);
- this_type = read_type_die_1 (type_die, type_cu);
+ /* If we found the type now, it's probably because the type came
+ from an inter-CU reference and the type's CU got expanded before
+ ours. */
+ this_type = get_die_type (type_die, type_cu);
+ if (this_type == NULL)
+ this_type = read_type_die_1 (type_die, type_cu);
}
/* If we still don't have a type use an error marker. */
Index: testsuite/gdb.dwarf2/dw2-intercu.S
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.dwarf2/dw2-intercu.S,v
retrieving revision 1.10
diff -u -p -r1.10 dw2-intercu.S
--- testsuite/gdb.dwarf2/dw2-intercu.S 4 Jan 2012 08:17:51 -0000 1.10
+++ testsuite/gdb.dwarf2/dw2-intercu.S 23 Apr 2012 20:08:55 -0000
@@ -58,7 +58,7 @@ func_cu1:
.byte 1 /* DW_AT_decl_file */
.byte 2 /* DW_AT_decl_line */
.ascii "func_cu1\0" /* DW_AT_name */
- .4byte .Ltype_int_in_cu2 /* DW_AT_type */
+ .4byte .Ltype_int2_in_cu2 /* DW_AT_type */
.4byte .Lbegin_func_cu1 /* DW_AT_low_pc */
.4byte .Lend_func_cu1 /* DW_AT_high_pc */
.byte 1 /* DW_AT_frame_base: length */
@@ -83,9 +83,12 @@ func_cu1:
.ascii "GNU C 3.3.3\0" /* DW_AT_producer */
.byte 1 /* DW_AT_language (C) */
-.Ltype_int_in_cu2:
+ /* This type is named "int2" and not "int" to ensure it is unique,
+ and thus we can easily ensure we expand this CU and not some
+ other CU with "int". */
+.Ltype_int2_in_cu2:
.uleb128 2 /* Abbrev: DW_TAG_base_type */
- .ascii "int\0" /* DW_AT_name */
+ .ascii "int2\0" /* DW_AT_name */
.byte 4 /* DW_AT_byte_size */
.byte 5 /* DW_AT_encoding */
Index: testsuite/gdb.dwarf2/dw2-intercu.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.dwarf2/dw2-intercu.exp,v
retrieving revision 1.12
diff -u -p -r1.12 dw2-intercu.exp
--- testsuite/gdb.dwarf2/dw2-intercu.exp 4 Jan 2012 08:17:51 -0000 1.12
+++ testsuite/gdb.dwarf2/dw2-intercu.exp 23 Apr 2012 20:08:55 -0000
@@ -45,8 +45,15 @@ gdb_load ${binfile}
set remote_dwarf_srcfile [remote_download host ${srcdir}/${subdir}/${dwarf_srcfile}]
+# This needs to be done first so that the CU for int2 gets expanded first.
+# This exercises the case where the type for this die is hashed, but we
+# need to perform the inter-cu lookup before looking the type up in the
+# hash table.
+gdb_test "ptype int2" "type = int2"
+
gdb_test_no_output "set listsize 1"
gdb_test "list func_cu1" "4\[ \t\]+File 1 Line 4"
-gdb_test "ptype func_cu1" "type = int \\(\\)"
+
+gdb_test "ptype func_cu1" "type = int2 \\(\\)"
remote_file host delete ${remote_dwarf_srcfile}