aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbarch.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2019-03-12 13:39:02 -0700
committerJohn Baldwin <jhb@FreeBSD.org>2019-03-12 13:45:47 -0700
commit6e056c817845f3d736a1be6b68c69b439c6c6d25 (patch)
treec5757ebd000ccd8a2d63440d6ef19db9e8c89d8d /gdb/gdbarch.c
parentcd250a1898bb6fdb41f4a1063dbcfac04affcd11 (diff)
downloadgdb-6e056c817845f3d736a1be6b68c69b439c6c6d25.zip
gdb-6e056c817845f3d736a1be6b68c69b439c6c6d25.tar.gz
gdb-6e056c817845f3d736a1be6b68c69b439c6c6d25.tar.bz2
Add a new gdbarch method to resolve the address of TLS variables.
Permit TLS variable addresses to be resolved purely by an ABI rather than requiring a target method. This doesn't try the target method if the ABI function is present (even if the ABI function fails) to simplify error handling. gdb/ChangeLog: * gdbarch.sh (get_thread_local_address): New method. * gdbarch.h, gdbarch.c: Regenerate. * target.c (target_translate_tls_address): Use gdbarch_get_thread_local_address if present instead of target::get_thread_local_address.
Diffstat (limited to 'gdb/gdbarch.c')
-rw-r--r--gdb/gdbarch.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 434ee3b..2b3fcef 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -251,6 +251,7 @@ struct gdbarch
CORE_ADDR deprecated_function_start_offset;
gdbarch_remote_register_number_ftype *remote_register_number;
gdbarch_fetch_tls_load_module_address_ftype *fetch_tls_load_module_address;
+ gdbarch_get_thread_local_address_ftype *get_thread_local_address;
CORE_ADDR frame_args_skip;
gdbarch_unwind_pc_ftype *unwind_pc;
gdbarch_unwind_sp_ftype *unwind_sp;
@@ -613,6 +614,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of deprecated_function_start_offset, invalid_p == 0 */
/* Skip verify of remote_register_number, invalid_p == 0 */
/* Skip verify of fetch_tls_load_module_address, has predicate. */
+ /* Skip verify of get_thread_local_address, has predicate. */
/* Skip verify of frame_args_skip, invalid_p == 0 */
/* Skip verify of unwind_pc, invalid_p == 0 */
/* Skip verify of unwind_sp, invalid_p == 0 */
@@ -1074,6 +1076,12 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
"gdbarch_dump: get_syscall_number = <%s>\n",
host_address_to_string (gdbarch->get_syscall_number));
fprintf_unfiltered (file,
+ "gdbarch_dump: gdbarch_get_thread_local_address_p() = %d\n",
+ gdbarch_get_thread_local_address_p (gdbarch));
+ fprintf_unfiltered (file,
+ "gdbarch_dump: get_thread_local_address = <%s>\n",
+ host_address_to_string (gdbarch->get_thread_local_address));
+ fprintf_unfiltered (file,
"gdbarch_dump: gnu_triplet_regexp = <%s>\n",
host_address_to_string (gdbarch->gnu_triplet_regexp));
fprintf_unfiltered (file,
@@ -3018,6 +3026,30 @@ set_gdbarch_fetch_tls_load_module_address (struct gdbarch *gdbarch,
gdbarch->fetch_tls_load_module_address = fetch_tls_load_module_address;
}
+int
+gdbarch_get_thread_local_address_p (struct gdbarch *gdbarch)
+{
+ gdb_assert (gdbarch != NULL);
+ return gdbarch->get_thread_local_address != NULL;
+}
+
+CORE_ADDR
+gdbarch_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid, CORE_ADDR lm_addr, CORE_ADDR offset)
+{
+ gdb_assert (gdbarch != NULL);
+ gdb_assert (gdbarch->get_thread_local_address != NULL);
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_get_thread_local_address called\n");
+ return gdbarch->get_thread_local_address (gdbarch, ptid, lm_addr, offset);
+}
+
+void
+set_gdbarch_get_thread_local_address (struct gdbarch *gdbarch,
+ gdbarch_get_thread_local_address_ftype get_thread_local_address)
+{
+ gdbarch->get_thread_local_address = get_thread_local_address;
+}
+
CORE_ADDR
gdbarch_frame_args_skip (struct gdbarch *gdbarch)
{