RISC-V: Add missing code to dumpstate

Just add the kernel stack dumping for completeness
This commit is contained in:
Ville Juven 2022-01-25 15:54:36 +02:00 committed by Xiang Xiao
parent 77e90d9c87
commit 44bec4cf8e

View File

@ -318,6 +318,9 @@ static void riscv_dumpstate(void)
uintptr_t istackbase; uintptr_t istackbase;
uintptr_t istacksize; uintptr_t istacksize;
#endif #endif
#ifdef CONFIG_ARCH_KERNEL_STACK
uintptr_t kstackbase = 0;
#endif
/* Show back trace */ /* Show back trace */
@ -395,18 +398,46 @@ static void riscv_dumpstate(void)
_alert("stack size: %" PRIxREG "\n", ustacksize); _alert("stack size: %" PRIxREG "\n", ustacksize);
#endif #endif
#ifdef CONFIG_ARCH_KERNEL_STACK
/* Does this thread have a kernel stack allocated? */
if (rtcb->xcp.kstack)
{
kstackbase = (uintptr_t)rtcb->xcp.kstack;
_alert("Kernel stack:\n");
_alert(" base: %" PRIxREG "\n", kstackbase);
_alert(" size: %" PRIxREG "\n", CONFIG_ARCH_KERNEL_STACKSIZE);
}
#endif
/* Dump the user stack if the stack pointer lies within the allocated user /* Dump the user stack if the stack pointer lies within the allocated user
* stack memory. * stack memory.
*/ */
if (sp >= ustackbase && sp < ustackbase + ustacksize) if (sp >= ustackbase && sp < ustackbase + ustacksize)
{ {
_alert("ERROR: Stack pointer is not within allocated stack\n"); _alert("User Stack\n");
riscv_stackdump(ustackbase, ustackbase + ustacksize); riscv_stackdump(sp, ustackbase + ustacksize);
} }
#ifdef CONFIG_ARCH_KERNEL_STACK
/* Dump the kernel stack if the stack pointer lies within the allocated
* kernel stack memory.
*/
else if (kstackbase != 0 &&
sp >= kstackbase &&
sp < kstackbase + CONFIG_ARCH_KERNEL_STACKSIZE)
{
_alert("Kernel Stack\n");
riscv_stackdump(sp, kstackbase + CONFIG_ARCH_KERNEL_STACKSIZE);
}
#endif
else else
{ {
riscv_stackdump(sp, ustackbase + ustacksize); _alert("ERROR: Stack pointer is not within allocated stack\n");
riscv_stackdump(ustackbase, ustackbase + ustacksize);
} }
} }
#else #else