From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 9CA49386CE7D; Sat, 25 Jun 2022 17:10:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9CA49386CE7D Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Fix end of CU calculation in cooked_indexer::index_dies X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: af6e3f77e939ecf85e18720925a4d8f355f90ee1 X-Git-Newrev: a858187afda380dd0bd9479f58c152178e275903 Message-Id: <20220625171030.9CA49386CE7D@sourceware.org> Date: Sat, 25 Jun 2022 17:10:30 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Jun 2022 17:10:30 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Da858187afda3= 80dd0bd9479f58c152178e275903 commit a858187afda380dd0bd9479f58c152178e275903 Author: Tom Tromey Date: Thu Jun 9 07:21:24 2022 -0600 Fix end of CU calculation in cooked_indexer::index_dies =20 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. Diff: --- gdb/dwarf2/read.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index e22e09b4e2b..80bb2929435 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 =3D info_ptr + reader->cu->header.get_length (); + const gdb_byte *end_ptr =3D (reader->buffer + + to_underlying (reader->cu->header.sect_off) + + reader->cu->header.get_length ()); =20 while (info_ptr < end_ptr) {