From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id oV+eG/TN82oOsAAAWB0awg (envelope-from ) for ; Tue, 10 Nov 2026 21:07:48 -0500 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=D5JBIiKp; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 6C3B6378002; Tue, 10 Nov 2026 21:07:48 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 40D511E043 for ; Tue, 10 Nov 2026 21:07:47 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AFAED4BA798A for ; Wed, 11 Nov 2026 02:07:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AFAED4BA798A Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=D5JBIiKp Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id 3DBB24BA2E22 for ; Wed, 11 Nov 2026 02:07:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3DBB24BA2E22 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3DBB24BA2E22 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=44.202.169.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794362825; cv=none; b=x7Jz8vgTrD70YoFAIA0DmKZvyfojmTZcp/qrfvBeNFqgHEiaC/R2kXBJJQTUIGqi85n054GdK9tZaKbZwMuuqKmpnt2NHAQVz+gpOC++NQV9kbFL8LdhlU8XCJu2KM4IWh1iCn4WnQXXmXNQDj2+DDZFvoGeHpbvz2DCkBFM86Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794362825; c=relaxed/simple; bh=2VybNqQppNbpqysaZCf0WntftfpLPkSGFqXV0lmEYlU=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=kzfLvnpoHpS0Q7GJ6hz2Ng6HwXfGxpp/Q2s6rTNfQHYD5EYjiPvog0bXG18eVPfSQIx43XW0Dob+yIxrTX1vOvktf0W6CrrbsII61euCTFexFqkhIsLMY6fuquD9ns9mIqSZSGUEenn475RgQQahmVQaf2aV8XHuXRAXA6J9dbA= ARC-Authentication-Results: i=1; sourceware.org; dkim=policy (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=D5JBIiKp reason="signing key too small" DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3DBB24BA2E22 Received: from eig-obgw-5003b.ext.cloudfilter.net ([10.0.29.155]) by cmsmtp with ESMTPS id QtuHxxl5H4vCDQxjnxQU1t; Wed, 11 Nov 2026 02:06:59 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QxjmxXxP5Sgq1QxjmxHUJJ; Wed, 11 Nov 2026 02:06:58 +0000 X-Authority-Analysis: v=2.4 cv=c8KrQQ9l c=1 sm=1 tr=0 ts=6af3cdc3 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=ItBw4LHWJt0A:10 a=_ATLoLIpNf86ze2ZN4QA:9 a=QEXdDO2ut3YA:10 a=DCx65vhANUyCzuf5D8fC:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=eof3BVhRZ+VpItj/kok+8pFM8TrEx4GfGyeihsJfa2g=; b=D5JBIiKpGfa0iCPgCi0jvnA3KI nkHjjbNKHnrI3lePgig1V+gByubvGVjFXuYMPGEERjdiP7BOesDRJXZd7VF+cYHRZlYs/ncVTzVhF qKLUO8aefP06yG+twLAYTkPjN; Received: from 97-122-110-129.hlrn.qwest.net ([97.122.110.129]:38316 helo=[192.168.122.1]) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xQxjm-00000000IPM-0ILD; Tue, 10 Nov 2026 19:06:58 -0700 From: Tom Tromey Date: Tue, 10 Nov 2026 19:06:57 -0700 Subject: [PATCH 3/5] Have program_space::set_exec_bfd do more work MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261110-minor-assert-v1-3-bb33660ca557@tromey.com> References: <20261110-minor-assert-v1-0-bb33660ca557@tromey.com> In-Reply-To: <20261110-minor-assert-v1-0-bb33660ca557@tromey.com> To: gdb-patches@sourceware.org Cc: Tom Tromey X-Mailer: b4 0.14.3 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.110.129 X-Source-L: No X-Exim-ID: 1xQxjm-00000000IPM-0ILD X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-110-129.hlrn.qwest.net ([192.168.122.1]) [97.122.110.129]:38316 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfDNAwhB3JP7Uoq1xH23d78sIefKudt8Hirg3B+WZPtKWTcOlSI7CUXWF5spE9OcweOI8LkRSBDoeJqvvvcvTSz9YgJo7+px1klrobTvmOYTNkBAz///5 XmesLeQoVlwmHs6gCEMmDnVmeSl68mfUSWmPvT+AE8GDp8Axh9k29n2XR5seu4yK55deVHRw/QlPCyT4Cf8HHZj2SwSMBg6cL14= X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org This changes program_space::set_exec_bfd to also set the exec filename, and to compute the exec BFD mtime. This is better because these things really ought to all be set at the same time. program_space::set_exec_filename is not needed any more -- and should not be needed in the future. --- gdb/exec.c | 20 +++++++------------- gdb/progspace.c | 14 ++++++++++++++ gdb/progspace.h | 14 ++++---------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/gdb/exec.c b/gdb/exec.c index aa6fc42ebe7..125ba9d2c44 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -477,26 +477,20 @@ exec_file_attach (const char *filename, int from_tty) styled_string (file_name_style.style (), scratch_pathname), gdb_bfd_errmsg (bfd_get_error (), matching).c_str ()); - current_program_space->set_exec_bfd (std::move (new_exec_bfd)); - - /* gdb_realpath_keepfile resolves symlinks on the local - filesystem and so cannot be used for "target:" files. */ - gdb_assert (current_program_space->exec_filename () == nullptr); + gdb::unique_xmalloc_ptr new_exec_filename; if (load_via_target) - current_program_space->set_exec_filename - (make_unique_xstrdup - (bfd_get_filename (current_program_space->exec_bfd ()))); + new_exec_filename + = make_unique_xstrdup (bfd_get_filename (new_exec_bfd.get ())); else - current_program_space->set_exec_filename - (make_unique_xstrdup (gdb_realpath_keepfile + new_exec_filename + = (make_unique_xstrdup (gdb_realpath_keepfile (scratch_pathname).c_str ())); + current_program_space->set_exec_bfd (std::move (new_exec_bfd), + std::move (new_exec_filename)); std::vector sections = build_section_table (current_program_space->exec_bfd ()); - current_program_space->ebfd_mtime - = gdb_bfd_get_mtime (current_program_space->exec_bfd ()); - validate_files (); set_gdbarch_from_file (current_program_space->exec_bfd ()); diff --git a/gdb/progspace.c b/gdb/progspace.c index a9d13c91598..430629c57b3 100644 --- a/gdb/progspace.c +++ b/gdb/progspace.c @@ -277,6 +277,20 @@ program_space::objfile_for_address (CORE_ADDR address) /* See progspace.h. */ +void +program_space::set_exec_bfd (gdb_bfd_ref_ptr &&abfd, + gdb::unique_xmalloc_ptr new_filename) +{ + gdb_assert (ebfd == nullptr); + gdb_assert (abfd != nullptr); + ebfd = std::move (abfd); + gdb_assert (m_exec_filename = nullptr); + m_exec_filename = std::move (new_filename); + ebfd_mtime = gdb_bfd_get_mtime (ebfd.get ()); +} + +/* See progspace.h. */ + void program_space::exec_close () { diff --git a/gdb/progspace.h b/gdb/progspace.h index d0d8466a8e5..f55444ce88c 100644 --- a/gdb/progspace.h +++ b/gdb/progspace.h @@ -298,9 +298,6 @@ struct program_space const char *exec_filename () const { return m_exec_filename.get (); } - void set_exec_filename (gdb::unique_xmalloc_ptr filename) - { m_exec_filename = std::move (filename); } - /* Close and clear exec_bfd. If we end up with no target sections to read memory from, this unpushes the exec_ops target. */ void exec_close (); @@ -309,13 +306,10 @@ struct program_space bfd *exec_bfd () const { return ebfd.get (); } - /* Set the exec BFD for this program space to ABFD. */ - void set_exec_bfd (gdb_bfd_ref_ptr &&abfd) - { - gdb_assert (ebfd == nullptr); - gdb_assert (abfd != nullptr); - ebfd = std::move (abfd); - } + /* Set the exec BFD for this program space to ABFD. This also + updates the ebfd_mtime and set the exec filename. */ + void set_exec_bfd (gdb_bfd_ref_ptr &&abfd, + gdb::unique_xmalloc_ptr new_filename); /* Reset saved solib data at the start of an solib event. This lets us properly collect the data when calling solib_add, so it can then -- 2.49.0