public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: John Baldwin <jhb@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Support TLS variables on FreeBSD/arm. Date: Tue, 3 May 2022 23:10:38 +0000 (GMT) [thread overview] Message-ID: <20220503231039.3B1563858C51@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2e686a74dc4782caeef75f76174909ab7ad358f8 commit 2e686a74dc4782caeef75f76174909ab7ad358f8 Author: John Baldwin <jhb@FreeBSD.org> Date: Tue May 3 16:05:10 2022 -0700 Support TLS variables on FreeBSD/arm. Derive the pointer to the DTV array from the tpidruro register. Diff: --- gdb/arm-fbsd-tdep.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/gdb/arm-fbsd-tdep.c b/gdb/arm-fbsd-tdep.c index a27dfb2fb4a..483820c1092 100644 --- a/gdb/arm-fbsd-tdep.c +++ b/gdb/arm-fbsd-tdep.c @@ -27,6 +27,7 @@ #include "auxv.h" #include "fbsd-tdep.h" #include "gdbcore.h" +#include "inferior.h" #include "osabi.h" #include "solib-svr4.h" #include "trad-frame.h" @@ -226,6 +227,30 @@ arm_fbsd_core_read_description (struct gdbarch *gdbarch, return arm_fbsd_read_description_auxv (target, tls != nullptr); } +/* Implement the get_thread_local_address gdbarch method. */ + +static CORE_ADDR +arm_fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid, + CORE_ADDR lm_addr, CORE_ADDR offset) +{ + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); + struct regcache *regcache; + + regcache = get_thread_arch_regcache (current_inferior ()->process_target (), + ptid, gdbarch); + + target_fetch_registers (regcache, tdep->tls_regnum); + + ULONGEST tpidruro; + if (regcache->cooked_read (tdep->tls_regnum, &tpidruro) != REG_VALID) + error (_("Unable to fetch %%tpidruro")); + + /* %tpidruro points to the TCB whose first member is the dtv + pointer. */ + CORE_ADDR dtv_addr = tpidruro; + return fbsd_get_thread_local_address (gdbarch, dtv_addr, lm_addr, offset); +} + /* Implement the 'init_osabi' method of struct gdb_osabi_handler. */ static void @@ -251,6 +276,14 @@ arm_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) (gdbarch, arm_fbsd_iterate_over_regset_sections); set_gdbarch_core_read_description (gdbarch, arm_fbsd_core_read_description); + if (tdep->tls_regnum > 0) + { + set_gdbarch_fetch_tls_load_module_address (gdbarch, + svr4_fetch_objfile_link_map); + set_gdbarch_get_thread_local_address (gdbarch, + arm_fbsd_get_thread_local_address); + } + /* Single stepping. */ set_gdbarch_software_single_step (gdbarch, arm_software_single_step); }
reply other threads:[~2022-05-03 23:10 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220503231039.3B1563858C51@sourceware.org \ --to=jhb@sourceware.org \ --cc=gdb-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).