Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: <Ezra.Sitorus@arm.com>
To: <gdb-patches@sourceware.org>
Cc: <luis.machado.foss@gmail.com>, <thiago.bauermann@linaro.org>,
	Ezra Sitorus <ezra.sitorus@arm.com>
Subject: [PATCH v2 4/5] gdb/aarch64: core file support for FPMR
Date: Tue, 7 Oct 2025 13:31:31 +0100	[thread overview]
Message-ID: <20251007123132.26769-5-Ezra.Sitorus@arm.com> (raw)
In-Reply-To: <20251007123132.26769-1-Ezra.Sitorus@arm.com>

From: Ezra Sitorus <ezra.sitorus@arm.com>

Add support for FPMR dumps/reads for core files.
---
Changes from v1->v2:
* Addressed comments/whitespace/formatting issues.

Ezra

 gdb/aarch64-linux-tdep.c | 66 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index e905be40a8d..5b4bc56210f 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -1518,6 +1518,55 @@ aarch64_linux_collect_zt_regset (const struct regset *regset,
 			    AARCH64_SME2_ZT0_SIZE);
 }
 
+/* Supply register REGNUM from BUF to REGCACHE, using the register map
+   in REGSET.  If REGNUM is -1, do this for all registers in REGSET.
+   If BUF is NULL, set the registers to "unavailable" status.  */
+
+static void
+aarch64_linux_supply_fpmr_regset (const struct regset *regset,
+				  struct regcache *regcache, int regnum,
+				  const void *buf, size_t size)
+{
+  /* Read the FPMR note from a core file into the register buffer.  */
+
+  /* Make sure the buffer contains at least the expected amount of data we are
+     supposed to get.  */
+  gdb_assert (size >= sizeof (uint64_t));
+
+  /* Handle an empty buffer.  */
+  if (buf == nullptr)
+    return regcache->supply_regset (regset, regnum, nullptr, size);
+
+  aarch64_gdbarch_tdep *tdep
+      = gdbarch_tdep<aarch64_gdbarch_tdep> (regcache->arch ());
+
+  /* Supply the FPMR register contents.  */
+  regcache->raw_supply (tdep->fpmr_regnum, buf);
+}
+
+/* Collect register REGNUM from REGCACHE to BUF, using the register
+   map in REGSET.  If REGNUM is -1, do this for all registers in
+   REGSET.  */
+
+static void
+aarch64_linux_collect_fpmr_regset (const struct regset *regset,
+				   const struct regcache *regcache, int regnum,
+				   void *buf, size_t size)
+{
+  /* Read the FPMR contents from the register buffer into the core
+     file section.  */
+
+  /* Make sure the buffer can hold the data we need to return.  */
+  gdb_assert (size >= sizeof (uint64_t));
+  gdb_assert (buf != nullptr);
+
+  aarch64_gdbarch_tdep *tdep
+      = gdbarch_tdep<aarch64_gdbarch_tdep> (regcache->arch ());
+
+  /* Dump the register cache contents for the FPMR to the buffer.  */
+  regcache->collect_regset (regset, tdep->fpmr_regnum, buf, sizeof (uint64_t));
+}
+
 /* Implement the "iterate_over_regset_sections" gdbarch method.  */
 
 static void
@@ -1635,6 +1684,23 @@ aarch64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
 	}
     }
 
+  if (tdep->has_fpmr ())
+    {
+      const struct regcache_map_entry fpmr_regmap[] =
+	{
+	  { 1, tdep->fpmr_regnum, sizeof (uint64_t) }
+	};
+
+	const struct regset aarch64_linux_fpmr_regset =
+	{
+	  fpmr_regmap, aarch64_linux_supply_fpmr_regset,
+	  aarch64_linux_collect_fpmr_regset
+	};
+
+	cb (".reg-aarch-fpmr", sizeof (uint64_t), sizeof (uint64_t),
+	    &aarch64_linux_fpmr_regset, "FPMR", cb_data);
+    }
+
   if (tdep->has_pauth ())
     {
       /* Create this on the fly in order to handle the variable location.  */
-- 
2.45.2


  parent reply	other threads:[~2025-10-07 12:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-07 12:31 [PATCH v2 0/5] gdb/aarch64: Support " Ezra.Sitorus
2025-10-07 12:31 ` [PATCH v2 1/5] gdb/aarch64: Enable FPMR for AArch64 in gdb on Linux Ezra.Sitorus
2025-10-11 11:35   ` Luis
2025-10-07 12:31 ` [PATCH v2 2/5] gdbserver/aarch64: Enable FPMR for AArch64 in gdbserver " Ezra.Sitorus
2025-10-11 11:50   ` Luis
2025-10-13 13:40     ` Richard Earnshaw
2025-10-13 14:53       ` Ezra Sitorus
2025-10-16 22:01         ` Luis
2025-10-07 12:31 ` [PATCH v2 3/5] gdb/aarch64: signal frame support for fpmr Ezra.Sitorus
2025-10-11 11:57   ` Luis
2025-10-11 12:15   ` Luis
2025-10-07 12:31 ` Ezra.Sitorus [this message]
2025-10-11 12:03   ` [PATCH v2 4/5] gdb/aarch64: core file support for FPMR Luis
2025-10-07 12:31 ` [PATCH v2 5/5] gdb/aarch64: Tests for fpmr Ezra.Sitorus
2025-10-11 12:53   ` Luis
2025-10-11 12:05 ` [PATCH v2 0/5] gdb/aarch64: Support for FPMR Luis

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=20251007123132.26769-5-Ezra.Sitorus@arm.com \
    --to=ezra.sitorus@arm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=luis.machado.foss@gmail.com \
    --cc=thiago.bauermann@linaro.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