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] Fetch the NT_ARM_TLS register set for native FreeBSD/arm processes. Date: Tue, 3 May 2022 23:10:44 +0000 (GMT) [thread overview] Message-ID: <20220503231044.4C34E3858C51@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=684943d213b461a6a84ae67a9b8fcae5a28f007d commit 684943d213b461a6a84ae67a9b8fcae5a28f007d Author: John Baldwin <jhb@FreeBSD.org> Date: Tue May 3 16:05:10 2022 -0700 Fetch the NT_ARM_TLS register set for native FreeBSD/arm processes. This permits resolving TLS variables. Diff: --- gdb/arm-fbsd-nat.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/gdb/arm-fbsd-nat.c b/gdb/arm-fbsd-nat.c index c32924de735..a306e1e2ee0 100644 --- a/gdb/arm-fbsd-nat.c +++ b/gdb/arm-fbsd-nat.c @@ -18,13 +18,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "defs.h" +#include "inferior.h" #include "target.h" +#include "elf/common.h" + #include <sys/types.h> #include <sys/ptrace.h> #include <machine/reg.h> #include "fbsd-nat.h" +#include "arm-tdep.h" #include "arm-fbsd-tdep.h" #include "inf-ptrace.h" @@ -49,6 +53,27 @@ arm_fbsd_nat_target::fetch_registers (struct regcache *regcache, int regnum) fetch_register_set<struct vfpreg> (regcache, regnum, PT_GETVFPREGS, &arm_fbsd_vfpregset); #endif +#ifdef PT_GETREGSET + gdbarch *gdbarch = regcache->arch (); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); + + if (tdep->tls_regnum > 0) + { + const struct regcache_map_entry arm_fbsd_tlsregmap[] = + { + { 1, tdep->tls_regnum, 4 }, + { 0 } + }; + + const struct regset arm_fbsd_tlsregset = + { + arm_fbsd_tlsregmap, + regcache_supply_regset, regcache_collect_regset + }; + + fetch_regset<uint32_t> (regcache, regnum, NT_ARM_TLS, &arm_fbsd_tlsregset); + } +#endif } /* Store register REGNUM back into the inferior. If REGNUM is -1, do @@ -63,6 +88,27 @@ arm_fbsd_nat_target::store_registers (struct regcache *regcache, int regnum) store_register_set<struct vfpreg> (regcache, regnum, PT_GETVFPREGS, PT_SETVFPREGS, &arm_fbsd_vfpregset); #endif +#ifdef PT_GETREGSET + gdbarch *gdbarch = regcache->arch (); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); + + if (tdep->tls_regnum > 0) + { + const struct regcache_map_entry arm_fbsd_tlsregmap[] = + { + { 1, tdep->tls_regnum, 4 }, + { 0 } + }; + + const struct regset arm_fbsd_tlsregset = + { + arm_fbsd_tlsregmap, + regcache_supply_regset, regcache_collect_regset + }; + + store_regset<uint32_t> (regcache, regnum, NT_ARM_TLS, &arm_fbsd_tlsregset); + } +#endif } /* Implement the to_read_description method. */ @@ -71,8 +117,12 @@ const struct target_desc * arm_fbsd_nat_target::read_description () { const struct target_desc *desc; + bool tls = false; - desc = arm_fbsd_read_description_auxv (this, false); +#ifdef PT_GETREGSET + tls = have_regset (inferior_ptid, NT_ARM_TLS) != 0; +#endif + desc = arm_fbsd_read_description_auxv (this, tls); if (desc == NULL) desc = this->beneath ()->read_description (); return desc;
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=20220503231044.4C34E3858C51@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).