aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2022-06-09 07:21:24 -0600
committerTom Tromey <tom@tromey.com>2022-06-25 10:58:16 -0600
commita858187afda380dd0bd9479f58c152178e275903 (patch)
tree1ab83eeda73d37e6539dcbfab58789fdd00b42e9 /gdb
parentaf6e3f77e939ecf85e18720925a4d8f355f90ee1 (diff)
downloadgdb-a858187afda380dd0bd9479f58c152178e275903.zip
gdb-a858187afda380dd0bd9479f58c152178e275903.tar.gz
gdb-a858187afda380dd0bd9479f58c152178e275903.tar.bz2
Fix end of CU calculation in cooked_indexer::index_dies
cooked_indexer::index_dies incorrect computes the end of the current CU in the .debug_info. This isn't readily testable without writing intentionally corrupt DWARF, but it's apparent through observation: it is currently based on 'info_ptr', which does not always point to the start of the CU. This patch fixes the expression. Tested on x86-64 Fedora 34.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/dwarf2/read.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index e22e09b..80bb292 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -18283,7 +18283,9 @@ cooked_indexer::index_dies (cutu_reader *reader,
const cooked_index_entry *parent_entry,
bool fully)
{
- const gdb_byte *end_ptr = info_ptr + reader->cu->header.get_length ();
+ const gdb_byte *end_ptr = (reader->buffer
+ + to_underlying (reader->cu->header.sect_off)
+ + reader->cu->header.get_length ());
while (info_ptr < end_ptr)
{