xtensa:backtrace: fix backtrace last buffer error in some scene

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
This commit is contained in:
zhuyanlin 2022-03-04 11:22:45 +08:00 committed by Abdelatif Guettouche
parent 5659f685c1
commit 981282696f

View File

@ -169,15 +169,12 @@ static int backtrace_stack(uintptr_t *base, uintptr_t *limit,
}
}
for (; i < size; sp = (uintptr_t *)*(sp - 3))
while (i < size)
{
if (sp > limit || sp < base)
{
break;
}
ra = (uintptr_t *)*(sp - 4);
if (ra == NULL)
sp = (uintptr_t *)*(sp - 3);
if (sp >= limit || sp < base || ra == NULL)
{
break;
}
@ -236,7 +233,7 @@ int up_backtrace(struct tcb_s *tcb, void **buffer, int size, int skip)
if (up_interrupt_context())
{
#if CONFIG_ARCH_INTERRUPTSTACK > 15
uintptr_t istackbase;
FAR void *istackbase;
#ifdef CONFIG_SMP
istackbase = xtensa_intstack_alloc();
#else
@ -244,9 +241,8 @@ int up_backtrace(struct tcb_s *tcb, void **buffer, int size, int skip)
#endif
xtensa_window_spill();
ret = backtrace_stack((void *)istackbase,
(void *)(istackbase +
CONFIG_ARCH_INTERRUPTSTACK),
ret = backtrace_stack(istackbase,
(istackbase + CONFIG_ARCH_INTERRUPTSTACK),
(void *)up_getsp(), NULL,
buffer, size, &skip);
#else