From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 8eC7GHzjdWpp8RAAWB0awg (envelope-from ) for ; Fri, 07 Aug 2026 09:54:04 -0400 Received: by simark.ca (Postfix, from userid 112) id 4C8D01E09B; Fri, 07 Aug 2026 09:54:04 -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 [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 C89CA1E09E for ; Fri, 07 Aug 2026 09:54:02 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 38A434BAE7CA for ; Fri, 7 Aug 2026 13:54:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 38A434BAE7CA Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id ABC6C4BB24F9 for ; Fri, 7 Aug 2026 13:53:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ABC6C4BB24F9 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 ABC6C4BB24F9 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=1786110785; cv=none; b=DEZPiKMvnoeMMrpJfzggRR/tmVqvMt/xsTh2mXLQDu0P/8PofIpS7nmysni099KsTvqewdjyYcbqRaOvt4s4y2i2mz+YSew98wtl+flNmD3isMNdtq1J8fZBu2yTrIuaDUI0VwbYyyWXClCs71HI2LFFC+/Ay97e41clSE5a8/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786110785; c=relaxed/simple; bh=/SfqDxahJ/gHzSSYs3XZRt6FCn0ET96Oe5/GeVPNX64=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=oT+qvsYb+cEYwuJsQYQkVMmKLvRaNuAZg4/72VO+anewPbs9WlYjHluObjKU4565MpTlgS9/5I/PMZQEwHW5eZneIFEy5JKYyqsD5tVOttc/MNd1DsH6PIEA8YKGi3qVJ+aQjcfl4T6CVGSoW3Lr10OgRWK9/qlHBE/XnyHRvc0= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ABC6C4BB24F9 Received: by simark.ca (Postfix) id 224891E16F; Fri, 07 Aug 2026 09:53:02 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi , Tom Tromey Subject: [PATCH v4 05/10] gdb/solib: add remove_solib function Date: Fri, 7 Aug 2026 09:52:23 -0400 Message-ID: <20260807135259.111194-6-simon.marchi@efficios.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260807135259.111194-1-simon.marchi@efficios.com> References: <20260807135259.111194-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 patches later in this series. This patch only moves code, so no behavior change expected. Change-Id: I6bb901c954cdcf900a3f09a4c4d1ba44203f1ed0 Approved-By: Tom Tromey --- gdb/solib.c | 53 +++++++++++++++++++++++++++++------------------------ gdb/solib.h | 10 ++++++++++ 2 files changed, 39 insertions(+), 24 deletions(-) diff --git a/gdb/solib.c b/gdb/solib.c index 561a1448cfe6..6afa97e1aed5 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -703,6 +703,34 @@ notify_solib_unloaded (program_space *pspace, const solib &so, /* See solib.h. */ +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 update_solib_list (int from_tty) { @@ -784,30 +812,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 diff --git a/gdb/solib.h b/gdb/solib.h index b2523906596a..903b9d7b2a86 100644 --- a/gdb/solib.h +++ b/gdb/solib.h @@ -350,6 +350,16 @@ extern bool in_solib_dynsym_resolve_code (CORE_ADDR); extern void no_shared_libraries (program_space *pspace); +/* 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. */ + +extern owning_intrusive_list::iterator remove_solib + (program_space *pspace, owning_intrusive_list::iterator solib_it); + /* Synchronize GDB's shared object list with inferior's. Extract the list of currently loaded shared objects from the -- 2.55.0