aboutsummaryrefslogtreecommitdiff
path: root/bfd/dwarf2.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2023-02-23 09:44:50 +0000
committerNick Clifton <nickc@redhat.com>2023-02-23 09:44:50 +0000
commite0b74a85b879354d2aa1a6b5026d5de58c78ec45 (patch)
treedf6e80125aa53469eb30785576ae9f92c61be783 /bfd/dwarf2.c
parent456481c6d634819b713eb88fc629a09b4e955aa3 (diff)
downloadgdb-e0b74a85b879354d2aa1a6b5026d5de58c78ec45.zip
gdb-e0b74a85b879354d2aa1a6b5026d5de58c78ec45.tar.gz
gdb-e0b74a85b879354d2aa1a6b5026d5de58c78ec45.tar.bz2
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.
Diffstat (limited to 'bfd/dwarf2.c')
-rw-r--r--bfd/dwarf2.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index b16ae11..8c9bd7a 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,