aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2011-12-31 17:18:13 +0000
committerDoug Evans <dje@google.com>2011-12-31 17:18:13 +0000
commit3c8e0968a5264c7793a09794a12a26b4c9976cc6 (patch)
tree95f36aa3847b332f316f8a8acda673b3251c1a3b
parentb909d38dfa0fd09dcbcead07b61e5ba3fedd6f7a (diff)
downloadgdb-3c8e0968a5264c7793a09794a12a26b4c9976cc6.zip
gdb-3c8e0968a5264c7793a09794a12a26b4c9976cc6.tar.gz
gdb-3c8e0968a5264c7793a09794a12a26b4c9976cc6.tar.bz2
* dwarf2read.c (read_typedef): Guard against self-referential typedefs.
-rw-r--r--gdb/ChangeLog4
-rw-r--r--gdb/dwarf2read.c16
2 files changed, 18 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 40f6169..5ef00d9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2011-12-30 Doug Evans <dje@google.com>
+
+ * dwarf2read.c (read_typedef): Guard against self-referential typedefs.
+
2011-12-28 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdbarch.sh (max_insn_length): Extend the comment by unit.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 31ea14e..cee021c 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -8836,14 +8836,26 @@ read_typedef (struct die_info *die, struct dwarf2_cu *cu)
{
struct objfile *objfile = cu->objfile;
const char *name = NULL;
- struct type *this_type;
+ struct type *this_type, *target_type;
name = dwarf2_full_name (NULL, die, cu);
this_type = init_type (TYPE_CODE_TYPEDEF, 0,
TYPE_FLAG_TARGET_STUB, NULL, objfile);
TYPE_NAME (this_type) = (char *) name;
set_die_type (die, this_type, cu);
- TYPE_TARGET_TYPE (this_type) = die_type (die, cu);
+ target_type = die_type (die, cu);
+ if (target_type != this_type)
+ TYPE_TARGET_TYPE (this_type) = target_type;
+ else
+ {
+ /* Self-referential typedefs are, it seems, not allowed by the DWARF
+ spec and cause infinite loops in GDB. */
+ complaint (&symfile_complaints,
+ _("Self-referential DW_TAG_typedef "
+ "- DIE at 0x%x [in module %s]"),
+ die->offset, cu->objfile->name);
+ TYPE_TARGET_TYPE (this_type) = NULL;
+ }
return this_type;
}