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/Aarch64 processes. Date: Tue, 3 May 2022 23:11:04 +0000 (GMT) [thread overview] Message-ID: <20220503231104.9DE673858010@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b7fe5463cf0dd6d7701d0be5ae129a9d4ecd28bc commit b7fe5463cf0dd6d7701d0be5ae129a9d4ecd28bc 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/Aarch64 processes. This permits resolving TLS variables. Diff: --- gdb/aarch64-fbsd-nat.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/gdb/aarch64-fbsd-nat.c b/gdb/aarch64-fbsd-nat.c index 99e2bf35276..910bf5bb190 100644 --- a/gdb/aarch64-fbsd-nat.c +++ b/gdb/aarch64-fbsd-nat.c @@ -24,12 +24,15 @@ #include "target.h" #include "nat/aarch64-hw-point.h" +#include "elf/common.h" + #include <sys/param.h> #include <sys/ptrace.h> #include <machine/armreg.h> #include <machine/reg.h> #include "fbsd-nat.h" +#include "aarch64-tdep.h" #include "aarch64-fbsd-tdep.h" #include "aarch64-nat.h" #include "inf-ptrace.h" @@ -50,6 +53,8 @@ struct aarch64_fbsd_nat_target final : public fbsd_nat_target void fetch_registers (struct regcache *, int) override; void store_registers (struct regcache *, int) override; + const struct target_desc *read_description () override; + #ifdef HAVE_DBREG /* Hardware breakpoints and watchpoints. */ bool stopped_by_watchpoint () override; @@ -84,6 +89,26 @@ aarch64_fbsd_nat_target::fetch_registers (struct regcache *regcache, &aarch64_fbsd_gregset); fetch_register_set<struct fpreg> (regcache, regnum, PT_GETFPREGS, &aarch64_fbsd_fpregset); + + gdbarch *gdbarch = regcache->arch (); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); + if (tdep->has_tls ()) + { + const struct regcache_map_entry aarch64_fbsd_tls_regmap[] = + { + { 1, tdep->tls_regnum, 8 }, + { 0 } + }; + + const struct regset aarch64_fbsd_tls_regset = + { + aarch64_fbsd_tls_regmap, + regcache_supply_regset, regcache_collect_regset + }; + + fetch_regset<uint64_t> (regcache, regnum, NT_ARM_TLS, + &aarch64_fbsd_tls_regset); + } } /* Store register REGNUM back into the inferior. If REGNUM is -1, do @@ -97,6 +122,35 @@ aarch64_fbsd_nat_target::store_registers (struct regcache *regcache, &aarch64_fbsd_gregset); store_register_set<struct fpreg> (regcache, regnum, PT_GETFPREGS, PT_SETFPREGS, &aarch64_fbsd_fpregset); + + gdbarch *gdbarch = regcache->arch (); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); + if (tdep->has_tls ()) + { + const struct regcache_map_entry aarch64_fbsd_tls_regmap[] = + { + { 1, tdep->tls_regnum, 8 }, + { 0 } + }; + + const struct regset aarch64_fbsd_tls_regset = + { + aarch64_fbsd_tls_regmap, + regcache_supply_regset, regcache_collect_regset + }; + + store_regset<uint64_t> (regcache, regnum, NT_ARM_TLS, + &aarch64_fbsd_tls_regset); + } +} + +/* Implement the target read_description method. */ + +const struct target_desc * +aarch64_fbsd_nat_target::read_description () +{ + bool tls = have_regset (inferior_ptid, NT_ARM_TLS) != 0; + return aarch64_read_description (0, false, false, tls); } #ifdef HAVE_DBREG
reply other threads:[~2022-05-03 23:11 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=20220503231104.9DE673858010@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).