From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 9465E384B0CA; Thu, 28 Apr 2022 15:43:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9465E384B0CA 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] Check OBJF_NOT_FILENAME in DWARF index code X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 0d1703b8fb611f978577a70ad6aa308a12a53980 X-Git-Newrev: 9dd9f9ce1e231ef594845f11c05a724653241b58 Message-Id: <20220428154346.9465E384B0CA@sourceware.org> Date: Thu, 28 Apr 2022 15:43:46 +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: Thu, 28 Apr 2022 15:43:46 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D9dd9f9ce1e23= 1ef594845f11c05a724653241b58 commit 9dd9f9ce1e231ef594845f11c05a724653241b58 Author: Tom Tromey Date: Tue Apr 26 12:45:07 2022 -0600 Check OBJF_NOT_FILENAME in DWARF index code =20 The DWARF index code currently uses 'stat' to see if an objfile represents a real file. However, I think it's more correct to check OBJF_NOT_FILENAME instead. =20 Regression tested on x86-64 Fedora 34. Diff: --- gdb/dwarf2/index-cache.c | 4 ++++ gdb/dwarf2/index-write.c | 9 +++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/gdb/dwarf2/index-cache.c b/gdb/dwarf2/index-cache.c index fb827e04e59..a1f6ff59634 100644 --- a/gdb/dwarf2/index-cache.c +++ b/gdb/dwarf2/index-cache.c @@ -96,6 +96,10 @@ index_cache::store (dwarf2_per_objfile *per_objfile) if (!enabled ()) return; =20 + /* If the objfile does not correspond to an actual file, skip it. */ + if ((obj->flags & OBJF_NOT_FILENAME) !=3D 0) + return; + /* Get build id of objfile. */ const bfd_build_id *build_id =3D build_id_bfd_get (obj->obfd); if (build_id =3D=3D nullptr) diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index afe55da6c1b..3d1c78d4459 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -1411,9 +1411,8 @@ write_dwarf_index (dwarf2_per_objfile *per_objfile, c= onst char *dir, if (per_objfile->per_bfd->types.size () > 1) error (_("Cannot make an index when the file has multiple .debug_types= sections")); =20 - struct stat st; - if (stat (objfile_name (objfile), &st) < 0) - perror_with_name (objfile_name (objfile)); + + gdb_assert ((objfile->flags & OBJF_NOT_FILENAME) =3D=3D 0); =20 const char *index_suffix =3D (index_kind =3D=3D dw_index_kind::DEBUG_NAM= ES ? INDEX5_SUFFIX : INDEX4_SUFFIX); @@ -1472,10 +1471,8 @@ save_gdb_index_command (const char *arg, int from_tt= y) =20 for (objfile *objfile : current_program_space->objfiles ()) { - struct stat st; - /* If the objfile does not correspond to an actual file, skip it. */ - if (stat (objfile_name (objfile), &st) < 0) + if ((objfile->flags & OBJF_NOT_FILENAME) !=3D 0) continue; =20 dwarf2_per_objfile *per_objfile =3D get_dwarf2_per_objfile (objfile);