public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Rewrite new die_info methods Date: Thu, 26 Mar 2020 15:34:10 +0000 (GMT) [thread overview] Message-ID: <20200326153410.43DDE385F020@sourceware.org> (raw) 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; }
reply other threads:[~2020-03-26 15:34 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200326153410.43DDE385F020@sourceware.org \ --to=tromey@sourceware.org \ --cc=gdb-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).