From: Tom Tromey Date: Thu, 26 Mar 2020 15:28:08 +0000 (-0600) Subject: Rewrite new die_info methods X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=eeb647814fbfd71dddea45f36cb4847341f5cde7;p=binutils-gdb.git Rewrite new die_info methods This rewrites the two new die_info methods to iterate over attributes rather than to do two separate searches. gdb/ChangeLog 2020-03-26 Tom Tromey * dwarf2/die.h (struct die_info) : Rewrite. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b8190a1381e..670f7f6c25b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-03-26 Tom Tromey + + * dwarf2/die.h (struct die_info) : + Rewrite. + 2020-03-26 Tom Tromey * dwarf2/die.h (struct die_info) : New diff --git a/gdb/dwarf2/die.h b/gdb/dwarf2/die.h index c3586645bd6..5522ebdf311 100644 --- a/gdb/dwarf2/die.h +++ b/gdb/dwarf2/die.h @@ -38,12 +38,14 @@ struct die_info DW_AT_addr_base. */ gdb::optional addr_base () { - struct attribute *attr = this->attr (DW_AT_addr_base); - if (attr == nullptr) - attr = this->attr (DW_AT_GNU_addr_base); - if (attr == nullptr) - return gdb::optional (); - return DW_UNSND (attr); + for (unsigned i = 0; i < num_attrs; ++i) + if (attrs[i].name == DW_AT_addr_base + || attrs[i].name == DW_AT_GNU_addr_base) + { + /* If both exist, just use the first one. */ + return DW_UNSND (&attrs[i]); + } + return gdb::optional (); } /* Return range lists base of the compile unit, which, if exists, is @@ -51,12 +53,14 @@ struct die_info DW_AT_GNU_ranges_base. */ ULONGEST ranges_base () { - struct attribute *attr = this->attr (DW_AT_rnglists_base); - if (attr == nullptr) - attr = this->attr (DW_AT_GNU_ranges_base); - if (attr == nullptr) - return 0; - return DW_UNSND (attr); + for (unsigned i = 0; i < num_attrs; ++i) + if (attrs[i].name == DW_AT_rnglists_base + || attrs[i].name == DW_AT_GNU_ranges_base) + { + /* If both exist, just use the first one. */ + return DW_UNSND (&attrs[i]); + } + return 0; }