From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id CU7yOWbcHWqyKS4AWB0awg (envelope-from ) for ; Mon, 01 Jun 2026 15:24:22 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MiphIAWg; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E88021E024; Mon, 01 Jun 2026 15:24:22 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_SBL_CSS autolearn=ham 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 783D31E024 for ; Mon, 01 Jun 2026 15:24:22 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DCD5C4BA2E26 for ; Mon, 1 Jun 2026 19:24:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DCD5C4BA2E26 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MiphIAWg Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 649AF4BA5439 for ; Mon, 1 Jun 2026 19:23:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 649AF4BA5439 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 649AF4BA5439 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780341826; cv=none; b=Y9jfYbKKcUbm2I0jNkPAh1Ay6CNcNY+mPI+p6gNxQjR2Lc/lu/eT5HM8S31jPuZfkSvw0CvulsHHzRNxmrNYBMh0zWSX0sykXhhDGP0YRH5Tho1TrM94dYIKLST57SdQFJdbLFvYr5yQFhpr3z22byCJe+gtgznteUN8jY97I6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780341826; c=relaxed/simple; bh=fVrNQcpKV4r22zO/Xcl+RiUwxd5pdz8na7aLHUYZIMA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=eMp3U7mze5ArHo8tOVCRdMtbeCMnT3RW92p0Pnszv6iMhl45+1+vMkxDynUmJs3N5FA58aVeKHoQyP13aYuFvqPYJiEhBH2dki4g62q9MbEzOI1LcA25WoIzHCfAlyWCVQpQACgWxNnX9ogoCbSayEoEG9Q7Bp23GHVjcCplWHQ= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MiphIAWg DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 649AF4BA5439 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780341826; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SNiROKT3ghO6+prBK44NVFHPCj0Jum6SS2ox7Xpn13Y=; b=MiphIAWg4Qvl+LW2tnWriE4alqg/s6bQR1503d2pdrACJia6VPfh3cXU1HnhMpnutSsF7+ HHm6lNukTRh5rBGjd5nx6Mx+9Wj0IN/cykOc0qTfni6cFBQmiGaY+dlxDmb2O2pHwCXpKg +Vv6qMtEngiRTDrZKlEZllP46GStoR4= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-13-98k5RVW3NyuJkzYIM76CmQ-1; Mon, 01 Jun 2026 15:23:45 -0400 X-MC-Unique: 98k5RVW3NyuJkzYIM76CmQ-1 X-Mimecast-MFC-AGG-ID: 98k5RVW3NyuJkzYIM76CmQ_1780341824 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 941D31955E8D for ; Mon, 1 Jun 2026 19:23:36 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.96.134.144]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E58FD19560A7; Mon, 1 Jun 2026 19:23:34 +0000 (UTC) From: Guinevere Larsen To: gdb-patches@sourceware.org Cc: Guinevere Larsen Subject: [PATCH v7 1/5] gdb: Create helper function for the current namespace Date: Mon, 1 Jun 2026 16:22:47 -0300 Message-ID: <20260601192251.60958-2-guinevere@redhat.com> In-Reply-To: <20260601192251.60958-1-guinevere@redhat.com> References: <20260601192251.60958-1-guinevere@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ca-rdlhbxIJSApNCCWlIimXQ_kGiFT7XpWaH3XoO2fw_1780341824 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true 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 More code is needing to access the linker namespace of the selected frame, so it makes sense to create a helper function that calculates the current namespace, and make the internalvar use that helper instead. This commit introduces this helper function. --- gdb/solib.c | 26 +++++++++++++++++--------- gdb/solib.h | 4 ++++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/gdb/solib.c b/gdb/solib.c index d92d0dd9a3d..dbb69ef7678 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -1793,15 +1793,10 @@ solib_linker_namespace_count (program_space *pspace) return 0; } -/* Implementation of the linker_namespace convenience variable. - - This returns the GDB internal identifier of the linker namespace, - for the selected frame, as an integer. If the inferior doesn't support - linker namespaces, this always returns 0. */ +/* See solib.h. */ -static value * -linker_namespace_make_value (gdbarch *gdbarch, internalvar *var, - void *ignore) +int +get_current_linker_namespace () { int nsid = 0; CORE_ADDR curr_pc = get_frame_pc (get_selected_frame ()); @@ -1815,9 +1810,22 @@ linker_namespace_make_value (gdbarch *gdbarch, internalvar *var, break; } + return nsid; +} + +/* Implementation of the linker_namespace convenience variable. + This returns the GDB internal identifier of the linker namespace, + for the selected frame, as an integer. If the inferior doesn't support + linker namespaces, this always returns 0. */ + +static value * +linker_namespace_make_value (gdbarch *gdbarch, internalvar *var, + void *ignore) +{ /* If the PC is not in an SO, or the solib_ops doesn't support linker namespaces, the inferior is in the default namespace. */ - return value_from_longest (builtin_type (gdbarch)->builtin_int, nsid); + return value_from_longest (builtin_type (gdbarch)->builtin_int, + get_current_linker_namespace ()); } /* Implementation of `$_linker_namespace' variable. */ diff --git a/gdb/solib.h b/gdb/solib.h index 9e6c3f7346e..e52eef53df8 100644 --- a/gdb/solib.h +++ b/gdb/solib.h @@ -412,4 +412,8 @@ extern void handle_solib_event (void); extern int solib_linker_namespace_count (program_space *pspace); +/* Calculate the linker namespace for the currently selected frame. */ + +int get_current_linker_namespace (); + #endif /* GDB_SOLIB_H */ -- 2.54.0