diff --git a/arch/arm/src/common/arm_assert.c b/arch/arm/src/common/arm_assert.c index 7098c3eaf3..93bce4be33 100644 --- a/arch/arm/src/common/arm_assert.c +++ b/arch/arm/src/common/arm_assert.c @@ -352,10 +352,17 @@ static void arm_dump_stack(const char *tag, uint32_t sp, else { _alert("ERROR: %s Stack pointer is not within the stack\n", tag); - if (force) { - arm_stackdump(base, top); +#ifdef CONFIG_STACK_COLORATION + uint32_t remain; + + remain = size - arm_stack_check((FAR void *)(uintptr_t)base, size); + base += remain; + size -= remain; +#endif + + arm_stackdump(base, base + size); } } } diff --git a/arch/risc-v/src/common/riscv_assert.c b/arch/risc-v/src/common/riscv_assert.c index 3d4d4c2d68..c04225447b 100644 --- a/arch/risc-v/src/common/riscv_assert.c +++ b/arch/risc-v/src/common/riscv_assert.c @@ -331,7 +331,15 @@ static void riscv_dump_stack(const char *tag, uintptr_t sp, if (force) { - riscv_stackdump(base, top); +#ifdef CONFIG_STACK_COLORATION + uint32_t remain; + + remain = size - riscv_stack_check((uintptr_t)base, size); + base += remain; + size -= remain; +#endif + + riscv_stackdump(base, base + size); } } } diff --git a/arch/xtensa/src/common/xtensa_dumpstate.c b/arch/xtensa/src/common/xtensa_dumpstate.c index faeb0bcd8b..140b5903e3 100644 --- a/arch/xtensa/src/common/xtensa_dumpstate.c +++ b/arch/xtensa/src/common/xtensa_dumpstate.c @@ -281,14 +281,16 @@ static void xtensa_dump_stack(const char *tag, uint32_t sp, uint32_t base, uint32_t size, bool force) { uint32_t top = base + size; +#ifdef CONFIG_STACK_COLORATION + uint32_t used = xtensa_stack_check((uintptr_t)base, size); +#endif _alert("%s Stack:\n", tag); _alert("sp: %08" PRIx32 "\n", sp); _alert(" base: %08" PRIx32 "\n", base); _alert(" size: %08" PRIx32 "\n", size); #ifdef CONFIG_STACK_COLORATION - _alert(" used: %08" PRIx32 "\n", xtensa_stack_check((uintptr_t)base, - size)); + _alert(" used: %08" PRIx32 "\n", used); #endif if (sp >= base && sp < top) @@ -301,7 +303,12 @@ static void xtensa_dump_stack(const char *tag, uint32_t sp, if (force) { - xtensa_stackdump(base, top); +#ifdef CONFIG_STACK_COLORATION + base += size - used; + size = used; +#endif + + xtensa_stackdump(base, base + size); } } }