public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 1/5] gdb/arm: Fix prologue analysis to support vpush
@ 2022-01-27 13:32 Christophe Lyon
  2022-01-27 13:32 ` [PATCH v2 2/5] gdb/arm: Define MSP and PSP registers for M-Profile Christophe Lyon
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Christophe Lyon @ 2022-01-27 13:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: torbjorn.svensson, Christophe Lyon

While working on adding support for Non-secure/Secure modes unwinding,
I noticed that the prologue analysis lacked support for vpush, which
is used for instance in the CMSE stub routine.

This patch updates thumb_analyze_prologue accordingly, adding support
for vpush of D-registers.
---
 gdb/arm-tdep.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 7495434484e..7d52d2d78f6 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -896,6 +896,31 @@ thumb_analyze_prologue (struct gdbarch *gdbarch,
 		regs[bits (insn, 0, 3)] = addr;
 	    }
 
+	  else if ((insn & 0xff20) == 0xed20    /* vstmdb Rn{!}, { D-registers} */
+		   && (inst2 & 0x0f00) == 0x0b00/* (aka vpush) */
+		   && pv_is_register (regs[bits (insn, 0, 3)], ARM_SP_REGNUM))
+	    {
+	      /* Address SP points to.  */
+	      pv_t addr = regs[bits (insn, 0, 3)];
+
+	      /* Number of registers saved.  */
+	      int number = bits (inst2, 0, 7) >> 1;
+
+	      if (stack.store_would_trash (addr))
+		break;
+
+	      /* Calculate offsets of saved registers.  */
+	      for (; number > 0; number--)
+		{
+		  addr = pv_add_constant (addr, -8);
+		  stack.store (addr, 8, pv_register (ARM_D0_REGNUM + number, 0));
+		}
+
+	      /* Writeback SP if needed.  */
+	      if (insn & 0x0020)
+		regs[bits (insn, 0, 3)] = addr;
+	    }
+
 	  else if ((insn & 0xff50) == 0xe940	/* strd Rt, Rt2,
 						   [Rn, #+/-imm]{!} */
 		   && pv_is_register (regs[bits (insn, 0, 3)], ARM_SP_REGNUM))
-- 
2.25.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-02-06 16:41 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-27 13:32 [PATCH v2 1/5] gdb/arm: Fix prologue analysis to support vpush Christophe Lyon
2022-01-27 13:32 ` [PATCH v2 2/5] gdb/arm: Define MSP and PSP registers for M-Profile Christophe Lyon
2022-02-06 15:41   ` Joel Brobecker
2022-01-27 13:32 ` [PATCH v2 3/5] gdb/arm: Introduce arm_cache_init Christophe Lyon
2022-02-06 15:52   ` Joel Brobecker
2022-01-27 13:32 ` [PATCH v2 4/5] gdb/arm: Add support for multiple stack pointers on Cortex-M Christophe Lyon
2022-02-06 16:07   ` Joel Brobecker
2022-01-27 13:32 ` [PATCH v2 5/5] gdb/arm: Extend arm_m_addr_is_magic to support FNC_RETURN, add unwind-ns-to-s command Christophe Lyon
2022-02-06 16:18   ` Joel Brobecker
2022-02-06 16:41     ` Eli Zaretskii
2022-02-06 15:30 ` [PATCH v2 1/5] gdb/arm: Fix prologue analysis to support vpush Joel Brobecker

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).