Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Guinevere Larsen <guinevere@redhat.com>
To: gdb-patches@sourceware.org
Cc: Guinevere Larsen <guinevere@redhat.com>
Subject: [PATCH v7 1/5] gdb: Create helper function for the current namespace
Date: Mon,  1 Jun 2026 16:22:47 -0300	[thread overview]
Message-ID: <20260601192251.60958-2-guinevere@redhat.com> (raw)
In-Reply-To: <20260601192251.60958-1-guinevere@redhat.com>

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


  reply	other threads:[~2026-06-01 19:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-01 19:22 [PATCH v7 0/5] Introduce syntax for linker-namespace specific symbols Guinevere Larsen
2026-06-01 19:22 ` Guinevere Larsen [this message]
2026-06-01 19:22 ` [PATCH v7 2/5] gdb: make lookup_minimal_symbol_linkage work with linker namespaces Guinevere Larsen
2026-06-01 19:22 ` [PATCH v7 3/5] gdb: Make the parser recognize the [[N]] syntax for variables Guinevere Larsen
2026-06-01 19:22 ` [PATCH v7 4/5] gdb: extend the [[N]]::foo syntax for files Guinevere Larsen
2026-06-01 19:22 ` [PATCH v7 5/5] gdb: prefer symtabs for the current linker namespace Guinevere Larsen
2026-06-03 18:26   ` Guinevere Larsen
2026-06-03 19:16 ` [PATCH v7 5/5] Fixed " Guinevere Larsen
2026-06-22 20:35 ` [PING][PATCH v7 0/5] Introduce syntax for linker-namespace specific symbols Guinevere Larsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260601192251.60958-2-guinevere@redhat.com \
    --to=guinevere@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox