From: "Torbjörn SVENSSON" <torbjorn.svensson@foss.st.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH] gdb/arm: Properly unwind S-registers for exception frames
Date: Mon, 10 Oct 2022 20:09:47 +0200 [thread overview]
Message-ID: <20221010180946.528256-1-torbjorn.svensson@foss.st.com> (raw)
For each D-register, there are 2 S-registers. In the GDB
architecture, the S-registers are implemented as pseudo registers.
As the value for the S-registers can be stacked, the value needs to
be extracted from the corresponding D-register and returned in the
associated prev_register function.
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
---
gdb/arm-tdep.c | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index d357066653b..7168e2a5edc 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -261,6 +261,8 @@ static void arm_neon_quad_write (struct gdbarch *gdbarch,
static CORE_ADDR
arm_get_next_pcs_syscall_next_pc (struct arm_get_next_pcs *self);
+static bool is_s_pseudo (struct gdbarch *gdbarch, int regnum);
+
/* get_next_pcs operations. */
static struct arm_get_next_pcs_ops arm_get_next_pcs_ops = {
@@ -3726,8 +3728,8 @@ arm_m_exception_prev_register (struct frame_info *this_frame,
cache = (struct arm_prologue_cache *) *this_cache;
/* The value was already reconstructed into PREV_SP. */
- arm_gdbarch_tdep *tdep
- = gdbarch_tdep<arm_gdbarch_tdep> (get_frame_arch (this_frame));
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
if (prev_regnum == ARM_SP_REGNUM)
return frame_unwind_got_constant (this_frame, prev_regnum,
arm_cache_get_prev_sp_value (cache, tdep));
@@ -3756,7 +3758,6 @@ arm_m_exception_prev_register (struct frame_info *this_frame,
pattern. */
if (prev_regnum == ARM_PS_REGNUM)
{
- struct gdbarch *gdbarch = get_frame_arch (this_frame);
struct value *value = trad_frame_get_prev_register (this_frame,
cache->saved_regs,
ARM_PC_REGNUM);
@@ -3770,6 +3771,30 @@ arm_m_exception_prev_register (struct frame_info *this_frame,
return frame_unwind_got_constant (this_frame, ARM_PS_REGNUM, xpsr);
}
+ /* If we are asked to unwind Sn, unwind Dm where m is n/2 and take the
+ corresponding part of the D register. */
+ if (is_s_pseudo (gdbarch, prev_regnum))
+ {
+ int single_regnum = prev_regnum - tdep->s_pseudo_base;
+ int double_regnum = ARM_D0_REGNUM + single_regnum / 2;
+ int offset;
+
+ struct value *value = trad_frame_get_prev_register (this_frame,
+ cache->saved_regs,
+ double_regnum);
+
+ gdb::array_view<const gdb_byte> raw = value_contents (value);
+
+ /* s0 is always the least significant half of d0. */
+ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
+ offset = (single_regnum & 1) ? 0 : 4;
+ else
+ offset = (single_regnum & 1) ? 4 : 0;
+
+ return frame_unwind_got_bytes (this_frame, prev_regnum,
+ raw.slice (offset).data ());
+ }
+
return trad_frame_get_prev_register (this_frame, cache->saved_regs,
prev_regnum);
}
--
2.25.1
reply other threads:[~2022-10-10 18:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20221010180946.528256-1-torbjorn.svensson@foss.st.com \
--to=torbjorn.svensson@foss.st.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).