public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Luis Machado <luis.machado@arm.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH v2 11/17] [gdb/aarch64] sme: Support TPIDR2 signal frame context
Date: Fri, 19 May 2023 11:25:02 +0100	[thread overview]
Message-ID: <20230519102508.14020-12-luis.machado@arm.com> (raw)
In-Reply-To: <20230519102508.14020-1-luis.machado@arm.com>

The Linux Kernel defines a separate context for the TPIDR2 register in a
signal frame.  Handle this additional context in gdb so this register
gets restored properly when unwinding through signal frames.

The TPIDR2 register is closely related to SME, and is available when SME
support is reported.

This is tested by testcases that are available in a later patch in the series.

Regressions-tested on aarch64-linux Ubuntu 22.04/20.04.
---
 gdb/aarch64-linux-tdep.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index c973a790f62..7ce34ee6846 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -154,6 +154,7 @@
 #define AARCH64_FPSIMD_MAGIC			0x46508001
 #define AARCH64_SVE_MAGIC			0x53564501
 #define AARCH64_ZA_MAGIC			0x54366345
+#define AARCH64_TPIDR2_MAGIC			0x54504902
 
 /* Defines for the extra_context that follows an AARCH64_EXTRA_MAGIC.  */
 #define AARCH64_EXTRA_DATAP_OFFSET		8
@@ -184,6 +185,9 @@
 #define AARCH64_SME_CONTEXT_SIZE(svq) \
   (AARCH64_SME_CONTEXT_REGS_OFFSET + AARCH64_SME_CONTEXT_ZA_SIZE (svq))
 
+/* TPIDR2 register value offset in the TPIDR2 signal frame context.  */
+#define AARCH64_TPIDR2_CONTEXT_TPIDR2_OFFSET	8
+
 /* Holds information about the signal frame.  */
 struct aarch64_linux_sigframe
 {
@@ -204,6 +208,8 @@ struct aarch64_linux_sigframe
   CORE_ADDR sve_section = 0;
   /* Starting address of the section containing the ZA register.  */
   CORE_ADDR za_section = 0;
+  /* Starting address of the section containing the TPIDR2 register.  */
+  CORE_ADDR tpidr2_section = 0;
   /* Starting address of the section containing extra information.  */
   CORE_ADDR extra_section = 0;
 
@@ -465,6 +471,13 @@ aarch64_linux_read_signal_frame_info (frame_info_ptr this_frame,
 	    break;
 	  }
 
+	case AARCH64_TPIDR2_MAGIC:
+	  {
+	    /* This is context containing the tpidr2 register.  */
+	    signal_frame.tpidr2_section = section;
+	    section += size;
+	    break;
+	  }
 	case AARCH64_EXTRA_MAGIC:
 	  {
 	    /* Extra is always the last valid section in reserved and points to
@@ -607,6 +620,17 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self,
 				sve_vg_from_vl (signal_frame.svl));
     }
 
+  /* Restore the tpidr2 register, if the target supports it and if there is
+     an entry for it.  */
+  if (signal_frame.tpidr2_section != 0 && tdep->has_tls ()
+      && tdep->tls_register_count >= 2)
+    {
+      /* Restore tpidr2.  */
+      trad_frame_set_reg_addr (this_cache, tdep->tls_regnum_base + 1,
+			       signal_frame.tpidr2_section
+			       + AARCH64_TPIDR2_CONTEXT_TPIDR2_OFFSET);
+    }
+
   trad_frame_set_id (this_cache, frame_id_build (signal_frame.sp, func));
 }
 
-- 
2.25.1


  parent reply	other threads:[~2023-05-19 10:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-19 10:24 [PATCH v2 00/17] SME support for AArch64 gdb/gdbserver on Linux Luis Machado
2023-05-19 10:24 ` [PATCH v2 01/17] [gdb/aarch64] Fix register fetch/store order for native AArch64 Linux Luis Machado
2023-05-19 10:24 ` [PATCH v2 02/17] [gdb/aarch64] refactor: Rename SVE-specific files Luis Machado
2023-05-19 10:24 ` [PATCH v2 03/17] [gdb/gdbserver] refactor: Simplify SVE interface to read/write registers Luis Machado
2023-05-19 10:24 ` [PATCH v2 04/17] [gdb/aarch64] sve: Fix return command when using V registers in a SVE-enabled target Luis Machado
2023-05-19 10:24 ` [PATCH v2 05/17] [gdb/aarch64] sme: Enable SME registers and pseudo-registers Luis Machado
2023-05-19 10:24 ` [PATCH v2 06/17] [gdbserver/aarch64] refactor: Adjust expedited registers dynamically Luis Machado
2023-05-19 10:24 ` [PATCH v2 07/17] [gdbserver/aarch64] sme: Add support for SME Luis Machado
2023-05-19 10:24 ` [PATCH v2 08/17] [gdb/aarch64] sve: Fix signal frame z/v register restore Luis Machado
2023-05-19 10:25 ` [PATCH v2 09/17] [gdb/aarch64] sme: Signal frame support Luis Machado
2023-05-19 10:25 ` [PATCH v2 10/17] [gdb/aarch64] sme: Fixup sigframe gdbarch when vg/svg changes Luis Machado
2023-05-19 10:25 ` Luis Machado [this message]
2023-05-19 10:25 ` [PATCH v2 12/17] [binutils/aarch64] sme: Core file support Luis Machado
2023-05-19 10:25 ` [PATCH v2 13/17] [gdb/generic] corefile/bug: Use thread-specific gdbarch when dumping register state to core files Luis Machado
2023-05-19 10:25 ` [PATCH v2 14/17] [gdb/generic] corefile/bug: Fixup (gcore) core file target description reading order Luis Machado
2023-05-19 10:25 ` [PATCH v2 15/17] [gdb/aarch64] sme: Core file support for Linux Luis Machado
2023-05-19 10:25 ` [PATCH v2 16/17] [gdb/testsuite] sme: Add SVE/SME testcases Luis Machado
2023-05-19 10:25 ` [PATCH v3 17/17] [gdb/docs] sme: Document SME registers and features Luis Machado
2023-05-19 11:20   ` Eli Zaretskii
2023-06-30 12:10     ` Luis Machado

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=20230519102508.14020-12-luis.machado@arm.com \
    --to=luis.machado@arm.com \
    --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).