diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-09-15 15:03:55 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-09-15 15:03:55 -0600 |
commit | c7d376387a9cbc102db40ad249d6014363b3508d (patch) | |
tree | 5c464a557b0d72498c73f36fb0180088670a0fc0 | |
parent | 3d4df2aed2b7fe2294e72b03cebc033ba72c4688 (diff) | |
download | px4-nuttx-c7d376387a9cbc102db40ad249d6014363b3508d.tar.gz px4-nuttx-c7d376387a9cbc102db40ad249d6014363b3508d.tar.bz2 px4-nuttx-c7d376387a9cbc102db40ad249d6014363b3508d.zip |
ARMv7-A: Improvements to assertion output for kernel mode
-rw-r--r-- | nuttx/arch/arm/src/armv7-a/arm_assert.c | 84 |
1 files changed, 45 insertions, 39 deletions
diff --git a/nuttx/arch/arm/src/armv7-a/arm_assert.c b/nuttx/arch/arm/src/armv7-a/arm_assert.c index f490a518b..1741b878b 100644 --- a/nuttx/arch/arm/src/armv7-a/arm_assert.c +++ b/nuttx/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,38 +211,54 @@ 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 +#endif - /* Does the current stack pointer lie within the interrupt - * stack? - */ + /* Show user stack info */ + + lldbg("User stack:\n"); + lldbg(" base: %08x\n", ustackbase); + lldbg(" size: %08x\n", ustacksize); +#ifdef CONFIG_DEBUG_STACK + lldbg(" used: %08x\n", up_check_tcbstack(rtcb)); +#endif - if (sp > istackbase || sp <= istackbase - istacksize) +#ifdef CONFIG_ARCH_KERNEL_STACK + /* This this thread have a kernel stack allocated? */ + + if (rtcb->xcp.kstack) { - if (up_interrupt_context()) - { - lldbg("ERROR: Stack pointer is not within interrupt stack\n"); - } + 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 (sp <= istackbase && sp > istackbase - istacksize) +#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 @@ -247,44 +266,31 @@ static void up_dumpstate(void) */ sp = g_intstackbase; - lldbg("sp: %08x\n", sp); + lldbg("User sp: %08x\n", sp); } - - /* Show user stack info */ - - lldbg("User stack:\n"); - lldbg(" base: %08x\n", ustackbase); - lldbg(" size: %08x\n", ustacksize); -#ifdef CONFIG_DEBUG_STACK - 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)); -#endif #endif /* Dump the user stack if the stack pointer lies within the allocated user * stack memory. */ - if (sp > ustackbase || sp <= ustackbase - ustacksize) + if (sp > ustackbase - ustacksize && sp < ustackbase) { -#if defined(CONFIG_ARCH_INTERRUPTSTACK) && CONFIG_ARCH_INTERRUPTSTACK > 3 - if (!up_interrupt_context()) -#endif - { - lldbg("ERROR: Stack pointer is not within allocated stack\n"); - } + lldbg("User Stack\n", sp); + up_stackdump(sp, ustackbase); } - else + +#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) { - up_stackdump(sp, ustackbase); + lldbg("Kernel Stack\n", sp); + up_stackdump(sp, kstackbase); } +#endif /* Then dump the registers (if available) */ |