From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4cyXGp0fJ2rmmzwAWB0awg (envelope-from ) for ; Mon, 08 Jun 2026 16:01:33 -0400 Received: by simark.ca (Postfix, from userid 112) id 6780C1E070; Mon, 08 Jun 2026 16:01:33 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable 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 DC6331E070 for ; Mon, 08 Jun 2026 16:01:32 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6EAD144DE4A8 for ; Mon, 8 Jun 2026 20:01:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6EAD144DE4A8 Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id C522051A4330 for ; Mon, 8 Jun 2026 20:01:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C522051A4330 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 C522051A4330 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780948864; cv=none; b=tv/R0A7bKBRZhCMvGlMAgZacynKKQxHdHxLWr8lfa+s3CPfMKD1w48hknV8ox9G7vchsCt5jOuMc2Lx2UPxmG6k6CcnItwXMwMQyNlOip+YpTaaoZLBnhnkW4/9ri/nbGAVg+OhnMvbi8wHnYaHxo7uYhIZLLMeKC63FennrXBU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780948864; c=relaxed/simple; bh=SVGxhu8eRuAqXyKK8UWCNuF9Jzsz7XYPgVA2TAcYLUo=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=vLJdzhKJ3DxO8+b1SQXD45r3Bi3n7Bci4coKjVeyJAz1qMsN9IY0vqz2BalU0bE+7y3OqvYpxhYyeTrepyOO1+9VBpjpAiZlhWqfZkfBXQQO85UDNb+E9/AhzOGThahiXjVc9aUh5w0jS8s7GgP3E7q7U7I0pwls5hWO14SNZuc= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C522051A4330 Received: by simark.ca (Postfix) id C8F581E0AF; Mon, 08 Jun 2026 16:01:02 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi , Tom Tromey Subject: [PATCH RESEND v2 07/10] gdb/solib: add remove_solib function Date: Mon, 8 Jun 2026 16:00:31 -0400 Message-ID: <20260608200100.666134-8-simon.marchi@efficios.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260608200100.666134-1-simon.marchi@efficios.com> References: <20260608200100.666134-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 Approved-By: Tom Tromey --- gdb/solib.c | 58 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/gdb/solib.c b/gdb/solib.c index ae41572b2b58..1211874d22be 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -684,6 +684,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 @@ -767,30 +800,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.54.0