arch/arm/assert: enhance the assert dump

show the all tasks info including backtrace and registers

Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2021-08-25 22:56:31 +08:00 committed by Xiang Xiao
parent f14bd44001
commit d5d6297ca1
5 changed files with 310 additions and 203 deletions

View File

@ -88,51 +88,13 @@ static void up_stackdump(uint32_t sp, uint32_t stack_top)
# define up_stackdump(sp,stack_top) # define up_stackdump(sp,stack_top)
#endif #endif
/****************************************************************************
* Name: up_taskdump
****************************************************************************/
#ifdef CONFIG_STACK_COLORATION
static void up_taskdump(FAR struct tcb_s *tcb, FAR void *arg)
{
/* Dump interesting properties of this task */
#if CONFIG_TASK_NAME_SIZE > 0
_alert("%s: PID=%d Stack Used=%lu of %lu\n",
tcb->name, tcb->pid, (unsigned long)up_check_tcbstack(tcb),
(unsigned long)tcb->adj_stack_size);
#else
_alert("PID: %d Stack Used=%lu of %lu\n",
tcb->pid, (unsigned long)up_check_tcbstack(tcb),
(unsigned long)tcb->adj_stack_size);
#endif
}
#endif
/****************************************************************************
* Name: up_showtasks
****************************************************************************/
#ifdef CONFIG_STACK_COLORATION
static inline void up_showtasks(void)
{
/* Dump interesting properties of each task in the crash environment */
nxsched_foreach(up_taskdump, NULL);
}
#else
# define up_showtasks()
#endif
/**************************************************************************** /****************************************************************************
* Name: up_registerdump * Name: up_registerdump
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_ARCH_STACKDUMP #ifdef CONFIG_ARCH_STACKDUMP
static inline void up_registerdump(void) static inline void up_registerdump(FAR volatile uint32_t *regs)
{ {
volatile uint32_t *regs = CURRENT_REGS;
/* Are user registers available from interrupt processing? */ /* Are user registers available from interrupt processing? */
if (regs == NULL) if (regs == NULL)
@ -160,7 +122,60 @@ static inline void up_registerdump(void)
#endif #endif
} }
#else #else
# define up_registerdump() # define up_registerdump(regs)
#endif
/****************************************************************************
* Name: up_taskdump
****************************************************************************/
#if defined(CONFIG_STACK_COLORATION) || defined(CONFIG_SCHED_BACKTRACE)
static void up_taskdump(FAR struct tcb_s *tcb, FAR void *arg)
{
/* Dump interesting properties of this task */
_alert(
#if CONFIG_TASK_NAME_SIZE > 0
"%s: "
#endif
"PID=%d "
#ifdef CONFIG_STACK_COLORATION
"Stack Used=%lu of %lu\n",
#else
"Stack=%lu\n",
#endif
#if CONFIG_TASK_NAME_SIZE > 0
tcb->name,
#endif
tcb->pid,
#ifdef CONFIG_STACK_COLORATION
(unsigned long)up_check_tcbstack(tcb),
#endif
(unsigned long)tcb->adj_stack_size);
/* Show back trace */
#ifdef CONFIG_SCHED_BACKTRACE
sched_dumpstack(tcb->pid);
#endif
/* Dump the registers */
up_registerdump(tcb->xcp.regs);
}
/****************************************************************************
* Name: up_showtasks
****************************************************************************/
static inline void up_showtasks(void)
{
/* Dump interesting properties of each task in the crash environment */
nxsched_foreach(up_taskdump, NULL);
}
#else
# define up_showtasks()
#endif #endif
/**************************************************************************** /****************************************************************************
@ -203,9 +218,15 @@ static void up_dumpstate(void)
uint32_t istacksize; uint32_t istacksize;
#endif #endif
/* Show back trace */
#ifdef CONFIG_SCHED_BACKTRACE
sched_dumpstack(rtcb->pid);
#endif
/* Dump the registers (if available) */ /* Dump the registers (if available) */
up_registerdump(); up_registerdump(CURRENT_REGS);
/* Get the limits on the user stack memory */ /* Get the limits on the user stack memory */

View File

@ -91,50 +91,13 @@ static void up_stackdump(uint32_t sp, uint32_t stack_top)
# define up_stackdump(sp,stack_top) # define up_stackdump(sp,stack_top)
#endif #endif
/****************************************************************************
* Name: up_taskdump
****************************************************************************/
#ifdef CONFIG_STACK_COLORATION
static void up_taskdump(FAR struct tcb_s *tcb, FAR void *arg)
{
/* Dump interesting properties of this task */
#if CONFIG_TASK_NAME_SIZE > 0
_alert("%s: PID=%d Stack Used=%lu of %lu\n",
tcb->name, tcb->pid, (unsigned long)up_check_tcbstack(tcb),
(unsigned long)tcb->adj_stack_size);
#else
_alert("PID: %d Stack Used=%lu of %lu\n",
tcb->pid, (unsigned long)up_check_tcbstack(tcb),
(unsigned long)tcb->adj_stack_size);
#endif
}
#endif
/****************************************************************************
* Name: up_showtasks
****************************************************************************/
#ifdef CONFIG_STACK_COLORATION
static inline void up_showtasks(void)
{
/* Dump interesting properties of each task in the crash environment */
nxsched_foreach(up_taskdump, NULL);
}
#else
# define up_showtasks()
#endif
/**************************************************************************** /****************************************************************************
* Name: up_registerdump * Name: up_registerdump
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_ARCH_STACKDUMP #ifdef CONFIG_ARCH_STACKDUMP
static inline void up_registerdump(void) static inline void up_registerdump(FAR volatile uint32_t *regs)
{ {
volatile uint32_t *regs = CURRENT_REGS;
int reg; int reg;
/* Are user registers available from interrupt processing? */ /* Are user registers available from interrupt processing? */
@ -160,7 +123,60 @@ static inline void up_registerdump(void)
_alert("CPSR: %08x\n", regs[REG_CPSR]); _alert("CPSR: %08x\n", regs[REG_CPSR]);
} }
#else #else
# define up_registerdump() # define up_registerdump(regs)
#endif
/****************************************************************************
* Name: up_taskdump
****************************************************************************/
#if defined(CONFIG_STACK_COLORATION) || defined(CONFIG_SCHED_BACKTRACE)
static void up_taskdump(FAR struct tcb_s *tcb, FAR void *arg)
{
/* Dump interesting properties of this task */
_alert(
#if CONFIG_TASK_NAME_SIZE > 0
"%s: "
#endif
"PID=%d "
#ifdef CONFIG_STACK_COLORATION
"Stack Used=%lu of %lu\n",
#else
"Stack=%lu\n",
#endif
#if CONFIG_TASK_NAME_SIZE > 0
tcb->name,
#endif
tcb->pid,
#ifdef CONFIG_STACK_COLORATION
(unsigned long)up_check_tcbstack(tcb),
#endif
(unsigned long)tcb->adj_stack_size);
/* Show back trace */
#ifdef CONFIG_SCHED_BACKTRACE
sched_dumpstack(tcb->pid);
#endif
/* Dump the registers */
up_registerdump(tcb->xcp.regs);
}
/****************************************************************************
* Name: up_showtasks
****************************************************************************/
static inline void up_showtasks(void)
{
/* Dump interesting properties of each task in the crash environment */
nxsched_foreach(up_taskdump, NULL);
}
#else
# define up_showtasks()
#endif #endif
/**************************************************************************** /****************************************************************************
@ -206,9 +222,15 @@ static void up_dumpstate(void)
uint32_t kstackbase = 0; uint32_t kstackbase = 0;
#endif #endif
/* Show back trace */
#ifdef CONFIG_SCHED_BACKTRACE
sched_dumpstack(rtcb->pid);
#endif
/* Dump the CPU registers (if available) */ /* Dump the CPU registers (if available) */
up_registerdump(); up_registerdump(CURRENT_REGS);
/* Get the limits on the user stack memory */ /* Get the limits on the user stack memory */

View File

@ -91,51 +91,13 @@ static void up_stackdump(uint32_t sp, uint32_t stack_top)
# define up_stackdump(sp,stack_top) # define up_stackdump(sp,stack_top)
#endif #endif
/****************************************************************************
* Name: up_taskdump
****************************************************************************/
#ifdef CONFIG_STACK_COLORATION
static void up_taskdump(FAR struct tcb_s *tcb, FAR void *arg)
{
/* Dump interesting properties of this task */
#if CONFIG_TASK_NAME_SIZE > 0
_alert("%s: PID=%d Stack Used=%lu of %lu\n",
tcb->name, tcb->pid, (unsigned long)up_check_tcbstack(tcb),
(unsigned long)tcb->adj_stack_size);
#else
_alert("PID: %d Stack Used=%lu of %lu\n",
tcb->pid, (unsigned long)up_check_tcbstack(tcb),
(unsigned long)tcb->adj_stack_size);
#endif
}
#endif
/****************************************************************************
* Name: up_showtasks
****************************************************************************/
#ifdef CONFIG_STACK_COLORATION
static inline void up_showtasks(void)
{
/* Dump interesting properties of each task in the crash environment */
nxsched_foreach(up_taskdump, NULL);
}
#else
# define up_showtasks()
#endif
/**************************************************************************** /****************************************************************************
* Name: up_registerdump * Name: up_registerdump
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_ARCH_STACKDUMP #ifdef CONFIG_ARCH_STACKDUMP
static inline void up_registerdump(void) static inline void up_registerdump(FAR volatile uint32_t *regs)
{ {
volatile uint32_t *regs = CURRENT_REGS;
/* Are user registers available from interrupt processing? */ /* Are user registers available from interrupt processing? */
if (regs == NULL) if (regs == NULL)
@ -168,7 +130,60 @@ static inline void up_registerdump(void)
#endif #endif
} }
#else #else
# define up_registerdump() # define up_registerdump(regs)
#endif
/****************************************************************************
* Name: up_taskdump
****************************************************************************/
#if defined(CONFIG_STACK_COLORATION) || defined(CONFIG_SCHED_BACKTRACE)
static void up_taskdump(FAR struct tcb_s *tcb, FAR void *arg)
{
/* Dump interesting properties of this task */
_alert(
#if CONFIG_TASK_NAME_SIZE > 0
"%s: "
#endif
"PID=%d "
#ifdef CONFIG_STACK_COLORATION
"Stack Used=%lu of %lu\n",
#else
"Stack=%lu\n",
#endif
#if CONFIG_TASK_NAME_SIZE > 0
tcb->name,
#endif
tcb->pid,
#ifdef CONFIG_STACK_COLORATION
(unsigned long)up_check_tcbstack(tcb),
#endif
(unsigned long)tcb->adj_stack_size);
/* Show back trace */
#ifdef CONFIG_SCHED_BACKTRACE
sched_dumpstack(tcb->pid);
#endif
/* Dump the registers */
up_registerdump(tcb->xcp.regs);
}
/****************************************************************************
* Name: up_showtasks
****************************************************************************/
static inline void up_showtasks(void)
{
/* Dump interesting properties of each task in the crash environment */
nxsched_foreach(up_taskdump, NULL);
}
#else
# define up_showtasks()
#endif #endif
/**************************************************************************** /****************************************************************************
@ -211,9 +226,15 @@ static void up_dumpstate(void)
uint32_t istacksize; uint32_t istacksize;
#endif #endif
/* Show back trace */
#ifdef CONFIG_SCHED_BACKTRACE
sched_dumpstack(rtcb->pid);
#endif
/* Dump the registers (if available) */ /* Dump the registers (if available) */
up_registerdump(); up_registerdump(CURRENT_REGS);
/* Get the limits on the user stack memory */ /* Get the limits on the user stack memory */

View File

@ -88,50 +88,13 @@ static void up_stackdump(uint32_t sp, uint32_t stack_top)
# define up_stackdump(sp,stack_top) # define up_stackdump(sp,stack_top)
#endif #endif
/****************************************************************************
* Name: up_taskdump
****************************************************************************/
#ifdef CONFIG_STACK_COLORATION
static void up_taskdump(FAR struct tcb_s *tcb, FAR void *arg)
{
/* Dump interesting properties of this task */
#if CONFIG_TASK_NAME_SIZE > 0
_alert("%s: PID=%d Stack Used=%lu of %lu\n",
tcb->name, tcb->pid, (unsigned long)up_check_tcbstack(tcb),
(unsigned long)tcb->adj_stack_size);
#else
_alert("PID: %d Stack Used=%lu of %lu\n",
tcb->pid, (unsigned long)up_check_tcbstack(tcb),
(unsigned long)tcb->adj_stack_size);
#endif
}
#endif
/****************************************************************************
* Name: up_showtasks
****************************************************************************/
#ifdef CONFIG_STACK_COLORATION
static inline void up_showtasks(void)
{
/* Dump interesting properties of each task in the crash environment */
nxsched_foreach(up_taskdump, NULL);
}
#else
# define up_showtasks()
#endif
/**************************************************************************** /****************************************************************************
* Name: up_registerdump * Name: up_registerdump
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_ARCH_STACKDUMP #ifdef CONFIG_ARCH_STACKDUMP
static inline void up_registerdump(void) static inline void up_registerdump(FAR volatile uint32_t *regs)
{ {
volatile uint32_t *regs = CURRENT_REGS;
int reg; int reg;
/* Are user registers available from interrupt processing? */ /* Are user registers available from interrupt processing? */
@ -157,7 +120,60 @@ static inline void up_registerdump(void)
_alert("CPSR: %08x\n", regs[REG_CPSR]); _alert("CPSR: %08x\n", regs[REG_CPSR]);
} }
#else #else
# define up_registerdump() # define up_registerdump(regs)
#endif
/****************************************************************************
* Name: up_taskdump
****************************************************************************/
#if defined(CONFIG_STACK_COLORATION) || defined(CONFIG_SCHED_BACKTRACE)
static void up_taskdump(FAR struct tcb_s *tcb, FAR void *arg)
{
/* Dump interesting properties of this task */
_alert(
#if CONFIG_TASK_NAME_SIZE > 0
"%s: "
#endif
"PID=%d "
#ifdef CONFIG_STACK_COLORATION
"Stack Used=%lu of %lu\n",
#else
"Stack=%lu\n",
#endif
#if CONFIG_TASK_NAME_SIZE > 0
tcb->name,
#endif
tcb->pid,
#ifdef CONFIG_STACK_COLORATION
(unsigned long)up_check_tcbstack(tcb),
#endif
(unsigned long)tcb->adj_stack_size);
/* Show back trace */
#ifdef CONFIG_SCHED_BACKTRACE
sched_dumpstack(tcb->pid);
#endif
/* Dump the registers */
up_registerdump(tcb->xcp.regs);
}
/****************************************************************************
* Name: up_showtasks
****************************************************************************/
static inline void up_showtasks(void)
{
/* Dump interesting properties of each task in the crash environment */
nxsched_foreach(up_taskdump, NULL);
}
#else
# define up_showtasks()
#endif #endif
/**************************************************************************** /****************************************************************************
@ -203,9 +219,15 @@ static void up_dumpstate(void)
uint32_t kstackbase = 0; uint32_t kstackbase = 0;
#endif #endif
/* Show back trace */
#ifdef CONFIG_SCHED_BACKTRACE
sched_dumpstack(rtcb->pid);
#endif
/* Dump the registers (if available) */ /* Dump the registers (if available) */
up_registerdump(); up_registerdump(CURRENT_REGS);
/* Get the limits on the user stack memory */ /* Get the limits on the user stack memory */

View File

@ -91,51 +91,13 @@ static void up_stackdump(uint32_t sp, uint32_t stack_top)
# define up_stackdump(sp,stack_top) # define up_stackdump(sp,stack_top)
#endif #endif
/****************************************************************************
* Name: up_taskdump
****************************************************************************/
#ifdef CONFIG_STACK_COLORATION
static void up_taskdump(FAR struct tcb_s *tcb, FAR void *arg)
{
/* Dump interesting properties of this task */
#if CONFIG_TASK_NAME_SIZE > 0
_alert("%s: PID=%d Stack Used=%lu of %lu\n",
tcb->name, tcb->pid, (unsigned long)up_check_tcbstack(tcb),
(unsigned long)tcb->adj_stack_size);
#else
_alert("PID: %d Stack Used=%lu of %lu\n",
tcb->pid, (unsigned long)up_check_tcbstack(tcb),
(unsigned long)tcb->adj_stack_size);
#endif
}
#endif
/****************************************************************************
* Name: up_showtasks
****************************************************************************/
#ifdef CONFIG_STACK_COLORATION
static inline void up_showtasks(void)
{
/* Dump interesting properties of each task in the crash environment */
nxsched_foreach(up_taskdump, NULL);
}
#else
# define up_showtasks()
#endif
/**************************************************************************** /****************************************************************************
* Name: up_registerdump * Name: up_registerdump
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_ARCH_STACKDUMP #ifdef CONFIG_ARCH_STACKDUMP
static inline void up_registerdump(void) static inline void up_registerdump(FAR volatile uint32_t *regs)
{ {
volatile uint32_t *regs = CURRENT_REGS;
/* Are user registers available from interrupt processing? */ /* Are user registers available from interrupt processing? */
if (regs == NULL) if (regs == NULL)
@ -168,7 +130,60 @@ static inline void up_registerdump(void)
#endif #endif
} }
#else #else
# define up_registerdump() # define up_registerdump(regs)
#endif
/****************************************************************************
* Name: up_taskdump
****************************************************************************/
#if defined(CONFIG_STACK_COLORATION) || defined(CONFIG_SCHED_BACKTRACE)
static void up_taskdump(FAR struct tcb_s *tcb, FAR void *arg)
{
/* Dump interesting properties of this task */
_alert(
#if CONFIG_TASK_NAME_SIZE > 0
"%s: "
#endif
"PID=%d "
#ifdef CONFIG_STACK_COLORATION
"Stack Used=%lu of %lu\n",
#else
"Stack=%lu\n",
#endif
#if CONFIG_TASK_NAME_SIZE > 0
tcb->name,
#endif
tcb->pid,
#ifdef CONFIG_STACK_COLORATION
(unsigned long)up_check_tcbstack(tcb),
#endif
(unsigned long)tcb->adj_stack_size);
/* Show back trace */
#ifdef CONFIG_SCHED_BACKTRACE
sched_dumpstack(tcb->pid);
#endif
/* Dump the registers */
up_registerdump(tcb->xcp.regs);
}
/****************************************************************************
* Name: up_showtasks
****************************************************************************/
static inline void up_showtasks(void)
{
/* Dump interesting properties of each task in the crash environment */
nxsched_foreach(up_taskdump, NULL);
}
#else
# define up_showtasks()
#endif #endif
/**************************************************************************** /****************************************************************************
@ -211,9 +226,15 @@ static void up_dumpstate(void)
uint32_t istacksize; uint32_t istacksize;
#endif #endif
/* Show back trace */
#ifdef CONFIG_SCHED_BACKTRACE
sched_dumpstack(rtcb->pid);
#endif
/* Dump the registers (if available) */ /* Dump the registers (if available) */
up_registerdump(); up_registerdump(CURRENT_REGS);
/* Get the limits on the user stack memory */ /* Get the limits on the user stack memory */