From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id UfN6FBHO82oOsAAAWB0awg (envelope-from ) for ; Tue, 10 Nov 2026 21:08:17 -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=fMrPGu22; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 4AD1B378002; Tue, 10 Nov 2026 21:08:17 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.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,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=no autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.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 5413B1E043 for ; Tue, 10 Nov 2026 21:08:16 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3969F4BA23F6 for ; Wed, 11 Nov 2026 02:08:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3969F4BA23F6 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=fMrPGu22 Received: from omta38.uswest2.a.cloudfilter.net (omta38.uswest2.a.cloudfilter.net [35.89.44.37]) by sourceware.org (Postfix) with ESMTPS id 4F2334BA2E2F for ; Wed, 11 Nov 2026 02:07:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4F2334BA2E2F 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 4F2334BA2E2F Authentication-Results: sourceware.org; arc=none smtp.remote-ip=35.89.44.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794362821; cv=none; b=izS+WPQpqM9A7VJphB1r6l0ETZBP2F8gwdbIO6Y86bJZTir5HtAubW7/rPF4BqsBk/sqG9nkQ7bV8wNdliWvJjamtwUbaAIveHlSta/rk2P+wbPkERshXL6XVOtZQotvjmyBQufOD7ZfxmYQUT7/T1DhlwZw4gRlfDav7N4KdKM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794362821; c=relaxed/simple; bh=hqyWmJbgADvD8zwrrwwdqNnvxDjZxFsOY1I+PTCjj90=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=HcgjdLvgiw+SUzml7EzU0sEhve1zUIdhQKaT0zpm60PLwj9m4ti0XPAEYsvHwWwu+90O9jTZNa4hvTjsgaXOeP2fAE5qxNsckYjL6wvMi5czRHRsM6GXnsoaUQujWZ3jVSC/LoLDBJKnm6KyjpPEG48IBnotQXG90Ox7GAWUITo= 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=fMrPGu22 reason="signing key too small" DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4F2334BA2E2F Received: from eig-obgw-6001b.ext.cloudfilter.net ([10.0.30.143]) by cmsmtp with ESMTPS id QqA5xy6yxVK9UQxjnxCU4A; Wed, 11 Nov 2026 02:06:59 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id Qxjmx73LydRrRQxjmxbgN3; Wed, 11 Nov 2026 02:06:59 +0000 X-Authority-Analysis: v=2.4 cv=LOhmQIW9 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=tzhb9HgV1i2ApFf3d6wA:9 a=3ZKOabzyN94A:10 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=ZWTrTWDY4CH8OW0wDWQ/8UkEHm+392Af5WEmN6tEHOE=; b=fMrPGu2282en+OADNMesW++mKx bRcs2rKd9A9FhurE99G+CA57kcxDY2J+MhkoZqNbXz01qfUcF/tQWwQ422Wey/0bel7IQFJkHywwB xGcrwIW/GPKGyz4WKTDmiFRjv; 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-1XsC; Tue, 10 Nov 2026 19:06:58 -0700 From: Tom Tromey Date: Tue, 10 Nov 2026 19:06:58 -0700 Subject: [PATCH 4/5] Mark two program_space fields as private MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261110-minor-assert-v1-4-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-1XsC 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: 5 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfMv/XCe+RCX7cjFWNseao58gnXq0WEw1lMS/0VAb6wwHKUbe1qmpbxxSJ8F4bs8Gl+OtMIyb2YZUNNrBkansO041I2uWtP34R4ifvz2vEqhzKRzdaXvK SOIkRd2sq2yIc1n+1Ljp/viPc3pc+GWwXOzODqpQWjthOldL2DWlqL73cHkj8ivm87W65rsxuJNkuDq/ZXXzbXdk3pMlHEa2L4o= 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 the 'ebfd' and 'ebfd_mtime' fields in program_space to be private. A new method is added to access the mtime. This patch also found one remaining spot that was directly accessing ebfd. --- gdb/corefile.c | 4 ++-- gdb/exec.c | 2 +- gdb/progspace.c | 20 ++++++++++---------- gdb/progspace.h | 23 ++++++++++++++--------- gdb/source-cache.c | 2 +- 5 files changed, 28 insertions(+), 23 deletions(-) diff --git a/gdb/corefile.c b/gdb/corefile.c index 37f04fa7794..ac488e8143f 100644 --- a/gdb/corefile.c +++ b/gdb/corefile.c @@ -55,8 +55,8 @@ reopen_exec_file (void) int res = gdb_bfd_stat (exec_bfd, &st); if (res == 0 - && current_program_space->ebfd_mtime != 0 - && current_program_space->ebfd_mtime != st.st_mtime) + && current_program_space->exec_bfd_mtime () != 0 + && current_program_space->exec_bfd_mtime () != st.st_mtime) exec_file_attach (bfd_get_filename (exec_bfd), 0); } diff --git a/gdb/exec.c b/gdb/exec.c index 125ba9d2c44..000b1170145 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -499,7 +499,7 @@ exec_file_attach (const char *filename, int from_tty) list of sections. This possibly pushes the exec_ops target. */ current_program_space->add_target_sections - (current_program_space->ebfd.get (), sections); + (current_program_space->exec_bfd (), sections); } /* Are are loading the same executable? */ diff --git a/gdb/progspace.c b/gdb/progspace.c index 430629c57b3..619db5ef2fb 100644 --- a/gdb/progspace.c +++ b/gdb/progspace.c @@ -281,12 +281,12 @@ void program_space::set_exec_bfd (gdb_bfd_ref_ptr &&abfd, gdb::unique_xmalloc_ptr new_filename) { - gdb_assert (ebfd == nullptr); + gdb_assert (m_ebfd == nullptr); gdb_assert (abfd != nullptr); - ebfd = std::move (abfd); - gdb_assert (m_exec_filename = nullptr); + m_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 ()); + m_ebfd_mtime = gdb_bfd_get_mtime (m_ebfd.get ()); } /* See progspace.h. */ @@ -294,15 +294,15 @@ program_space::set_exec_bfd (gdb_bfd_ref_ptr &&abfd, void program_space::exec_close () { - if (ebfd != nullptr) + if (m_ebfd != nullptr) { /* Removing target sections may close the exec_ops target. - Clear ebfd before doing so to prevent recursion. We + Clear m_ebfd before doing so to prevent recursion. We move it to another ref_ptr instead of saving it to a raw pointer to avoid it looking like possible use-after-free. */ - gdb_bfd_ref_ptr saved_ebfd = std::move (ebfd); - ebfd.reset (nullptr); - ebfd_mtime = 0; + gdb_bfd_ref_ptr saved_ebfd = std::move (m_ebfd); + m_ebfd.reset (nullptr); + m_ebfd_mtime = 0; remove_target_sections (saved_ebfd.get ()); @@ -599,7 +599,7 @@ initialize_progspace () _initialize_foo routines may need to install their per-pspace data keys. We can only allocate a progspace when all those modules have done that. Do this before - initialize_current_architecture, because that accesses the ebfd + initialize_current_architecture, because that accesses the m_ebfd of current_program_space. */ current_program_space = new program_space (new_address_space ()); } diff --git a/gdb/progspace.h b/gdb/progspace.h index f55444ce88c..a5e5f0ea3f5 100644 --- a/gdb/progspace.h +++ b/gdb/progspace.h @@ -304,13 +304,19 @@ struct program_space /* Return the exec BFD for this program space. */ bfd *exec_bfd () const - { return ebfd.get (); } + { return m_ebfd.get (); } /* 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); + /* Return the saved mtime of the exec BFD. */ + long exec_bfd_mtime () const + { + return m_ebfd_mtime; + } + /* 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 later be printed. */ @@ -367,14 +373,6 @@ struct program_space /* Unique ID number. */ int num = 0; - /* The main executable loaded into this program space. This is - managed by the exec target. */ - - /* The BFD handle for the main executable. */ - gdb_bfd_ref_ptr ebfd; - /* The last-modified time, from when the exec was brought in. */ - long ebfd_mtime = 0; - /* The address space attached to this program space. More than one program space may be bound to the same address space. In the traditional unix-like debugging scenario, this will usually @@ -419,6 +417,13 @@ struct program_space registry registry_fields; private: + /* The main executable loaded into this program space. This is + managed by the exec target. */ + /* The BFD handle for the main executable. */ + gdb_bfd_ref_ptr m_ebfd; + /* The last-modified time, from when the exec was brought in. */ + long m_ebfd_mtime = 0; + /* All known objfiles are kept in a linked list. */ owning_intrusive_list m_objfiles_list; diff --git a/gdb/source-cache.c b/gdb/source-cache.c index 804a6a08a8c..c2e98cae168 100644 --- a/gdb/source-cache.c +++ b/gdb/source-cache.c @@ -114,7 +114,7 @@ source_cache::get_plain_source_lines (struct symtab *s, && s->compunit ().objfile ()->obfd != NULL) mtime = s->compunit ().objfile ()->mtime; else if (current_program_space->exec_bfd ()) - mtime = current_program_space->ebfd_mtime; + mtime = current_program_space->exec_bfd_mtime (); if (mtime && mtime < st.st_mtime) warning (_("Source file is more recent than executable.")); -- 2.49.0