public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: John Baldwin <jhb@FreeBSD.org>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 12/14] Read the tpidr register from NT_ARM_TLS core dump notes on Linux Aarch64.
Date: Tue, 12 Apr 2022 16:46:45 -0700	[thread overview]
Message-ID: <20220412234647.84595-13-jhb@FreeBSD.org> (raw)
In-Reply-To: <20220412234647.84595-1-jhb@FreeBSD.org>

---
 gdb/aarch64-linux-tdep.c | 20 +++++++++++++++++++-
 gdb/aarch64-linux-tdep.h |  4 ++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index 8cfb64d9f4a..e29b29523bb 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -479,6 +479,12 @@ static const struct regcache_map_entry aarch64_linux_fpregmap[] =
     { 0 }
   };
 
+static const struct regcache_map_entry aarch64_linux_tls_regmap[] =
+  {
+    { 1, AARCH64_TPIDR_REGNUM, 8 },
+    { 0 }
+  };
+
 /* Register set definitions.  */
 
 const struct regset aarch64_linux_gregset =
@@ -493,6 +499,12 @@ const struct regset aarch64_linux_fpregset =
     regcache_supply_regset, regcache_collect_regset
   };
 
+const struct regset aarch64_linux_tls_regset =
+  {
+    aarch64_linux_tls_regmap,
+    regcache_supply_regset, regcache_collect_regset
+  };
+
 /* The fields in an SVE header at the start of a SVE regset.  */
 
 #define SVE_HEADER_SIZE_LENGTH		4
@@ -749,6 +761,11 @@ aarch64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
 	  AARCH64_LINUX_SIZEOF_MTE_REGSET, &aarch64_linux_mte_regset,
 	  "MTE registers", cb_data);
     }
+
+  if (tdep->has_tls ())
+    cb (".reg-aarch-tls", AARCH64_LINUX_SIZEOF_TLSREGSET,
+	AARCH64_LINUX_SIZEOF_TLSREGSET, &aarch64_linux_tls_regset,
+	"TLS register", cb_data);
 }
 
 /* Implement the "core_read_description" gdbarch method.  */
@@ -757,13 +774,14 @@ static const struct target_desc *
 aarch64_linux_core_read_description (struct gdbarch *gdbarch,
 				     struct target_ops *target, bfd *abfd)
 {
+  asection *tls = bfd_get_section_by_name (abfd, ".reg-aarch-tls");
   CORE_ADDR hwcap = linux_get_hwcap (target);
   CORE_ADDR hwcap2 = linux_get_hwcap2 (target);
 
   bool pauth_p = hwcap & AARCH64_HWCAP_PACA;
   bool mte_p = hwcap2 & HWCAP2_MTE;
   return aarch64_read_description (aarch64_linux_core_read_vq (gdbarch, abfd),
-				   pauth_p, mte_p, false);
+				   pauth_p, mte_p, tls != nullptr);
 }
 
 /* Implementation of `gdbarch_stap_is_single_operand', as defined in
diff --git a/gdb/aarch64-linux-tdep.h b/gdb/aarch64-linux-tdep.h
index 8ae33efc605..6f5a671cb6e 100644
--- a/gdb/aarch64-linux-tdep.h
+++ b/gdb/aarch64-linux-tdep.h
@@ -39,8 +39,12 @@
 /* The MTE regset consists of a 64-bit register.  */
 #define AARCH64_LINUX_SIZEOF_MTE_REGSET (8)
 
+/* The TLS regset consists of a single register.  */
+#define AARCH64_LINUX_SIZEOF_TLSREGSET (X_REGISTER_SIZE)
+
 extern const struct regset aarch64_linux_gregset;
 extern const struct regset aarch64_linux_fpregset;
+extern const struct regset aarch64_linux_tls_regset;
 
 /* Matches HWCAP_PACA in kernel header arch/arm64/include/uapi/asm/hwcap.h.  */
 #define AARCH64_HWCAP_PACA (1 << 30)
-- 
2.34.1


  parent reply	other threads:[~2022-04-12 23:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12 23:46 [PATCH v2 00/14] Support for Thread Local Storage (TLS) variables on FreeBSD arm and aarch64 architectures John Baldwin
2022-04-12 23:46 ` [PATCH v2 01/14] fbsd-nat: Add helper routines for register sets using PT_[G]SETREGSET John Baldwin
2022-04-12 23:46 ` [PATCH v2 02/14] Create pseudo sections for NT_ARM_TLS notes on FreeBSD John Baldwin
2022-04-12 23:46 ` [PATCH v2 03/14] Add an arm-tls feature which includes the tpidruro register from CP15 John Baldwin
2022-04-12 23:46 ` [PATCH v2 04/14] Read the tpidruro register from NT_ARM_TLS core dump notes on FreeBSD/arm John Baldwin
2022-04-12 23:46 ` [PATCH v2 05/14] Support TLS variables " John Baldwin
2022-04-12 23:46 ` [PATCH v2 06/14] Fetch the NT_ARM_TLS register set for native FreeBSD/arm processes John Baldwin
2022-04-12 23:46 ` [PATCH v2 07/14] Add an aarch64-tls feature which includes the tpidr register John Baldwin
2022-04-12 23:46 ` [PATCH v2 08/14] Read the tpidr register from NT_ARM_TLS core dump notes on FreeBSD/Aarch64 John Baldwin
2022-04-12 23:46 ` [PATCH v2 09/14] Support TLS variables " John Baldwin
2022-04-12 23:46 ` [PATCH v2 10/14] Fetch the NT_ARM_TLS register set for native FreeBSD/Aarch64 processes John Baldwin
2022-04-12 23:46 ` [PATCH v2 11/14] NEWS: Add a note for TLS support on FreeBSD/arm and FreeBSD/Aarch64 John Baldwin
2022-04-13  2:31   ` Eli Zaretskii
2022-04-12 23:46 ` John Baldwin [this message]
2022-04-12 23:46 ` [PATCH v2 13/14] gdbserver: Read the tpidr register from NT_ARM_TLS on Linux John Baldwin
2022-04-12 23:46 ` [PATCH v2 14/14] " John Baldwin

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=20220412234647.84595-13-jhb@FreeBSD.org \
    --to=jhb@freebsd.org \
    --cc=gdb-patches@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: link
Be 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).