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>
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
@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
/* 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;
}
}
/* 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. */
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
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"
}
# 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
}