From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1936) id 4C34E3858C51; Tue, 3 May 2022 23:10:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C34E3858C51 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: John Baldwin To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Fetch the NT_ARM_TLS register set for native FreeBSD/arm processes. X-Act-Checkin: binutils-gdb X-Git-Author: John Baldwin X-Git-Refname: refs/heads/master X-Git-Oldrev: 2e686a74dc4782caeef75f76174909ab7ad358f8 X-Git-Newrev: 684943d213b461a6a84ae67a9b8fcae5a28f007d Message-Id: <20220503231044.4C34E3858C51@sourceware.org> Date: Tue, 3 May 2022 23:10:44 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 May 2022 23:10:44 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D684943d213b4= 61a6a84ae67a9b8fcae5a28f007d commit 684943d213b461a6a84ae67a9b8fcae5a28f007d Author: John Baldwin Date: Tue May 3 16:05:10 2022 -0700 Fetch the NT_ARM_TLS register set for native FreeBSD/arm processes. =20 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 . = */ =20 #include "defs.h" +#include "inferior.h" #include "target.h" =20 +#include "elf/common.h" + #include #include #include =20 #include "fbsd-nat.h" +#include "arm-tdep.h" #include "arm-fbsd-tdep.h" #include "inf-ptrace.h" =20 @@ -49,6 +53,27 @@ arm_fbsd_nat_target::fetch_registers (struct regcache *r= egcache, int regnum) fetch_register_set (regcache, regnum, PT_GETVFPREGS, &arm_fbsd_vfpregset); #endif +#ifdef PT_GETREGSET + gdbarch *gdbarch =3D regcache->arch (); + arm_gdbarch_tdep *tdep =3D (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); + + if (tdep->tls_regnum > 0) + { + const struct regcache_map_entry arm_fbsd_tlsregmap[] =3D + { + { 1, tdep->tls_regnum, 4 }, + { 0 } + }; + + const struct regset arm_fbsd_tlsregset =3D + { + arm_fbsd_tlsregmap, + regcache_supply_regset, regcache_collect_regset + }; + + fetch_regset (regcache, regnum, NT_ARM_TLS, &arm_fbsd_tlsr= egset); + } +#endif } =20 /* Store register REGNUM back into the inferior. If REGNUM is -1, do @@ -63,6 +88,27 @@ arm_fbsd_nat_target::store_registers (struct regcache *r= egcache, int regnum) store_register_set (regcache, regnum, PT_GETVFPREGS, PT_SETVFPREGS, &arm_fbsd_vfpregset); #endif +#ifdef PT_GETREGSET + gdbarch *gdbarch =3D regcache->arch (); + arm_gdbarch_tdep *tdep =3D (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); + + if (tdep->tls_regnum > 0) + { + const struct regcache_map_entry arm_fbsd_tlsregmap[] =3D + { + { 1, tdep->tls_regnum, 4 }, + { 0 } + }; + + const struct regset arm_fbsd_tlsregset =3D + { + arm_fbsd_tlsregmap, + regcache_supply_regset, regcache_collect_regset + }; + + store_regset (regcache, regnum, NT_ARM_TLS, &arm_fbsd_tlsr= egset); + } +#endif } =20 /* 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 =3D false; =20 - desc =3D arm_fbsd_read_description_auxv (this, false); +#ifdef PT_GETREGSET + tls =3D have_regset (inferior_ptid, NT_ARM_TLS) !=3D 0; +#endif + desc =3D arm_fbsd_read_description_auxv (this, tls); if (desc =3D=3D NULL) desc =3D this->beneath ()->read_description (); return desc;