hitHuang commented on code in PR #19528:
URL: https://github.com/apache/nuttx/pull/19528#discussion_r3653910036


##########
arch/risc-v/src/common/riscv_backtrace.c:
##########
@@ -42,7 +112,7 @@
  *
  ****************************************************************************/
 
-static inline uintptr_t getfp(void)
+always_inline_function static uintptr_t getfp(void)

Review Comment:
   done



##########
arch/risc-v/src/common/riscv_backtrace.c:
##########
@@ -184,100 +392,98 @@ static int backtrace(uintptr_t *base, uintptr_t *limit,
 int up_backtrace(struct tcb_s *tcb, void **buffer, int size, int skip)
 {
   struct tcb_s *rtcb = running_task();
-  int ret;
+  struct bt_segment_s segments[BT_MAX_SEGMENTS];
+  struct bt_segment_s *segment;
+  uintptr_t *ubase;
+  uintptr_t *ulimit;
+  bool self = (tcb == NULL || tcb == rtcb);
+  int nsegments = 0;
+#if CONFIG_ARCH_INTERRUPTSTACK > 15
+  int cpu;
+  uintptr_t *ilimit;
+  uintptr_t *ibase;
+#endif
 
   if (size <= 0 || !buffer)
     {
       return 0;
     }
 
-  if (tcb == NULL || tcb == rtcb)
+  if (self)
     {
-      if (up_interrupt_context())
-        {
-          ret = backtrace(rtcb->stack_base_ptr,
-                          (uintptr_t *)((uintptr_t)rtcb->stack_base_ptr +
-                                        rtcb->adj_stack_size),
-                          (void *)getfp(), NULL, buffer, size, &skip
-#ifdef CONFIG_ARCH_ADDRENV
-                          , NULL
-#endif
-                          );
-          if (ret < size)
-            {
-              ret += backtrace(rtcb->stack_base_ptr, (uintptr_t *)
-                               ((uintptr_t)rtcb->stack_base_ptr +
-                                rtcb->adj_stack_size),
-                               running_regs()[REG_FP],
-                               running_regs()[REG_EPC],
-                               &buffer[ret], size - ret, &skip
-#ifdef CONFIG_ARCH_ADDRENV
-                               , NULL
-#endif
-                               );
-            }
-        }
-      else
-        {
-#ifdef CONFIG_ARCH_KERNEL_STACK
-          if ((rtcb->flags & TCB_FLAG_SYSCALL) != 0)
-            {
-              ret = backtrace(rtcb->stack_base_ptr, (uintptr_t *)
-                              ((uintptr_t)rtcb->stack_base_ptr +
-                               rtcb->adj_stack_size),
-                              (void *)rtcb->xcp.sregs[REG_FP],
-                              (void *)rtcb->xcp.sregs[REG_EPC],
-                              buffer, size, &skip
-#ifdef CONFIG_ARCH_ADDRENV
-                              , NULL
-#endif
-                              );
-            }
-          else
-#endif
-            {
-              ret = backtrace(rtcb->stack_base_ptr, (uintptr_t *)
-                              ((uintptr_t)rtcb->stack_base_ptr +
-                               rtcb->adj_stack_size),
-                              (void *)getfp(), NULL, buffer, size, &skip
-#ifdef CONFIG_ARCH_ADDRENV
-                              , NULL
-#endif
-                              );
-            }
-        }
+      tcb = rtcb;
     }
-  else
-    {
-#ifdef CONFIG_ARCH_KERNEL_STACK
-      if ((tcb->flags & TCB_FLAG_SYSCALL) != 0)
-        {
-          ret = backtrace(tcb->stack_base_ptr,
-                          (uintptr_t *)((uintptr_t)tcb->stack_base_ptr +
-                                        tcb->adj_stack_size),
-                          (void *)tcb->xcp.sregs[REG_FP],
-                          (void *)tcb->xcp.sregs[REG_EPC],
-                          buffer, size, &skip
-#ifdef CONFIG_ARCH_ADDRENV
-                          , tcb->addrenv_own
+
+  ubase  = tcb->stack_base_ptr;
+  ulimit = (uintptr_t *)((uintptr_t)tcb->stack_base_ptr +
+                         tcb->adj_stack_size);
+
+#ifdef CONFIG_LIB_SYSCALL
+  bool insyscall = (tcb->flags & TCB_FLAG_SYSCALL) != 0;

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to