From 4511ae80b9049ecbd8b8002b6c17a52e5b360bbd Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Tue, 3 May 2016 15:37:32 +1000 Subject: [PATCH] Dump register state on fatal exception --- core/debug_dumps.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/core/debug_dumps.c b/core/debug_dumps.c index 6075f40..5878ae8 100644 --- a/core/debug_dumps.c +++ b/core/debug_dumps.c @@ -68,6 +68,22 @@ void dump_stack(uint32_t *sp) { } } +/* Dump exception status registers as stored above 'sp' + by the interrupt handler preamble +*/ +void dump_exception_registers(uint32_t *sp) { + uint32_t excsave1; + uint32_t *saved = sp - (0x50 / sizeof(uint32_t)); + printf("Registers:\n"); + RSR(excsave1, excsave1); + printf("a0 %08x ", excsave1); + printf("a1 %08x ", (intptr_t)sp); + for(int a = 2; a < 14; a++) { + printf("a%-2d %08x%c", a, saved[a+3], a == 3 || a == 7 || a == 11 ? '\n':' '); + } + printf("SAR %08x\n", saved[0x13]); +} + void IRAM fatal_exception_handler(uint32_t *sp) { if (!sdk_NMIIrqIsOn) { vPortEnterCritical(); @@ -78,11 +94,12 @@ void IRAM fatal_exception_handler(uint32_t *sp) { Cache_Read_Disable(); Cache_Read_Enable(0, 0, 1); dump_excinfo(); - if (sp) + if (sp) { + dump_exception_registers(sp); dump_stack(sp); + } uart_flush_txfifo(0); uart_flush_txfifo(1); sdk_system_restart_in_nmi(); while(1) {} } -