[v7,1/5] gdb: Create helper function for the current namespace
Checks
| Context |
Check |
Description |
| linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Test passed
|
| linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Test passed
|
Commit Message
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(-)
@@ -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. */
@@ -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 */