From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ITsKLMp6OGkyTikAWB0awg (envelope-from ) for ; Tue, 09 Dec 2025 14:38:50 -0500 Received: by simark.ca (Postfix, from userid 112) id B0F2F1E0B3; Tue, 09 Dec 2025 14:38:50 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham 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 461961E08D for ; Tue, 09 Dec 2025 14:38:50 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id E30A04BA2E1D for ; Tue, 9 Dec 2025 19:38:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E30A04BA2E1D Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 624174BA2E28 for ; Tue, 9 Dec 2025 19:38:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 624174BA2E28 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 624174BA2E28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765309096; cv=none; b=rSMY0UDNGWuYQ0HhYL8eXUwcZvRavTgG9mhg9x7cW6mEAoj07fevn5SR0TgyO4CRedqY7czL2keEwOajStRoaEeoC+wn5o0PllOb17as/ILXJe2qj7zxM2ZQe/62uyrB+NYEd4LJra7W/eKrLEuTxUIuOMRL5PV9b+5OvvRILjk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765309096; c=relaxed/simple; bh=KOOTr81OJtHrK5RBBef4gTrNXkTPt79H9PQsdxdy3HU=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=XCoGL6q58ZazWRyiT481SJKSD1HpTYrYW4MK8ur4qbBbB9cxh5nddNwYru8HL+12Sq9sdN90ZGW2it6yYoCTfXj+IS0EdIBxGuqmBnPIFBwBqfYSQpcx5Y04/ahONOfvZSNLojcB3pNt8aXzJWHBxz/TZBGOlGuQuYJAAKlj+Rw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 624174BA2E28 Received: by simark.ca (Postfix) id E4DCC1E08D; Tue, 09 Dec 2025 14:38:15 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 08/11] gdb/solib: add remove_solib function Date: Tue, 9 Dec 2025 14:32:12 -0500 Message-ID: <20251209193610.296085-9-simon.marchi@efficios.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251209193610.296085-1-simon.marchi@efficios.com> References: <20251209193610.296085-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From: Simon Marchi Factor out the code to remove an solib into a new remove_solib function. This function is used by a patch later in this series. This patch only moves code, so no behavior change expected. Change-Id: I6bb901c954cdcf900a3f09a4c4d1ba44203f1ed0 --- gdb/solib.c | 58 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/gdb/solib.c b/gdb/solib.c index cc587aa8158b..9f6cc26b63b4 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -713,6 +713,39 @@ notify_solib_unloaded (program_space *pspace, const solib &so, gdb::observers::solib_unloaded.notify (pspace, so, still_in_use, silent); } +/* Remove solib *SOLIB_IT from PSPACE. + + Remove the corresponding objfiles and target sections. + + Return an iterator to the next solib in PSPACE's solib list, helping to + continue iterating. */ + +static owning_intrusive_list::iterator +remove_solib (program_space *pspace, + owning_intrusive_list::iterator solib_it) +{ + bool still_in_use + = solib_it->objfile != nullptr && solib_used (pspace, *solib_it); + + /* Notify any observer that the shared object has been unloaded before we + remove it from GDB's tables. */ + notify_solib_unloaded (pspace, *solib_it, still_in_use, false); + + /* Unless the user loaded it explicitly, free SO's objfile. */ + if (solib_it->objfile != nullptr + && !(solib_it->objfile->flags & OBJF_USERLOADED) + && !still_in_use) + solib_it->objfile->unlink (); + + pspace->deleted_solibs.push_back (solib_it->name); + + /* Some targets' section tables might be referring to + sections from so.abfd; remove them. */ + pspace->remove_target_sections (&*solib_it); + + return pspace->solibs ().erase (solib_it); +} + /* See solib.h. */ void @@ -796,30 +829,7 @@ update_solib_list (int from_tty) /* If it's not on the inferior's list, remove it from GDB's tables. */ else - { - bool still_in_use - = (gdb_iter->objfile != nullptr - && solib_used (current_program_space, *gdb_iter)); - - /* Notify any observer that the shared object has been - unloaded before we remove it from GDB's tables. */ - notify_solib_unloaded (current_program_space, *gdb_iter, - still_in_use, false); - - /* Unless the user loaded it explicitly, free SO's objfile. */ - if (gdb_iter->objfile != nullptr - && !(gdb_iter->objfile->flags & OBJF_USERLOADED) - && !still_in_use) - gdb_iter->objfile->unlink (); - - current_program_space->deleted_solibs.push_back (gdb_iter->name); - - /* Some targets' section tables might be referring to - sections from so.abfd; remove them. */ - current_program_space->remove_target_sections (&*gdb_iter); - - gdb_iter = current_program_space->solibs ().erase (gdb_iter); - } + gdb_iter = remove_solib (current_program_space, gdb_iter); } /* Now the inferior's list contains only shared objects that don't -- 2.52.0