From: Tom Tromey Date: Fri, 9 Mar 2012 20:06:18 +0000 (+0000) Subject: * dwarf2read.c (dwarf2_attr): Avoid tail-recursive call. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a48e046c37f9e3914710a4726db12ded2b9c939f;p=binutils-gdb.git * dwarf2read.c (dwarf2_attr): Avoid tail-recursive call. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index cb9127cc616..d458636951a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2012-03-09 Tom Tromey + + * dwarf2read.c (dwarf2_attr): Avoid tail-recursive call. + 2012-03-08 Joel Brobecker * ravenscar-sparc-thread.c (_initialize_ravenscar_sparc): Add diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 6eed8d53b08..91331788c99 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -10708,22 +10708,24 @@ set_cu_language (unsigned int lang, struct dwarf2_cu *cu) static struct attribute * dwarf2_attr (struct die_info *die, unsigned int name, struct dwarf2_cu *cu) { - unsigned int i; - struct attribute *spec = NULL; - - for (i = 0; i < die->num_attrs; ++i) + for (;;) { - if (die->attrs[i].name == name) - return &die->attrs[i]; - if (die->attrs[i].name == DW_AT_specification - || die->attrs[i].name == DW_AT_abstract_origin) - spec = &die->attrs[i]; - } + unsigned int i; + struct attribute *spec = NULL; + + for (i = 0; i < die->num_attrs; ++i) + { + if (die->attrs[i].name == name) + return &die->attrs[i]; + if (die->attrs[i].name == DW_AT_specification + || die->attrs[i].name == DW_AT_abstract_origin) + spec = &die->attrs[i]; + } + + if (!spec) + break; - if (spec) - { die = follow_die_ref (die, spec, &cu); - return dwarf2_attr (die, name, cu); } return NULL;