Merge "lib: debug: add dump frame info in panic"
diff --git a/arch/arm/asm.S b/arch/arm/asm.S
index 97ebc73..39b8dca 100644
--- a/arch/arm/asm.S
+++ b/arch/arm/asm.S
@@ -69,7 +69,7 @@
 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 020266a..1b412ac 100644
--- a/arch/arm/faults.c
+++ b/arch/arm/faults.c
@@ -24,7 +24,7 @@
 #include <arch/arm.h>
 #include <kernel/thread.h>
 
-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 bcf73c5..d4bce54 100644
--- a/include/debug.h
+++ b/include/debug.h
@@ -64,6 +64,8 @@
 /* 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 84d0678..f239bbe 100644
--- a/lib/debug/debug.c
+++ b/lib/debug/debug.c
@@ -35,6 +35,9 @@
 #include <kernel/thread.h>
 #include <kernel/timer.h>
 #include <rand.h>
+#if ARCH_ARM
+#include <arch/arm.h>
+#endif
 
 void __attribute__ ((noreturn))
 __stack_chk_fail (void)
@@ -56,8 +59,19 @@
 	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;