arch/ all assertion functinos: up_stackdump dump the full stack if stack overflow the stack info is very useful to find the backtrace

This commit is contained in:
Xiang Xiao 2018-11-11 12:52:36 -06:00 committed by Gregory Nutt
parent e4106a3744
commit dfe788be25
18 changed files with 157 additions and 38 deletions

View File

@ -245,6 +245,11 @@ static void up_dumpstate(void)
sp = g_intstackbase;
_alert("sp: %08x\n", sp);
}
else if (CURRENT_REGS)
{
_alert("ERROR: Stack pointer is not within the interrupt stack\n");
up_stackdump(istackbase - istacksize, istackbase);
}
/* Show user stack info */
@ -270,9 +275,8 @@ static void up_dumpstate(void)
if (sp > ustackbase || sp <= ustackbase - ustacksize)
{
#if !defined(CONFIG_ARCH_INTERRUPTSTACK) || CONFIG_ARCH_INTERRUPTSTACK < 4
_alert("ERROR: Stack pointer is not within allocated stack\n");
#endif
up_stackdump(ustackbase - ustacksize, ustackbase);
}
else
{

View File

@ -275,6 +275,11 @@ static void up_dumpstate(void)
up_stackdump(sp, istackbase);
}
else if (CURRENT_REGS)
{
_alert("ERROR: Stack pointer is not within the interrupt stack\n");
up_stackdump(istackbase - istacksize, istackbase);
}
/* Extract the user stack pointer if we are in an interrupt handler.
* If we are not in an interrupt handler. Then sp is the user stack
@ -302,6 +307,11 @@ static void up_dumpstate(void)
{
up_stackdump(sp, ustackbase);
}
else
{
_alert("ERROR: Stack pointer is not within the allocated stack\n");
up_stackdump(ustackbase - ustacksize, ustackbase);
}
#else
_alert("sp: %08x\n", sp);
@ -318,6 +328,7 @@ static void up_dumpstate(void)
if (sp > ustackbase || sp <= ustackbase - ustacksize)
{
_alert("ERROR: Stack pointer is not within allocated stack\n");
up_stackdump(ustackbase - ustacksize, ustackbase);
}
else
{

View File

@ -321,6 +321,11 @@ static void up_dumpstate(void)
sp = *stackbase;
_alert("User sp: %08x\n", sp);
}
else if (CURRENT_REGS)
{
_alert("ERROR: Stack pointer is not within the interrupt stack\n");
up_stackdump(istackbase - istacksize, istackbase);
}
#endif
/* Dump the user stack if the stack pointer lies within the allocated user
@ -338,12 +343,20 @@ static void up_dumpstate(void)
* kernel stack memory.
*/
if (sp >= (uint32_t)rtcb->xcp.kstack && sp < kstackbase)
else if (sp >= (uint32_t)rtcb->xcp.kstack && sp < kstackbase)
{
_alert("Kernel Stack\n", sp);
up_stackdump(sp, kstackbase);
}
#endif
else
{
_alert("ERROR: Stack pointer is not within the allocated stack\n");
up_stackdump(ustackbase - ustacksize, ustackbase);
#ifdef CONFIG_ARCH_KERNEL_STACK
up_stackdump((uint32_t)rtcb->xcp.kstack, kstackbase);
#endif
}
#ifdef CONFIG_SMP
/* Show the CPU number */

View File

@ -287,6 +287,11 @@ static void up_dumpstate(void)
up_stackdump(sp, istackbase);
}
else if (CURRENT_REGS)
{
_alert("ERROR: Stack pointer is not within the interrupt stack\n");
up_stackdump(istackbase - istacksize, istackbase);
}
/* Extract the user stack pointer if we are in an interrupt handler.
* If we are not in an interrupt handler. Then sp is the user stack
@ -314,6 +319,11 @@ static void up_dumpstate(void)
{
up_stackdump(sp, ustackbase);
}
else
{
_alert("ERROR: Stack pointer is not within the allocated stack\n");
up_stackdump(ustackbase - ustacksize, ustackbase);
}
#else
@ -333,6 +343,7 @@ static void up_dumpstate(void)
if (sp > ustackbase || sp <= ustackbase - ustacksize)
{
_alert("ERROR: Stack pointer is not within the allocated stack\n");
up_stackdump(ustackbase - ustacksize, ustackbase);
}
else
{

View File

@ -306,6 +306,11 @@ static void up_dumpstate(void)
sp = g_intstackbase;
_alert("User sp: %08x\n", sp);
}
else if (CURRENT_REGS)
{
_alert("ERROR: Stack pointer is not within the interrupt stack\n");
up_stackdump(istackbase - istacksize, istackbase);
}
#endif
/* Dump the user stack if the stack pointer lies within the allocated user
@ -323,12 +328,20 @@ static void up_dumpstate(void)
* kernel stack memory.
*/
if (sp >= (uint32_t)rtcb->xcp.kstack && sp < kstackbase)
else if (sp >= (uint32_t)rtcb->xcp.kstack && sp < kstackbase)
{
_alert("Kernel Stack\n", sp);
up_stackdump(sp, kstackbase);
}
#endif
else
{
_alert("ERROR: Stack pointer is not within the allocated stack\n");
up_stackdump(ustackbase - ustacksize, ustackbase);
#ifdef CONFIG_ARCH_KERNEL_STACK
up_stackdump((uint32_t)rtcb->xcp.kstack, kstackbase);
#endif
}
/* Then dump the registers (if available) */

View File

@ -208,6 +208,11 @@ void up_dumpstate(void)
up_stackdump(sp, istackbase);
}
else if (g_current_regs)
{
_alert("ERROR: Stack pointer is not within the interrupt stack\n");
up_stackdump(istackbase - istacksize, istackbase);
}
/* Extract the user stack pointer if we are in an interrupt handler.
* If we are not in an interrupt handler. Then sp is the user stack
@ -235,6 +240,11 @@ void up_dumpstate(void)
{
up_stackdump(sp, ustackbase);
}
else
{
_alert("ERROR: Stack pointer is not within allocated stack\n");
up_stackdump(ustackbase - ustacksize, ustackbase);
}
#else
_alert("sp: %04x\n", sp);
_alert("stack base: %04x\n", ustackbase);
@ -250,6 +260,7 @@ void up_dumpstate(void)
if (sp > ustackbase || sp <= ustackbase - ustacksize)
{
_alert("ERROR: Stack pointer is not within allocated stack\n");
up_stackdump(ustackbase - ustacksize, ustackbase);
}
else
{

View File

@ -174,6 +174,11 @@ void up_dumpstate(void)
up_stackdump(sp, istackbase);
}
else if (g_current_regs)
{
_alert("ERROR: Stack pointer is not within the interrupt stack\n");
up_stackdump(istackbase - istacksize, istackbase);
}
/* Extract the user stack pointer if we are in an interrupt handler.
* If we are not in an interrupt handler. Then sp is the user stack
@ -201,6 +206,11 @@ void up_dumpstate(void)
{
up_stackdump(sp, ustackbase);
}
else
{
_alert("ERROR: Stack pointer is not within allocated stack\n");
up_stackdump(ustackbase - ustacksize, ustackbase);
}
#else
_alert("sp: %08x\n", sp);
_alert("stack base: %08x\n", ustackbase);
@ -216,6 +226,7 @@ void up_dumpstate(void)
if (sp > ustackbase || sp <= ustackbase - ustacksize)
{
_alert("ERROR: Stack pointer is not within allocated stack\n");
up_stackdump(ustackbase - ustacksize, ustackbase);
}
else
{

View File

@ -236,6 +236,11 @@ static void up_dumpstate(void)
sp = g_intstackbase;
_alert("sp: %04x\n", sp);
}
else if (g_current_regs)
{
_alert("ERROR: Stack pointer is not within the interrupt stack\n");
up_stackdump(istackbase - istacksize, istackbase);
}
/* Show user stack info */
@ -254,9 +259,8 @@ static void up_dumpstate(void)
if (sp > ustackbase || sp <= ustackbase - ustacksize)
{
#if !defined(CONFIG_ARCH_INTERRUPTSTACK) || CONFIG_ARCH_INTERRUPTSTACK < 4
_alert("ERROR: Stack pointer is not within allocated stack\n");
#endif
up_stackdump(ustackbase - ustacksize, ustackbase);
}
else
{

View File

@ -191,6 +191,11 @@ void up_dumpstate(void)
sp = g_intstackbase;
_alert("sp: %08x\n", sp);
}
else if (g_current_regs)
{
_alert("ERROR: Stack pointer is not within the interrupt stack\n");
up_stackdump(istackbase - istacksize, istackbase);
}
/* Show user stack info */
@ -209,9 +214,8 @@ void up_dumpstate(void)
if (sp > ustackbase || sp <= ustackbase - ustacksize)
{
#if !defined(CONFIG_ARCH_INTERRUPTSTACK) || CONFIG_ARCH_INTERRUPTSTACK < 4
_alert("ERROR: Stack pointer is not within allocated stack\n");
#endif
up_stackdump(ustackbase - ustacksize, ustackbase);
}
else
{

View File

@ -187,6 +187,11 @@ void lm32_dumpstate(void)
sp = g_intstackbase;
_alert("sp: %08x\n", sp);
}
else if (g_current_regs)
{
_alert("ERROR: Stack pointer is not within the interrupt stack\n");
up_stackdump(istackbase - istacksize, istackbase);
}
/* Show user stack info */
@ -205,9 +210,8 @@ void lm32_dumpstate(void)
if (sp > ustackbase || sp <= ustackbase - ustacksize)
{
#if !defined(CONFIG_ARCH_INTERRUPTSTACK) || CONFIG_ARCH_INTERRUPTSTACK < 4
_alert("ERROR: Stack pointer is not within allocated stack\n");
#endif
up_stackdump(ustackbase - ustacksize, ustackbase);
}
else
{

View File

@ -280,6 +280,11 @@ static void up_dumpstate(void)
up_stackdump(sp, istackbase);
}
else if (CURRENT_REGS)
{
_alert("ERROR: Stack pointer is not within the interrupt stack\n");
up_stackdump(istackbase - istacksize, istackbase);
}
/* Extract the user stack pointer if we are in an interrupt handler.
* If we are not in an interrupt handler. Then sp is the user stack
@ -307,6 +312,11 @@ static void up_dumpstate(void)
{
up_stackdump(sp, ustackbase);
}
else
{
_alert("ERROR: Stack pointer is not within the allocated stack\n");
up_stackdump(ustackbase - ustacksize, ustackbase);
}
#else
_alert("sp: %08x\n", sp);
@ -323,6 +333,7 @@ static void up_dumpstate(void)
if (sp > ustackbase || sp <= ustackbase - ustacksize)
{
_alert("ERROR: Stack pointer is not within allocated stack\n");
up_stackdump(ustackbase - ustacksize, ustackbase);
}
else
{

View File

@ -209,6 +209,11 @@ void up_dumpstate(void)
sp = m16c_getusersp();
_alert("sp: %04x\n", sp);
}
else if (g_current_regs)
{
_alert("ERROR: Stack pointer is not within the interrupt stack\n");
m16c_stackdump(istackbase - istacksize, istackbase);
}
/* Show user stack info */
@ -227,9 +232,8 @@ void up_dumpstate(void)
if (sp > ustackbase || sp <= ustackbase - ustacksize)
{
#if !defined(CONFIG_ARCH_INTERRUPTSTACK) || CONFIG_ARCH_INTERRUPTSTACK < 4
_alert("ERROR: Stack pointer is not within allocated stack\n");
#endif
m16c_stackdump(ustackbase - ustacksize, ustackbase);
}
else
{

View File

@ -193,6 +193,11 @@ void up_dumpstate(void)
sp = g_intstackbase;
_alert("sp: %08x\n", sp);
}
else if (g_current_regs)
{
_alert("ERROR: Stack pointer is not within the interrupt stack\n");
sh1_stackdump(istackbase - istacksize, istackbase);
}
/* Show user stack info */
@ -211,9 +216,8 @@ void up_dumpstate(void)
if (sp > ustackbase || sp <= ustackbase - ustacksize)
{
#if !defined(CONFIG_ARCH_INTERRUPTSTACK) || CONFIG_ARCH_INTERRUPTSTACK < 4
_alert("ERROR: Stack pointer is not within allocated stack\n");
#endif
sh1_stackdump(ustackbase - ustacksize, ustackbase);
}
else
{

View File

@ -196,6 +196,11 @@ void up_dumpstate(void)
sp = g_intstackbase;
_alert("sp: %08x\n", sp);
}
else if (g_current_regs)
{
_alert("ERROR: Stack pointer is not within the interrupt stack\n");
up_stackdump(istackbase - istacksize, istackbase);
}
/* Show user stack info */
@ -214,9 +219,8 @@ void up_dumpstate(void)
if (sp > ustackbase || sp <= ustackbase - ustacksize)
{
#if !defined(CONFIG_ARCH_INTERRUPTSTACK) || CONFIG_ARCH_INTERRUPTSTACK < 4
_alert("ERROR: Stack pointer is not within allocated stack\n");
#endif
up_stackdump(ustackbase - ustacksize, ustackbase);
}
else
{

View File

@ -187,6 +187,11 @@ static void up_dumpstate(void)
sp = g_intstackbase;
_alert("sp: %08x\n", sp);
}
else if (g_current_regs)
{
_alert("ERROR: Stack pointer is not within the interrupt stack\n");
up_stackdump(istackbase - istacksize, istackbase);
}
/* Show user stack info */
@ -205,9 +210,8 @@ static void up_dumpstate(void)
if (sp > ustackbase || sp <= ustackbase - ustacksize)
{
#if !defined(CONFIG_ARCH_INTERRUPTSTACK) || CONFIG_ARCH_INTERRUPTSTACK < 4
_alert("ERROR: Stack pointer is not within allocated stack\n");
#endif
up_stackdump(ustackbase - ustacksize, ustackbase);
}
else
{

View File

@ -255,6 +255,11 @@ void xtensa_dumpstate(void)
sp = &g_instack[INTERRUPTSTACK_SIZE - sizeof(uint32_t)];
_alert("sp: %08x\n", sp);
}
else if (CURRENT_REGS)
{
_alert("ERROR: Stack pointer is not within the interrupt stack\n");
xtensa_stackdump(istackbase - istacksize, istackbase);
}
/* Show user stack info */
@ -279,9 +284,8 @@ void xtensa_dumpstate(void)
if (sp > ustackbase || sp <= ustackbase - ustacksize)
{
#ifdef HAVE_INTERRUPTSTACK
_alert("ERROR: Stack pointer is not within allocated stack\n");
#endif
xtensa_stackdump(ustackbase - ustacksize, ustackbase);
}
else
{

View File

@ -66,6 +66,7 @@ static void up_stackdump(void)
chipreg_t sp = up_getsp();
chipreg_t stack_base = (chipreg_t)rtcb->adj_stack_ptr;
chipreg_t stack_size = (chipreg_t)rtcb->adj_stack_size;
chipreg_t stack;
_alert("stack_base: %08x\n", stack_base);
_alert("stack_size: %08x\n", stack_size);
@ -74,20 +75,20 @@ static void up_stackdump(void)
if (sp >= stack_base || sp < stack_base - stack_size)
{
_err("ERROR: Stack pointer is not within allocated stack\n");
return;
stack = stack_base - stack_size;
}
else
{
chipreg_t stack = sp & ~0x0f;
stack = sp;
}
for (stack = sp & ~0x0f; stack < stack_base; stack += 8*sizeof(chipreg_t))
for (stack = stack & ~0x0f; stack < stack_base; stack += 8*sizeof(chipreg_t))
{
chipreg_t *ptr = (chipreg_t*)stack;
_alert("%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
stack, ptr[0], ptr[1], ptr[2], ptr[3],
ptr[4], ptr[5], ptr[6], ptr[7]);
}
}
}
#endif /* CONFIG_ARCH_STACKDUMP */

View File

@ -67,6 +67,7 @@ static void up_stackdump(void)
uint16_t sp = up_getsp();
uint16_t stack_base = (uint16_t)rtcb->adj_stack_ptr;
uint16_t stack_size = (uint16_t)rtcb->adj_stack_size;
uint16_t stack;
_alert("stack_base: %04x\n", stack_base);
_alert("stack_size: %04x\n", stack_size);
@ -75,20 +76,20 @@ static void up_stackdump(void)
if (sp >= stack_base || sp < stack_base - stack_size)
{
_alert("ERROR: Stack pointer is not within allocated stack\n");
return;
stack = stack_base - stack_size;
}
else
{
uint16_t stack = sp & ~0x0f;
stack = sp;
}
for (stack = sp & ~0x0f; stack < stack_base; stack += 8*sizeof(uint16_t))
for (stack = stack & ~0x0f; stack < stack_base; stack += 8*sizeof(uint16_t))
{
uint16_t *ptr = (uint16_t*)stack;
_alert("%04x: %04x %04x %04x %04x %04x %04x %04x %04x\n",
stack, ptr[0], ptr[1], ptr[2], ptr[3],
ptr[4], ptr[5], ptr[6], ptr[7]);
}
}
}
#endif /* CONFIG_ARCH_STACKDUMP */