Skip to content
This repository was archived by the owner on Jan 8, 2025. It is now read-only.

Commit

Permalink
lib: debug: add dump frame info in panic
Browse files Browse the repository at this point in the history
Dump frame info when panic occurs.

Change-Id: I7332a9dcb31c842ff549e806a1a3acc598ce4681
  • Loading branch information
sixtaku committed Sep 23, 2014
1 parent 99caaa7 commit 639951a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion arch/arm/asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/faults.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 2 additions & 0 deletions include/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
14 changes: 14 additions & 0 deletions lib/debug/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down

0 comments on commit 639951a

Please sign in to comment.