aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuinevere Larsen <guinevere@redhat.com>2025-05-15 10:45:57 -0300
committerGuinevere Larsen <guinevere@redhat.com>2025-06-05 08:53:43 -0300
commit9dbef4c2897df267fc0b783e673ddcc48ed04c90 (patch)
tree66ee2977278372b00c6696f876d20b88a638fe46
parent83433790d8e6b790343a482eaa7a579cd2688f2a (diff)
downloadbinutils-9dbef4c2897df267fc0b783e673ddcc48ed04c90.zip
binutils-9dbef4c2897df267fc0b783e673ddcc48ed04c90.tar.gz
binutils-9dbef4c2897df267fc0b783e673ddcc48ed04c90.tar.bz2
gdb/solib: Change type of convenience variable _current_linker_namespace
Based on IRC feedback since commit 6a0da68c036a85a46415aa0dada2421eee7c2269 gdb: add convenience variables around linker namespace debugging This commit changes the type of the _current_linker_namespace variable to be a simple integer. This makes it easier to use for expressions, like breakpoint conditions or printing from a specific namespace once that is supported, at the cost of making namespace IDs slightly less consistent. This is based on PR solib/32960, where no negative feedback was given for the suggestion. The commit also changes the usage of "linkage namespaces" to "linker namespaces" in the NEWS file, to reduce chance of confusion from an end user. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32960 Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-By: Tom Tromey <tom@tromey.com>
-rw-r--r--gdb/NEWS8
-rw-r--r--gdb/doc/gdb.texinfo6
-rw-r--r--gdb/solib.c12
-rw-r--r--gdb/testsuite/gdb.base/dlmopen-ns-ids.exp6
4 files changed, 15 insertions, 17 deletions
diff --git a/gdb/NEWS b/gdb/NEWS
index ec71d89..507e533 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -35,16 +35,16 @@
a -h or --help option, which prints each options and a brief
description.
-* On systems that support linkage namespaces, the output of the command
+* On systems that support linker namespaces, the output of the command
"info sharedlibraries" may add one more column, NS, which identifies the
namespace into which the library was loaded, if more than one namespace
is active.
* New built-in convenience variables $_active_linker_namespaces and
- $_current_linker_namespace. These show the number of active linkage
+ $_current_linker_namespace. These show the number of active linker
namespaces, and the namespace to which the current location belongs to.
- In systems that don't support linkage namespaces, these always return 1
- and [[0]] respectively.
+ In systems that don't support linker namespaces, these always return
+ the integers 1 and 0 respectively.
* Add record full support for rv64gc architectures
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 2676471..9aad9e7 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -13112,9 +13112,9 @@ support for linkage namespaces, this variable will always be set to @samp{1}.
@vindex $_current_linker_namespace@r{, convenience variable}
@item $_current_linker_namespace
The namespace which contains the current location in the inferior. This
-returns GDB's internal identifier for namespaces, which is @samp{[[@var{n}]]}
-where @var{n} is a zero-based namespace number. In systems with no support
-for linkage namespaces, this variable will always be set to @samp{[[0]]}.
+returns @value{GDBN}'s internal numbering for the namespace. In systems with no
+support for linker namespaces, this variable will always be set to
+@samp{0}.
@end table
diff --git a/gdb/solib.c b/gdb/solib.c
index 21cb90a..afc1dcc 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -1820,24 +1820,22 @@ default_find_solib_addr (solib &so)
/* Implementation of the current_linker_namespace convenience variable.
This returns the GDB internal identifier of the linker namespace,
- for the current frame, in the form '[[<number>]]'. If the inferior
- doesn't support linker namespaces, this always returns [[0]]. */
+ for the current frame, as an integer. If the inferior doesn't support
+ linker namespaces, this always returns 0. */
static value *
current_linker_namespace_make_value (gdbarch *gdbarch, internalvar *var,
void *ignore)
{
const solib_ops *ops = gdbarch_so_ops (gdbarch);
- const language_defn *lang = language_def (get_frame_language
- (get_current_frame ()));
- std::string nsid = "[[0]]";
+ int nsid = 0;
if (ops->find_solib_ns != nullptr)
{
CORE_ADDR curr_pc = get_frame_pc (get_current_frame ());
for (const solib &so : current_program_space->solibs ())
if (solib_contains_address_p (so, curr_pc))
{
- nsid = string_printf ("[[%d]]", ops->find_solib_ns (so));
+ nsid = ops->find_solib_ns (so);
break;
}
}
@@ -1845,7 +1843,7 @@ current_linker_namespace_make_value (gdbarch *gdbarch, internalvar *var,
/* 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 lang->value_string (gdbarch, nsid.c_str (), nsid.length ());
+ return value_from_longest (builtin_type (gdbarch)->builtin_int, nsid);
}
/* Implementation of `$_current_linker_namespace' variable. */
diff --git a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
index 8f52199..cae1be7 100644
--- a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
+++ b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
@@ -121,7 +121,7 @@ proc_with_prefix test_conv_vars {} {
gdb_test "print \$_active_linker_namespaces" "1" \
"Before activating namespaces"
- gdb_test "print \$_current_linker_namespace" ".*\"\\\[\\\[0\\\]\\\]\"" \
+ gdb_test "print \$_current_linker_namespace" ".* = 0" \
"Still in the default namespace"
gdb_breakpoint "inc" allow-pending
@@ -130,7 +130,7 @@ proc_with_prefix test_conv_vars {} {
foreach_with_prefix dl {3 2 1} {
gdb_continue_to_breakpoint "inc"
- gdb_test "print \$_current_linker_namespace" ".*\"\\\[\\\[$dl\\\]\\\]\"" \
+ gdb_test "print \$_current_linker_namespace" ".* = $dl" \
"Verify we're in namespace $dl"
}
@@ -154,7 +154,7 @@ proc_with_prefix test_conv_vars {} {
# breakpoints and pending breakpoints at the same time with
# gdb_breakpoint.
gdb_test "next" ".*assert.*" "load the first SO"
- gdb_breakpoint "inc if \$_streq(\$_current_linker_namespace, \"\[\[2\]\]\")"
+ gdb_breakpoint "inc if \$_current_linker_namespace == 2"
gdb_continue_to_breakpoint "inc"
gdb_continue_to_end "" continue 1
}