This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new d5d6297  arch/arm/assert: enhance the assert dump
d5d6297 is described below

commit d5d6297ca1aeaadb878b75cfec6056aef2d18e67
Author: chao.an <[email protected]>
AuthorDate: Wed Aug 25 22:56:31 2021 +0800

    arch/arm/assert: enhance the assert dump
    
    show the all tasks info including backtrace and registers
    
    Signed-off-by: chao.an <[email protected]>
---
 arch/arm/src/armv6-m/arm_assert.c | 103 +++++++++++++++++++++++---------------
 arch/arm/src/armv7-a/arm_assert.c | 102 ++++++++++++++++++++++---------------
 arch/arm/src/armv7-m/arm_assert.c | 103 +++++++++++++++++++++++---------------
 arch/arm/src/armv7-r/arm_assert.c | 102 ++++++++++++++++++++++---------------
 arch/arm/src/armv8-m/arm_assert.c | 103 +++++++++++++++++++++++---------------
 5 files changed, 310 insertions(+), 203 deletions(-)

diff --git a/arch/arm/src/armv6-m/arm_assert.c 
b/arch/arm/src/armv6-m/arm_assert.c
index 048959e..16e7676 100644
--- a/arch/arm/src/armv6-m/arm_assert.c
+++ b/arch/arm/src/armv6-m/arm_assert.c
@@ -89,50 +89,12 @@ static void up_stackdump(uint32_t sp, uint32_t stack_top)
 #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
  ****************************************************************************/
 
 #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? */
 
   if (regs == NULL)
@@ -160,7 +122,60 @@ static inline void up_registerdump(void)
 #endif
 }
 #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
 
 /****************************************************************************
@@ -203,9 +218,15 @@ static void up_dumpstate(void)
   uint32_t istacksize;
 #endif
 
+  /* Show back trace */
+
+#ifdef CONFIG_SCHED_BACKTRACE
+  sched_dumpstack(rtcb->pid);
+#endif
+
   /* Dump the registers (if available) */
 
-  up_registerdump();
+  up_registerdump(CURRENT_REGS);
 
   /* Get the limits on the user stack memory */
 
diff --git a/arch/arm/src/armv7-a/arm_assert.c 
b/arch/arm/src/armv7-a/arm_assert.c
index 65129cf..2388c20 100644
--- a/arch/arm/src/armv7-a/arm_assert.c
+++ b/arch/arm/src/armv7-a/arm_assert.c
@@ -92,49 +92,12 @@ static void up_stackdump(uint32_t sp, uint32_t stack_top)
 #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
  ****************************************************************************/
 
 #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;
 
   /* Are user registers available from interrupt processing? */
@@ -160,7 +123,60 @@ static inline void up_registerdump(void)
   _alert("CPSR: %08x\n", regs[REG_CPSR]);
 }
 #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
 
 /****************************************************************************
@@ -206,9 +222,15 @@ static void up_dumpstate(void)
   uint32_t kstackbase = 0;
 #endif
 
+  /* Show back trace */
+
+#ifdef CONFIG_SCHED_BACKTRACE
+  sched_dumpstack(rtcb->pid);
+#endif
+
   /* Dump the CPU registers (if available) */
 
-  up_registerdump();
+  up_registerdump(CURRENT_REGS);
 
   /* Get the limits on the user stack memory */
 
diff --git a/arch/arm/src/armv7-m/arm_assert.c 
b/arch/arm/src/armv7-m/arm_assert.c
index 6a65245..c317d8d 100644
--- a/arch/arm/src/armv7-m/arm_assert.c
+++ b/arch/arm/src/armv7-m/arm_assert.c
@@ -92,50 +92,12 @@ static void up_stackdump(uint32_t sp, uint32_t stack_top)
 #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
  ****************************************************************************/
 
 #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? */
 
   if (regs == NULL)
@@ -168,7 +130,60 @@ static inline void up_registerdump(void)
 #endif
 }
 #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
 
 /****************************************************************************
@@ -211,9 +226,15 @@ static void up_dumpstate(void)
   uint32_t istacksize;
 #endif
 
+  /* Show back trace */
+
+#ifdef CONFIG_SCHED_BACKTRACE
+  sched_dumpstack(rtcb->pid);
+#endif
+
   /* Dump the registers (if available) */
 
-  up_registerdump();
+  up_registerdump(CURRENT_REGS);
 
   /* Get the limits on the user stack memory */
 
diff --git a/arch/arm/src/armv7-r/arm_assert.c 
b/arch/arm/src/armv7-r/arm_assert.c
index 9d6e6ab..7742c4d 100644
--- a/arch/arm/src/armv7-r/arm_assert.c
+++ b/arch/arm/src/armv7-r/arm_assert.c
@@ -89,49 +89,12 @@ static void up_stackdump(uint32_t sp, uint32_t stack_top)
 #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
  ****************************************************************************/
 
 #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;
 
   /* Are user registers available from interrupt processing? */
@@ -157,7 +120,60 @@ static inline void up_registerdump(void)
   _alert("CPSR: %08x\n", regs[REG_CPSR]);
 }
 #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
 
 /****************************************************************************
@@ -203,9 +219,15 @@ static void up_dumpstate(void)
   uint32_t kstackbase = 0;
 #endif
 
+  /* Show back trace */
+
+#ifdef CONFIG_SCHED_BACKTRACE
+  sched_dumpstack(rtcb->pid);
+#endif
+
   /* Dump the registers (if available) */
 
-  up_registerdump();
+  up_registerdump(CURRENT_REGS);
 
   /* Get the limits on the user stack memory */
 
diff --git a/arch/arm/src/armv8-m/arm_assert.c 
b/arch/arm/src/armv8-m/arm_assert.c
index 4a3ba2b..7cf43bd 100644
--- a/arch/arm/src/armv8-m/arm_assert.c
+++ b/arch/arm/src/armv8-m/arm_assert.c
@@ -92,50 +92,12 @@ static void up_stackdump(uint32_t sp, uint32_t stack_top)
 #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
  ****************************************************************************/
 
 #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? */
 
   if (regs == NULL)
@@ -168,7 +130,60 @@ static inline void up_registerdump(void)
 #endif
 }
 #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
 
 /****************************************************************************
@@ -211,9 +226,15 @@ static void up_dumpstate(void)
   uint32_t istacksize;
 #endif
 
+  /* Show back trace */
+
+#ifdef CONFIG_SCHED_BACKTRACE
+  sched_dumpstack(rtcb->pid);
+#endif
+
   /* Dump the registers (if available) */
 
-  up_registerdump();
+  up_registerdump(CURRENT_REGS);
 
   /* Get the limits on the user stack memory */
 

Reply via email to