diff options
author | Guinevere Larsen <guinevere@redhat.com> | 2025-06-06 16:23:37 -0300 |
---|---|---|
committer | Guinevere Larsen <guinevere@redhat.com> | 2025-06-06 17:45:49 -0300 |
commit | 925908e4995f7ab56349b30b29096e211cce42b0 (patch) | |
tree | cbb626e46d6b2db19a0a4cb278c65bd2f7168c46 | |
parent | 3ba8e33726e78ea43b3bb2b0f1a26059b45b8e7e (diff) | |
download | binutils-925908e4995f7ab56349b30b29096e211cce42b0.zip binutils-925908e4995f7ab56349b30b29096e211cce42b0.tar.gz binutils-925908e4995f7ab56349b30b29096e211cce42b0.tar.bz2 |
gdb/solib: make _linker_namespace use selected frame
When the convenience variable $_linker_namespace was introduced, I meant
for it to print the namespace of the frame that where the user was
stopped. However, due to confusing what "current_frame" and
"selected_frame" meant, it instead printed the namespace of the
lowermost frame.
This commit updates the code to follow my original intent. Since the
variable was never in a GDB release, updating the behavior should not
cause any disruption. It also adds a test to verify the functionality.
Approved-By: Tom Tromey <tom@tromey.com>
-rw-r--r-- | gdb/solib.c | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/dlmopen-ns-ids.exp | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/gdb/solib.c b/gdb/solib.c index 3e821ba..7721fd6 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -1820,7 +1820,7 @@ default_find_solib_addr (solib &so) /* Implementation of the linker_namespace convenience variable. This returns the GDB internal identifier of the linker namespace, - for the current frame, as an integer. If the inferior doesn't support + for the selected frame, as an integer. If the inferior doesn't support linker namespaces, this always returns 0. */ static value * @@ -1831,7 +1831,7 @@ linker_namespace_make_value (gdbarch *gdbarch, internalvar *var, int nsid = 0; if (ops->find_solib_ns != nullptr) { - CORE_ADDR curr_pc = get_frame_pc (get_current_frame ()); + CORE_ADDR curr_pc = get_frame_pc (get_selected_frame ()); for (const solib &so : current_program_space->solibs ()) if (solib_contains_address_p (so, curr_pc)) { diff --git a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp index 801022b..94b4a6e 100644 --- a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp +++ b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp @@ -134,6 +134,12 @@ proc_with_prefix test_conv_vars {} { "Verify we're in namespace $dl" } + # Check that we display the namespace of the selected + # frame, not the lowermost one. + gdb_test "up" "\#1.*in main.*" + gdb_test "print \$_linker_namespace" ".* = 0" \ + "print namespace of selected frame" + gdb_continue_to_breakpoint "first dlclose" gdb_test "print \$_active_linker_namespaces" "4" "all SOs loaded" |