From d14d3b29bb4cfa1aa5808fdd2ede101c98faacc0 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 15 Sep 2014 15:03:55 -0600 Subject: [PATCH] ARMv7-A: Improvements to assertion output for kernel mode --- arch/arm/src/armv7-a/arm_assert.c | 96 ++++++++++++++++--------------- 1 file changed, 51 insertions(+), 45 deletions(-) diff --git a/arch/arm/src/armv7-a/arm_assert.c b/arch/arm/src/armv7-a/arm_assert.c index f490a518ba8..1741b878ba0 100644 --- a/arch/arm/src/armv7-a/arm_assert.c +++ b/arch/arm/src/armv7-a/arm_assert.c @@ -194,6 +194,9 @@ static void up_dumpstate(void) uint32_t istackbase; uint32_t istacksize; #endif +#ifdef CONFIG_ARCH_KERNEL_STACK + uint32_t kstackbase = 0; +#endif /* Get the limits on the user stack memory */ @@ -208,47 +211,23 @@ static void up_dumpstate(void) ustacksize = (uint32_t)rtcb->adj_stack_size; } - /* Get the limits on the interrupt stack memory */ + lldbg("Current sp: %08x\n", sp); #if CONFIG_ARCH_INTERRUPTSTACK > 3 + /* Get the limits on the interrupt stack memory */ + istackbase = (uint32_t)&g_intstackbase; istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3); /* Show interrupt stack info */ - lldbg("sp: %08x\n", sp); - lldbg("IRQ stack:\n"); + lldbg("Interrupt stack:\n"); lldbg(" base: %08x\n", istackbase); lldbg(" size: %08x\n", istacksize); #ifdef CONFIG_DEBUG_STACK lldbg(" used: %08x\n", up_check_intstack()); #endif - - /* Does the current stack pointer lie within the interrupt - * stack? - */ - - if (sp > istackbase || sp <= istackbase - istacksize) - { - if (up_interrupt_context()) - { - lldbg("ERROR: Stack pointer is not within interrupt stack\n"); - } - } - - if (sp <= istackbase && sp > istackbase - istacksize) - { - /* Yes.. dump the interrupt stack */ - - up_stackdump(sp, istackbase); - - /* Extract the user stack pointer which should lie - * at the base of the interrupt stack. - */ - - sp = g_intstackbase; - lldbg("sp: %08x\n", sp); - } +#endif /* Show user stack info */ @@ -259,33 +238,60 @@ static void up_dumpstate(void) lldbg(" used: %08x\n", up_check_tcbstack(rtcb)); #endif -#else - lldbg("sp: %08x\n", sp); - lldbg("stack base: %08x\n", ustackbase); - lldbg("stack size: %08x\n", ustacksize); -#ifdef CONFIG_DEBUG_STACK - lldbg("stack used: %08x\n", up_check_tcbstack(rtcb)); +#ifdef CONFIG_ARCH_KERNEL_STACK + /* This this thread have a kernel stack allocated? */ + + if (rtcb->xcp.kstack) + { + uint32_t kstackbase = (uint32_t)rtcb->xcp.kstack + CONFIG_ARCH_KERNEL_STACKSIZE - 4; + + lldbg("Kernel stack:\n"); + lldbg(" base: %08x\n", kstackbase); + lldbg(" size: %08x\n", CONFIG_ARCH_KERNEL_STACKSIZE); + } #endif + +#if CONFIG_ARCH_INTERRUPTSTACK > 3 + /* Does the current stack pointer lie within the interrupt stack? */ + + if (sp > istackbase - istacksize && sp < istackbase) + { + /* Yes.. dump the interrupt stack */ + + lldbg("Interrupt Stack\n", sp); + up_stackdump(sp, istackbase); + + /* Extract the user stack pointer which should lie + * at the base of the interrupt stack. + */ + + sp = g_intstackbase; + lldbg("User sp: %08x\n", sp); + } #endif /* Dump the user stack if the stack pointer lies within the allocated user * stack memory. */ - if (sp > ustackbase || sp <= ustackbase - ustacksize) - { -#if defined(CONFIG_ARCH_INTERRUPTSTACK) && CONFIG_ARCH_INTERRUPTSTACK > 3 - if (!up_interrupt_context()) -#endif - { - lldbg("ERROR: Stack pointer is not within allocated stack\n"); - } - } - else + if (sp > ustackbase - ustacksize && sp < ustackbase) { + lldbg("User Stack\n", sp); up_stackdump(sp, ustackbase); } +#ifdef CONFIG_ARCH_KERNEL_STACK + /* Dump the user stack if the stack pointer lies within the allocated + * kernel stack memory. + */ + + if (sp >= (uint32_t)rtcb->xcp.kstack && sp < kstackbase) + { + lldbg("Kernel Stack\n", sp); + up_stackdump(sp, kstackbase); + } +#endif + /* Then dump the registers (if available) */ up_registerdump();