backtrace: fix busy loop backtrace

Situation:
1. user call assert
2. crash in assert
3. crash happend, do backtrace
4. backtrace interrupt stack successful
5. busy loop backtrace user stack with CURRENT_REGS

Fix:
use rtcb->regs instead

Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd 2022-07-28 12:11:19 +08:00 committed by Xiang Xiao
parent a1c9598fff
commit a3f9bd3786
7 changed files with 32 additions and 11 deletions

View File

@ -59,6 +59,12 @@
#ifdef CONFIG_ARCH_STACKDUMP
/****************************************************************************
* Private Data
****************************************************************************/
static uint8_t s_last_regs[XCPTCONTEXT_SIZE];
/****************************************************************************
* Private Functions
****************************************************************************/
@ -397,7 +403,8 @@ static void arm_dumpstate(void)
}
else
{
up_saveusercontext(rtcb->xcp.regs);
up_saveusercontext(s_last_regs);
rtcb->xcp.regs = (uint32_t *)s_last_regs;
}
/* Dump the registers */

View File

@ -144,8 +144,8 @@ int up_backtrace(struct tcb_s *tcb,
{
ret += backtrace(rtcb->stack_base_ptr,
rtcb->stack_base_ptr + rtcb->adj_stack_size,
(void *)CURRENT_REGS[REG_FP],
(void *)CURRENT_REGS[REG_PC],
(void *)rtcb->xcp.regs[REG_FP],
(void *)rtcb->xcp.regs[REG_PC],
&buffer[ret], size - ret, &skip);
}
}

View File

@ -504,10 +504,10 @@ int up_backtrace(struct tcb_s *tcb,
#endif
if (ret < size)
{
sp = (void *)CURRENT_REGS[REG_SP];
sp = (void *)rtcb->xcp.regs[REG_SP];
ret += backtrace_push(rtcb->stack_base_ptr +
rtcb->adj_stack_size, &sp,
(void *)CURRENT_REGS[REG_PC],
(void *)rtcb->xcp.regs[REG_PC],
&buffer[ret], size - ret, &skip);
}
}

View File

@ -65,6 +65,12 @@
#ifdef CONFIG_ARCH_STACKDUMP
/****************************************************************************
* Private Data
****************************************************************************/
static uint8_t s_last_regs[XCPTCONTEXT_SIZE];
/****************************************************************************
* Private Functions
****************************************************************************/
@ -374,7 +380,8 @@ static void riscv_dumpstate(void)
}
else
{
up_saveusercontext(rtcb->xcp.regs);
up_saveusercontext(s_last_regs);
rtcb->xcp.regs = (uintptr_t *)s_last_regs;
}
/* Dump the registers (if available) */

View File

@ -154,8 +154,8 @@ int up_backtrace(struct tcb_s *tcb, void **buffer, int size, int skip)
{
ret += backtrace(rtcb->stack_base_ptr,
rtcb->stack_base_ptr + rtcb->adj_stack_size,
(void *)CURRENT_REGS[REG_FP],
(void *)CURRENT_REGS[REG_EPC],
(void *)rtcb->xcp.regs[REG_FP],
(void *)rtcb->xcp.regs[REG_EPC],
&buffer[ret], size - ret, &skip);
}
}

View File

@ -253,8 +253,8 @@ int up_backtrace(struct tcb_s *tcb, void **buffer, int size, int skip)
#endif
ret += backtrace_stack(rtcb->stack_base_ptr,
rtcb->stack_base_ptr + rtcb->adj_stack_size,
(void *)CURRENT_REGS[REG_A1],
(void *)CURRENT_REGS[REG_A0],
(void *)rtcb->xcp.regs[REG_A1],
(void *)rtcb->xcp.regs[REG_A0],
&buffer[ret], size - ret, &skip);
}
else

View File

@ -44,6 +44,12 @@
#ifdef CONFIG_DEBUG_ALERT
/****************************************************************************
* Private Data
****************************************************************************/
static uint8_t s_last_regs[XCPTCONTEXT_SIZE];
/****************************************************************************
* Private Functions
****************************************************************************/
@ -343,7 +349,8 @@ void xtensa_dumpstate(void)
}
else
{
up_saveusercontext(rtcb->xcp.regs);
up_saveusercontext(s_last_regs);
rtcb->xcp.regs = (uint32_t *)s_last_regs;
}
/* Dump the registers (if available) */