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>
/* 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 *
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))
{
"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"