From 639951a89c6c62aa98c054ad40487feb865c0606 Mon Sep 17 00:00:00 2001 From: Maria Yu Date: Thu, 29 May 2014 14:15:54 +0800 Subject: [PATCH] lib: debug: add dump frame info in panic Dump frame info when panic occurs. Change-Id: I7332a9dcb31c842ff549e806a1a3acc598ce4681 --- arch/arm/asm.S | 2 +- arch/arm/faults.c | 2 +- include/debug.h | 2 ++ lib/debug/debug.c | 14 ++++++++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/arch/arm/asm.S b/arch/arm/asm.S index 97ebc73f1..39b8dca4f 100644 --- a/arch/arm/asm.S +++ b/arch/arm/asm.S @@ -69,7 +69,7 @@ FUNCTION(arm_context_switch) FUNCTION(arm_save_mode_regs) mrs r1, cpsr -#if ARM_ISA_ARMv6 +#if ARM_ISA_ARMv6 || ARM_ISA_ARMV7 cps #0x11 /* fiq */ str r13, [r0], #4 str r14, [r0], #4 diff --git a/arch/arm/faults.c b/arch/arm/faults.c index 020266ae7..1b412ac4c 100644 --- a/arch/arm/faults.c +++ b/arch/arm/faults.c @@ -24,7 +24,7 @@ #include #include -static void dump_fault_frame(struct arm_fault_frame *frame) +void dump_fault_frame(struct arm_fault_frame *frame) { dprintf(CRITICAL, "r0 0x%08x r1 0x%08x r2 0x%08x r3 0x%08x\n", frame->r[0], frame->r[1], frame->r[2], frame->r[3]); dprintf(CRITICAL, "r4 0x%08x r5 0x%08x r6 0x%08x r7 0x%08x\n", frame->r[4], frame->r[5], frame->r[6], frame->r[7]); diff --git a/include/debug.h b/include/debug.h index bcf73c5a2..d4bce5457 100644 --- a/include/debug.h +++ b/include/debug.h @@ -64,6 +64,8 @@ int dgetc(char *c, bool wait); /* systemwide halts */ void halt(void); +void dump_frame(void *frame); + void _panic(void *caller, const char *fmt, ...) __PRINTFLIKE(2, 3); #define panic(x...) _panic(__GET_CALLER(), x) diff --git a/lib/debug/debug.c b/lib/debug/debug.c index 84d0678b1..f239bbeea 100644 --- a/lib/debug/debug.c +++ b/lib/debug/debug.c @@ -35,6 +35,9 @@ #include #include #include +#if ARCH_ARM +#include +#endif void __attribute__ ((noreturn)) __stack_chk_fail (void) @@ -56,8 +59,19 @@ void halt(void) platform_halt(); } +void dump_frame(void *frame) +{ + enter_critical_section(); // disable ints +#if ARCH_ARM + dump_fault_frame((struct arm_fault_frame *)frame); +#endif + exit_critical_section(); // disable ints +} + void _panic(void *caller, const char *fmt, ...) { + dprintf(ALWAYS, "panic (frame %p): \n", __GET_FRAME()); + dump_frame(__GET_FRAME()); dprintf(ALWAYS, "panic (caller %p): ", caller); va_list ap;