+2020-03-26 Tom Tromey <tom@tromey.com>
+
+ * dwarf2/die.h (struct die_info) <addr_base, ranges_base>:
+ Rewrite.
+
2020-03-26 Tom Tromey <tom@tromey.com>
* dwarf2/die.h (struct die_info) <addr_base, ranges_base>: New
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
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;
}