You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gu...@apache.org on 2021/08/20 16:11:54 UTC

[incubator-nuttx] 02/02: nuttx/up_backtrace: add up_backtrace interface

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

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

commit c826c37277084c2758f9e6425ee3418e6f8df3d0
Author: chao.an <an...@xiaomi.com>
AuthorDate: Fri Aug 20 20:32:55 2021 +0800

    nuttx/up_backtrace: add up_backtrace interface
    
    Signed-off-by: chao.an <an...@xiaomi.com>
---
 include/nuttx/arch.h | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h
index 42e2dfe..82092f5 100644
--- a/include/nuttx/arch.h
+++ b/include/nuttx/arch.h
@@ -492,6 +492,35 @@ void up_exit() noreturn_function;
 
 void up_assert(FAR const char *filename, int linenum);
 
+#ifdef CONFIG_ARCH_HAVE_BACKTRACE
+
+/****************************************************************************
+ * Name: up_backtrace
+ *
+ * Description:
+ *  up_backtrace()  returns  a backtrace for the TCB, in the array
+ *  pointed to by buffer.  A backtrace is the series of currently active
+ *  function calls for the program.  Each item in the array pointed to by
+ *  buffer is of type void *, and is the return address from the
+ *  corresponding stack frame.  The size argument specifies the maximum
+ *  number of addresses that can be stored in buffer.   If  the backtrace is
+ *  larger than size, then the addresses corresponding to the size most
+ *  recent function calls are returned; to obtain the complete backtrace,
+ *  make sure that buffer and size are large enough.
+ *
+ * Input Parameters:
+ *   tcb    - Address of the task's TCB, NULL means dump the running task
+ *   buffer - Return address from the corresponding stack frame
+ *   size   - Maximum number of addresses that can be stored in buffer
+ *
+ * Returned Value:
+ *   up_backtrace() returns the number of addresses returned in buffer
+ *
+ ****************************************************************************/
+
+int up_backtrace(FAR struct tcb_s *tcb, FAR void **buffer, int size);
+#endif /* CONFIG_ARCH_HAVE_BACKTRACE */
+
 /****************************************************************************
  * Name: up_schedule_sigaction
  *