public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Rewrite new die_info methods
@ 2020-03-26 15:34 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2020-03-26 15:34 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=eeb647814fbfd71dddea45f36cb4847341f5cde7
commit eeb647814fbfd71dddea45f36cb4847341f5cde7
Author: Tom Tromey <tom@tromey.com>
Date: Thu Mar 26 09:28:08 2020 -0600
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.
Diff:
---
gdb/ChangeLog | 5 +++++
gdb/dwarf2/die.h | 28 ++++++++++++++++------------
2 files changed, 21 insertions(+), 12 deletions(-)
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 <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
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<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;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-03-26 15:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-26 15:34 [binutils-gdb] Rewrite new die_info methods Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).