kernel/os; fix crash_restore_regs for m4 when FP registers
are pushed to exception stack.
@@ -174,7 +174,7 @@ os_default_irq(struct trap_frame *tf)
struct coredump_regs regs;
#endif
#if MYNEWT_VAL(OS_CRASH_RESTORE_REGS)
- uint32_t *orig_sp;
+ uint32_t orig_sp;
#endif
console_blocking_mode();
@@ -212,10 +212,19 @@ os_default_irq(struct trap_frame *tf)
#if MYNEWT_VAL(OS_CRASH_RESTORE_REGS)
if (((SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) < 16) &&
hal_debugger_connected()) {
- orig_sp = &tf->ef->r0;
- orig_sp += 8;
- if (tf->ef->psr & SCB_CCR_STKALIGN_Msk) {
- orig_sp++;
+ if ((tf->lr & 0x10) == 0) {
+ /*
+ * Extended frame
+ */
+ orig_sp = ((uint32_t)tf->ef) + 0x68;
+ if (tf->ef->psr & (1 << 9)) {
+ orig_sp += 4;
+ }
+ } else {
+ orig_sp = ((uint32_t)tf->ef) + 0x20;
+ if ((SCB->CCR & SCB_CCR_STKALIGN_Msk) & tf->ef->psr & (1 << 9)) {
+ orig_sp += 4;
+ }
}
console_printf("Use 'set $pc = 0x%08lx' to restore PC in gdb\n",
