From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ktV+FqLITmqn1CwAWB0awg (envelope-from ) for ; Wed, 08 Jul 2026 18:01:06 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=qP9kkOXH; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 474891E098; Wed, 08 Jul 2026 18:01:06 -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.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED 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 8A72F1E04F for ; Wed, 08 Jul 2026 18:01:05 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 494054BA2E32 for ; Wed, 8 Jul 2026 22:01:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 494054BA2E32 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=qP9kkOXH Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 32DA64BA2E10 for ; Wed, 8 Jul 2026 22:00:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 32DA64BA2E10 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 32DA64BA2E10 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783548036; cv=none; b=CqoMPYXYdHUriAFDiyk7WeMlC1xN8sBjIjeZ6RlkWgoL4Ur6qEtv0TQWRcNWt7O+lAF091SdMSzfBL4iNJO+uDeUeNvkZjS4p3qRs5T7+C6CDYyQNutHrqUVv7YytwXKqb3343HTehO9/EdKYo4PwYdhLU5m60ffuSeoVlg0s3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783548036; c=relaxed/simple; bh=/SfqDxahJ/gHzSSYs3XZRt6FCn0ET96Oe5/GeVPNX64=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=xbSQ1EUl1Qw9f2FGwY+dnzB4uJOgGw8anf/BgX7/V8i5ShDoKEfd7ArzBasJMr/Ta60XiYr/76bK1F2hhrrPPwe1vMOB7YRRTw2FBm1ZFylnZGVZbCf9HqnjGxr4QUTjNSeaEOnoori2edS6hPiJ5tAz4/JI7swyBUv9mNg0JQo= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=qP9kkOXH DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 32DA64BA2E10 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 668M0R3A120690 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 8 Jul 2026 18:00:32 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 668M0R3A120690 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=oct2025; t=1783548033; bh=fPR+Wz9zu4UmYvhpB/U2u51sEuvazAtYw0Sbx0QAndI=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=qP9kkOXHt+kgooc+Yww9QoOVVPg8ik0BYaMNR/SLzFX97u8NvX0jXLsoIi5MN6IHo suBfDgSA77i3Tvcbt0+ZeQP2GlsDsShkiJ6bCviSReXJEXJCsHJ8tw/2piOSQj0KLg CqdffjuEv2+fiozxnc+26z3RuONzxeSxkSYCDupWVocVSFbGUu8vM0QUfYMJL4RcED 8NgtjBq2r/ZosziK5cqdKBGUAQZ4tZ+OXzKdTURqCITWF2pYjprHNsvu3I2B7LbCI/ V9aJ+6hQcJEg/jkKnE60XjpdmTLQPAnCQG6mLN2C2x9IG4NEiENtEeYHE5Qa7f3tg2 blN9axFj69/2Q== Received: by simark.ca (Postfix) id 475131E0AB; Wed, 08 Jul 2026 17:51:52 -0400 (EDT) From: simon.marchi@polymtl.ca To: gdb-patches@sourceware.org Cc: Tom Tromey , Lancelot SIX , Simon Marchi Subject: [PATCH v3 05/10] gdb/solib: add remove_solib function Date: Wed, 8 Jul 2026 17:51:37 -0400 Message-ID: <20260708215145.93134-6-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260708215145.93134-1-simon.marchi@polymtl.ca> References: <20260708215145.93134-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Wed, 8 Jul 2026 22:00:27 +0000 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