public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Torbjörn SVENSSON" <torbjorn.svensson@foss.st.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH v2] gdb/arm: Unwind S-registers for exception frames
Date: Tue, 11 Oct 2022 10:00:26 +0200	[thread overview]
Message-ID: <20221011080025.567502-1-torbjorn.svensson@foss.st.com> (raw)

After sending the v1 patch yesterday, I had an epiphany that the solution could be simplified.
The v2 of the patch is an alternative implementation that appears to work equally well.
Which do you prefer?


Save the address on the stack that contains the value for the
S-register when unwinding, just like already done for the
D-registers.

Signed-off-by: Torbjörn SVENSSON  <torbjorn.svensson@foss.st.com>
---
 gdb/arm-tdep.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index d357066653b..f725d437825 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -3625,10 +3625,13 @@ arm_m_exception_cache (struct frame_info *this_frame)
 	  if (read_fp_regs_from_stack)
 	    {
 	      CORE_ADDR addr = unwound_sp + sp_r0_offset + 0x20;
-	      for (int i = 0; i < 8; i++)
+	      for (int i = 0; i < 16; i++)
 		{
-		  cache->saved_regs[ARM_D0_REGNUM + i].set_addr (addr);
-		  addr += 8;
+		  if (tdep->have_s_pseudos)
+		    cache->saved_regs[tdep->s_pseudo_base + i].set_addr (addr);
+		  if (i % 2 == 0)
+		    cache->saved_regs[ARM_D0_REGNUM + i].set_addr (addr);
+		  addr += 4;
 		}
 	    }
 	  cache->saved_regs[ARM_FPSCR_REGNUM].set_addr (unwound_sp
@@ -3641,10 +3644,14 @@ arm_m_exception_cache (struct frame_info *this_frame)
 	      if (read_fp_regs_from_stack)
 		{
 		  CORE_ADDR addr = unwound_sp + sp_r0_offset + 0x68;
-		  for (int i = 8; i < 16; i++)
+		  for (int i = 16; i < 32; i++)
 		    {
-		      cache->saved_regs[ARM_D0_REGNUM + i].set_addr (addr);
-		      addr += 8;
+		      if (tdep->have_s_pseudos)
+			cache->saved_regs[tdep->s_pseudo_base + i]
+			  .set_addr (addr);
+		      if (i % 2 == 0)
+			cache->saved_regs[ARM_D0_REGNUM + i].set_addr (addr);
+		      addr += 4;
 		    }
 		}
 
-- 
2.25.1


             reply	other threads:[~2022-10-11  8:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-11  8:00 Torbjörn SVENSSON [this message]
2022-10-11 16:34 ` 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=20221011080025.567502-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).