summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorShell <[email protected]>2023-10-21 20:14:45 +0800
committerGitHub <[email protected]>2023-10-21 20:14:45 +0800
commit70a8d1d4656bc678ddada5e56263c9cb4423a623 (patch)
treeb81b97a4f4cf33df2b1a02742e80de218da51333 /include
parent90c7089d47755a3edaf9008282225c5019fa188c (diff)
[kservice] improve backtrace service in kernel (#8144)
Signed-off-by: Shell <[email protected]>
Diffstat (limited to 'include')
-rw-r--r--include/rtdef.h2
-rw-r--r--include/rthw.h23
-rw-r--r--include/rtthread.h6
3 files changed, 26 insertions, 5 deletions
diff --git a/include/rtdef.h b/include/rtdef.h
index 13a3c743ad..eb0d66b06c 100644
--- a/include/rtdef.h
+++ b/include/rtdef.h
@@ -421,6 +421,7 @@ typedef int (*init_fn_t)(void);
#define RT_ENOENT ENOENT /**< No entry */
#define RT_ENOSPC ENOSPC /**< No space left */
#define RT_EPERM EPERM /**< Operation not permitted */
+#define RT_EFAULT EFAULT /**< Bad address */
#define RT_ETRAP 254 /**< Trap event */
#else
#define RT_EOK 0 /**< There is no error */
@@ -438,6 +439,7 @@ typedef int (*init_fn_t)(void);
#define RT_ENOSPC 12 /**< No space left */
#define RT_EPERM 13 /**< Operation not permitted */
#define RT_ETRAP 14 /**< Trap event */
+#define RT_EFAULT 15 /**< Bad address */
#endif /* defined(RT_USING_LIBC) && !RT_USING_LIBC_ISO_ONLY */
/**@}*/
diff --git a/include/rthw.h b/include/rthw.h
index ed512ac14f..65764d5635 100644
--- a/include/rthw.h
+++ b/include/rthw.h
@@ -13,6 +13,7 @@
* 2018-11-17 Jesven add rt_hw_spinlock_t
* add smp support
* 2019-05-18 Bernard add empty definition for not enable cache case
+ * 2023-10-16 Shell Support a new backtrace framework
*/
#ifndef __RT_HW_H__
@@ -20,6 +21,10 @@
#include <rtdef.h>
+#if defined (RT_USING_CACHE) || defined(RT_USING_SMP)
+#include <cpuport.h> /* include spinlock, cache ops, etc. */
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -145,9 +150,20 @@ void rt_hw_context_switch_to(rt_ubase_t to);
void rt_hw_context_switch_interrupt(rt_ubase_t from, rt_ubase_t to, rt_thread_t from_thread, rt_thread_t to_thread);
#endif /*RT_USING_SMP*/
+/**
+ * Hardware Layer Backtrace Service
+ */
+struct rt_hw_backtrace_frame {
+ rt_base_t fp;
+ rt_base_t pc;
+};
+
+rt_err_t rt_hw_backtrace_frame_get(rt_thread_t thread, struct rt_hw_backtrace_frame *frame);
+
+rt_err_t rt_hw_backtrace_frame_unwind(rt_thread_t thread, struct rt_hw_backtrace_frame *frame);
+
void rt_hw_console_output(const char *str);
-void rt_hw_backtrace(rt_uint32_t *fp, rt_ubase_t thread_entry);
void rt_hw_show_memory(rt_uint32_t addr, rt_size_t size);
/*
@@ -170,7 +186,6 @@ void rt_hw_ipi_send(int ipi_vector, unsigned int cpu_mask);
#endif
#ifdef RT_USING_SMP
-#include <cpuport.h> /* for spinlock from arch */
struct rt_spinlock
{
@@ -216,9 +231,7 @@ struct rt_spinlock
};
#endif
-#ifdef RT_USING_CACHE
-#include <cpuport.h>
-#else
+#ifndef RT_USING_CACHE
#define rt_hw_isb()
#define rt_hw_dmb()
#define rt_hw_dsb()
diff --git a/include/rtthread.h b/include/rtthread.h
index 610115134c..f693b4f856 100644
--- a/include/rtthread.h
+++ b/include/rtthread.h
@@ -19,6 +19,7 @@
* 2022-06-04 Meco Man remove strnlen
* 2023-05-20 Bernard add rtatomic.h header file to included files.
* 2023-06-30 ChuShicheng move debug check from the rtdebug.h
+ * 2023-10-16 Shell Support a new backtrace framework
*/
#ifndef __RT_THREAD_H__
@@ -658,6 +659,11 @@ void rt_components_board_init(void);
#else
int rt_kprintf(const char *fmt, ...);
void rt_kputs(const char *str);
+
+rt_err_t rt_backtrace(void);
+rt_err_t rt_backtrace_thread(rt_thread_t thread);
+rt_err_t rt_backtrace_frame(struct rt_hw_backtrace_frame *frame);
+
#endif /* RT_USING_CONSOLE */
int rt_vsprintf(char *dest, const char *format, va_list arg_ptr);