From: Nick Clifton <nickc@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] Fix the BFD library's find_nearest_line feature to produce consistent results.
Date: Thu, 23 Feb 2023 09:47:23 +0000 (GMT) [thread overview]
Message-ID: <20230223094723.5F12A3858C5E@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e0b74a85b879354d2aa1a6b5026d5de58c78ec45
commit e0b74a85b879354d2aa1a6b5026d5de58c78ec45
Author: Nick Clifton <nickc@redhat.com>
Date: Thu Feb 23 09:44:50 2023 +0000
Fix the BFD library's find_nearest_line feature to produce consistent results.
PR 30150
* dwarf2.c (comp_unit_contains_address): Renamed to ... (comp_unit_may_contain_address): this,
and added code to return true if the CU's ranges have not yet been computed.
(_bfd_dwarf2_find_nearest_line_with_alt): Use the renamed function, simplifying code in the process.
Diff:
---
bfd/ChangeLog | 10 ++++++++++
bfd/dwarf2.c | 26 +++++++++++---------------
2 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index b8987211dd4..b7c03c11678 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,13 @@
+2023-02-23 Nick Clifton <nickc@redhat.com>
+ Alan Modra <amodra@gmail.com>
+
+ PR 30150
+ * dwarf2.c (comp_unit_contains_address): Renamed to ...
+ (comp_unit_may_contain_address): this, and added code to return
+ true if the CU's ranges have not yet been computed.
+ (_bfd_dwarf2_find_nearest_line_with_alt): Use the renamed
+ function, simplifying code in the process.
+
2023-02-21 Nick Clifton <nickc@redhat.com>
* opncls.c (bfd_fill_in_gnu_debuglink_section): Update
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index b16ae11e5f2..8c9bd7a3026 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -4643,21 +4643,20 @@ parse_comp_unit (struct dwarf2_debug *stash,
really contains the given address. */
static bool
-comp_unit_contains_address (struct comp_unit *unit, bfd_vma addr)
+comp_unit_may_contain_address (struct comp_unit *unit, bfd_vma addr)
{
struct arange *arange;
if (unit->error)
return false;
- arange = &unit->arange;
- do
- {
- if (addr >= arange->low && addr < arange->high)
- return true;
- arange = arange->next;
- }
- while (arange);
+ if (unit->arange.high == 0 /* No ranges have been computed yet. */
+ || unit->line_table == NULL) /* The line info table has not been loaded. */
+ return true;
+
+ for (arange = &unit->arange; arange != NULL; arange = arange->next)
+ if (addr >= arange->low && addr < arange->high)
+ return true;
return false;
}
@@ -5890,8 +5889,7 @@ _bfd_dwarf2_find_nearest_line_with_alt
/* Check the previously read comp. units first. */
for (each = stash->f.all_comp_units; each; each = each->next_unit)
if ((symbol->flags & BSF_FUNCTION) == 0
- || each->arange.high == 0
- || comp_unit_contains_address (each, addr))
+ || comp_unit_may_contain_address (each, addr))
{
found = comp_unit_find_line (each, symbol, addr, filename_ptr,
linenumber_ptr);
@@ -5973,13 +5971,11 @@ _bfd_dwarf2_find_nearest_line_with_alt
address. */
if (do_line)
found = (((symbol->flags & BSF_FUNCTION) == 0
- || each->arange.high == 0
- || comp_unit_contains_address (each, addr))
+ || comp_unit_may_contain_address (each, addr))
&& comp_unit_find_line (each, symbol, addr,
filename_ptr, linenumber_ptr));
else
- found = ((each->arange.high == 0
- || comp_unit_contains_address (each, addr))
+ found = (comp_unit_may_contain_address (each, addr)
&& comp_unit_find_nearest_line (each, addr,
filename_ptr,
&function,
reply other threads:[~2023-02-23 9:47 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=20230223094723.5F12A3858C5E@sourceware.org \
--to=nickc@sourceware.org \
--cc=bfd-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: link
Be 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).