Read the tpidr register from NT_ARM_TLS core dump notes on Linux Aarch64.
authorJohn Baldwin <jhb@FreeBSD.org>
Tue, 3 May 2022 23:05:10 +0000 (16:05 -0700)
committerJohn Baldwin <jhb@FreeBSD.org>
Tue, 3 May 2022 23:05:10 +0000 (16:05 -0700)
gdb/aarch64-linux-tdep.c
gdb/aarch64-linux-tdep.h

index 8cfb64d9f4a03a2dfc1f17f1c473752a8a84490a..dbebcd4f0e02a9e19985b9e9c5670e5709bac286 100644 (file)
@@ -749,6 +749,24 @@ 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 ())
+    {
+      const struct regcache_map_entry tls_regmap[] =
+       {
+         { 1, tdep->tls_regnum, 8 },
+         { 0 }
+       };
+
+      const struct regset aarch64_linux_tls_regset =
+       {
+         tls_regmap, regcache_supply_regset, regcache_collect_regset
+       };
+
+      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 +775,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
index 8ae33efc605a2c0608925b4871b7c97cfec0b36b..9a7e4339dba82b27a814ebad4041f3414421e921 100644 (file)
@@ -39,6 +39,9 @@
 /* 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;