This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch] Fix "Cannot find DIE" error with -gdwarf-4
- From: Cary Coutant <ccoutant at google dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 9 Nov 2009 13:31:32 -0800
- Subject: [patch] Fix "Cannot find DIE" error with -gdwarf-4
This patch fixes a problem in read_import_statement, where we get a
"Cannot find DIE" error when trying to process a DW_AT_import
attribute that refers to a DIE in a different CU. When finding the
referenced DIE, the current code clobbers the CU parameter, but later
calls determine_prefix(die, cu), assuming that CU is still the CU that
contains DIE.
I found this problem using -gdwarf-4 and DW_FORM_sig8, but I don't
think this problem was introduced with the support for type units. The
same problem could have occurred given a compiler that splits debug
info into separate compilation units by include file, using
DW_FORM_ref_addr to refer to a DIE in a different CU.
OK for trunk?
-cary
* dwarf2read.c (read_import_statement): Don't clobber original cu.
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.331
diff -u -p -r1.331 dwarf2read.c
--- dwarf2read.c 5 Nov 2009 23:18:00 -0000 1.331
+++ dwarf2read.c 9 Nov 2009 21:15:57 -0000
@@ -3372,6 +3372,7 @@ read_import_statement (struct die_info *
{
struct attribute *import_attr;
struct die_info *imported_die;
+ struct dwarf2_cu *imported_cu;
const char *imported_name;
const char *imported_name_prefix;
const char *import_prefix;
@@ -3385,8 +3386,9 @@ read_import_statement (struct die_info *
return;
}
- imported_die = follow_die_ref_or_sig (die, import_attr, &cu);
- imported_name = dwarf2_name (imported_die, cu);
+ imported_cu = cu;
+ imported_die = follow_die_ref_or_sig (die, import_attr, &imported_cu);
+ imported_name = dwarf2_name (imported_die, imported_cu);
if (imported_name == NULL)
{
/* GCC bug: https://bugzilla.redhat.com/show_bug.cgi?id=506524
@@ -3431,7 +3433,7 @@ read_import_statement (struct die_info *
/* Figure out what the scope of the imported die is and prepend it
to the name of the imported die. */
- imported_name_prefix = determine_prefix (imported_die, cu);
+ imported_name_prefix = determine_prefix (imported_die, imported_cu);
if (strlen (imported_name_prefix) > 0)
{