aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-03-26 09:28:08 -0600
committerTom Tromey <tom@tromey.com>2020-03-26 09:28:26 -0600
commiteeb647814fbfd71dddea45f36cb4847341f5cde7 (patch)
treeea50e03859b54fe84ea4fdda4078c595eae66d05 /gdb/dwarf2
parenta39fdb411d43824b27d886bab42cada62a9fe431 (diff)
downloadfsf-binutils-gdb-eeb647814fbfd71dddea45f36cb4847341f5cde7.zip
fsf-binutils-gdb-eeb647814fbfd71dddea45f36cb4847341f5cde7.tar.gz
fsf-binutils-gdb-eeb647814fbfd71dddea45f36cb4847341f5cde7.tar.bz2
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 <tom@tromey.com> * dwarf2/die.h (struct die_info) <addr_base, ranges_base>: Rewrite.
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r--gdb/dwarf2/die.h28
1 files changed, 16 insertions, 12 deletions
diff --git a/gdb/dwarf2/die.h b/gdb/dwarf2/die.h
index c358664..5522ebd 100644
--- a/gdb/dwarf2/die.h
+++ b/gdb/dwarf2/die.h
@@ -38,12 +38,14 @@ struct die_info
DW_AT_addr_base. */
gdb::optional<ULONGEST> 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<ULONGEST> ();
- 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<ULONGEST> ();
}
/* 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;
}