From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1936) id CE0093854575; Tue, 22 Nov 2022 22:44:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE0093854575 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669157041; bh=Xgle3k/h1yEU+Zd9zBMNVL6v5GAazl0w+3+JqDrDZU8=; h=From:To:Subject:Date:From; b=sFP6+ibdYIL0AHkvTKhPi8w+5ORQG2MtoNz7+Ao/g5bbvdkd7EROmXUbNQiT/3Hdp Ixs6ze2Jm7WHoezgEF8jM9+pCENZE7XutfQz5q9kyN9HDn66SrC1EKlT6LdjUhIx+T 7yYNPfDO6zM1yZqoznYCGjAaOmiztmsrdZKllHZ8= 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] arm-fbsd: Use a static regset for the TLS register set. X-Act-Checkin: binutils-gdb X-Git-Author: John Baldwin X-Git-Refname: refs/heads/master X-Git-Oldrev: a141d32c6ef5c644c856d89de88f9980ec3d8ceb X-Git-Newrev: 759bbcb917959eedca1c67a05fd43583fe20f12e Message-Id: <20221122224401.CE0093854575@sourceware.org> Date: Tue, 22 Nov 2022 22:44:01 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D759bbcb91795= 9eedca1c67a05fd43583fe20f12e commit 759bbcb917959eedca1c67a05fd43583fe20f12e Author: John Baldwin Date: Tue Nov 22 14:21:13 2022 -0800 arm-fbsd: Use a static regset for the TLS register set. =20 This uses custom collect/supply regset handlers which pass the TLS register number from the gdbarch_tdep as the base register number. =20 Approved-By: Simon Marchi Diff: --- gdb/arm-fbsd-nat.c | 34 ++++----------------------------- gdb/arm-fbsd-tdep.c | 54 +++++++++++++++++++++++++++++++++++++------------= ---- gdb/arm-fbsd-tdep.h | 1 + 3 files changed, 43 insertions(+), 46 deletions(-) diff --git a/gdb/arm-fbsd-nat.c b/gdb/arm-fbsd-nat.c index bbd722ed923..340b8e0d710 100644 --- a/gdb/arm-fbsd-nat.c +++ b/gdb/arm-fbsd-nat.c @@ -58,21 +58,8 @@ arm_fbsd_nat_target::fetch_registers (struct regcache *r= egcache, int regnum) arm_gdbarch_tdep *tdep =3D gdbarch_tdep (gdbarch); =20 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); - } + fetch_regset (regcache, regnum, NT_ARM_TLS, &arm_fbsd_tls_re= gset, + tdep->tls_regnum); #endif } =20 @@ -93,21 +80,8 @@ arm_fbsd_nat_target::store_registers (struct regcache *r= egcache, int regnum) arm_gdbarch_tdep *tdep =3D gdbarch_tdep (gdbarch); =20 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); - } + store_regset (regcache, regnum, NT_ARM_TLS, &arm_fbsd_tls_re= gset, + tdep->tls_regnum); #endif } =20 diff --git a/gdb/arm-fbsd-tdep.c b/gdb/arm-fbsd-tdep.c index 4395136b83c..75ee08eba50 100644 --- a/gdb/arm-fbsd-tdep.c +++ b/gdb/arm-fbsd-tdep.c @@ -52,6 +52,14 @@ static const struct regcache_map_entry arm_fbsd_vfpregma= p[] =3D { 0 } }; =20 +/* Register numbers are relative to tdep->tls_regnum. */ + +static const struct regcache_map_entry arm_fbsd_tls_regmap[] =3D + { + { 1, 0, 4 }, /* tpidruro */ + { 0 } + }; + /* In a signal frame, sp points to a 'struct sigframe' which is defined as: =20 @@ -151,6 +159,34 @@ const struct regset arm_fbsd_vfpregset =3D regcache_supply_regset, regcache_collect_regset }; =20 +static void +arm_fbsd_supply_tls_regset (const struct regset *regset, + struct regcache *regcache, + int regnum, const void *buf, size_t size) +{ + struct gdbarch *gdbarch =3D regcache->arch (); + arm_gdbarch_tdep *tdep =3D gdbarch_tdep (gdbarch); + + regcache->supply_regset (regset, tdep->tls_regnum, regnum, buf, size); +} + +static void +arm_fbsd_collect_tls_regset (const struct regset *regset, + const struct regcache *regcache, + int regnum, void *buf, size_t size) +{ + struct gdbarch *gdbarch =3D regcache->arch (); + arm_gdbarch_tdep *tdep =3D gdbarch_tdep (gdbarch); + + regcache->collect_regset (regset, tdep->tls_regnum, regnum, buf, size); +} + +const struct regset arm_fbsd_tls_regset =3D + { + arm_fbsd_tls_regmap, + arm_fbsd_supply_tls_regset, arm_fbsd_collect_tls_regset + }; + /* Implement the "iterate_over_regset_sections" gdbarch method. */ =20 static void @@ -165,22 +201,8 @@ arm_fbsd_iterate_over_regset_sections (struct gdbarch = *gdbarch, &arm_fbsd_gregset, NULL, cb_data); =20 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 - }; - - cb (".reg-aarch-tls", ARM_FBSD_SIZEOF_TLSREGSET, ARM_FBSD_SIZEOF_TLS= REGSET, - &arm_fbsd_tlsregset, NULL, cb_data); - } + cb (".reg-aarch-tls", ARM_FBSD_SIZEOF_TLSREGSET, ARM_FBSD_SIZEOF_TLSRE= GSET, + &arm_fbsd_tls_regset, NULL, cb_data); =20 /* While FreeBSD/arm cores do contain a NT_FPREGSET / ".reg2" register set, it is not populated with register values by the diff --git a/gdb/arm-fbsd-tdep.h b/gdb/arm-fbsd-tdep.h index 85d7b59d136..b4137eb9a51 100644 --- a/gdb/arm-fbsd-tdep.h +++ b/gdb/arm-fbsd-tdep.h @@ -35,6 +35,7 @@ =20 extern const struct regset arm_fbsd_gregset; extern const struct regset arm_fbsd_vfpregset; +extern const struct regset arm_fbsd_tls_regset; =20 /* Flags passed in AT_HWCAP. */ #define HWCAP_VFP 0x00000040