stack_dump:change Conditions for stack dump

If the gap between sp and stack_top is too small,
then the stack will not be output,
modify the conditional loop condition, and fix this problem

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao 2023-09-05 12:20:24 +08:00 committed by Xiang Xiao
parent 0ca8ae81d0
commit 7fd172d9ff

View file

@ -70,6 +70,8 @@
# undef CONFIG_ARCH_USBDUMP
#endif
#define DUMP_PTR(p, x) ((uintptr_t)(&(p)[(x)]) < stack_top ? (p)[(x)] : 0)
/****************************************************************************
* Private Data
****************************************************************************/
@ -135,14 +137,16 @@ static void stack_dump(uintptr_t sp, uintptr_t stack_top)
{
uintptr_t stack;
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
for (stack = sp; stack <= stack_top; stack += 32)
{
FAR uint32_t *ptr = (FAR uint32_t *)stack;
_alert("%p: %08" PRIx32 " %08" PRIx32 " %08" PRIx32
" %08" PRIx32 " %08" PRIx32 " %08" PRIx32 " %08" PRIx32
" %08" PRIx32 "\n",
(FAR void *)stack, ptr[0], ptr[1], ptr[2], ptr[3],
ptr[4], ptr[5], ptr[6], ptr[7]);
(FAR void *)stack, DUMP_PTR(ptr, 0), DUMP_PTR(ptr , 1),
DUMP_PTR(ptr, 2), DUMP_PTR(ptr, 3), DUMP_PTR(ptr, 4),
DUMP_PTR(ptr, 5), DUMP_PTR(ptr , 6), DUMP_PTR(ptr, 7));
}
}