|
|
@@ -13,10 +13,18 @@
|
|
13
|
13
|
#include "arch/mcd_arch_interface.h"
|
|
14
|
14
|
#include "addr2line/addr2line.h"
|
|
15
|
15
|
|
|
|
16
|
+#define PRINT_COREDUMP_ELF 0 // 直接打印elf格式
|
|
16
|
17
|
#define PRINT_COREDUMP_INFO_STRING 1 // 打印字符串格式的coredump信息
|
|
17
|
18
|
#define STACK_CORE_REG_SIZE (17 * 4) // 16个自动+手动压栈寄存器 + exe_return
|
|
18
|
19
|
#define STACK_FPU_REG_SIZE (17 * 4) // 17个自动压栈的浮点寄存器
|
|
19
|
20
|
|
|
|
21
|
+static rt_int32_t is_thread_object(rt_thread_t thread)
|
|
|
22
|
+{
|
|
|
23
|
+ /* Check if the object is a thread (both static and dynamic) */
|
|
|
24
|
+ return ((thread->type & ~RT_Object_Class_Static) == RT_Object_Class_Thread);
|
|
|
25
|
+}
|
|
|
26
|
+
|
|
|
27
|
+#if PRINT_COREDUMP_ELF
|
|
20
|
28
|
/*
|
|
21
|
29
|
* RT-Thread OS abstraction layer implementation for MCoreDump
|
|
22
|
30
|
*/
|
|
|
@@ -26,12 +34,6 @@ typedef struct
|
|
26
|
34
|
rt_int32_t cur_idx;
|
|
27
|
35
|
} rtthread_ti_priv_t;
|
|
28
|
36
|
|
|
29
|
|
-static rt_int32_t is_thread_object(rt_thread_t thread)
|
|
30
|
|
-{
|
|
31
|
|
- /* Check if the object is a thread (both static and dynamic) */
|
|
32
|
|
- return ((thread->type & ~RT_Object_Class_Static) == RT_Object_Class_Thread);
|
|
33
|
|
-}
|
|
34
|
|
-
|
|
35
|
37
|
static int32_t rtthread_thread_cnts(struct thread_info_ops *ops)
|
|
36
|
38
|
{
|
|
37
|
39
|
rtthread_ti_priv_t *priv = (rtthread_ti_priv_t *)ops->priv;
|
|
|
@@ -196,11 +198,12 @@ static int32_t rtthread_get_memarea(struct thread_info_ops *ops, int32_t idx,
|
|
196
|
198
|
}
|
|
197
|
199
|
return 0;
|
|
198
|
200
|
}
|
|
|
201
|
+#endif
|
|
199
|
202
|
|
|
200
|
203
|
#if PRINT_COREDUMP_INFO_STRING
|
|
201
|
204
|
static int mcd_print_coredump_info_string(struct thread_info_ops *ops)
|
|
202
|
205
|
{
|
|
203
|
|
- rt_int32_t current_idx = rtthread_cur_index(ops);
|
|
|
206
|
+ rt_thread_t current_thread = rt_thread_self();
|
|
204
|
207
|
rt_int32_t idx_l = 0;
|
|
205
|
208
|
struct rt_object_information *information;
|
|
206
|
209
|
struct rt_object *object;
|
|
|
@@ -220,7 +223,7 @@ static int mcd_print_coredump_info_string(struct thread_info_ops *ops)
|
|
220
|
223
|
if (is_thread_object(thread))
|
|
221
|
224
|
{
|
|
222
|
225
|
/* If this is the current thread, use current stack pointer */
|
|
223
|
|
- if (idx_l == current_idx)
|
|
|
226
|
+ if (thread == current_thread)
|
|
224
|
227
|
{
|
|
225
|
228
|
uint32_t fpu_flag = 0;
|
|
226
|
229
|
addr = (rt_uint32_t)get_cur_core_regset_address()->sp; // 异常中填充
|
|
|
@@ -273,18 +276,22 @@ static int mcd_print_coredump_info_string(struct thread_info_ops *ops)
|
|
273
|
276
|
|
|
274
|
277
|
void mcd_rtos_thread_ops(struct thread_info_ops *ops)
|
|
275
|
278
|
{
|
|
|
279
|
+ memset(ops, 0, sizeof(struct thread_info_ops));
|
|
|
280
|
+#if PRINT_COREDUMP_ELF
|
|
276
|
281
|
static rtthread_ti_priv_t priv;
|
|
277
|
282
|
ops->get_threads_count = rtthread_thread_cnts;
|
|
278
|
283
|
ops->get_current_thread_idx = rtthread_cur_index;
|
|
279
|
284
|
ops->get_thread_regset = rtthread_thread_register;
|
|
280
|
285
|
ops->get_memarea_count = rtthread_get_mem_cnts;
|
|
281
|
286
|
ops->get_memarea = rtthread_get_memarea;
|
|
282
|
|
-#if PRINT_COREDUMP_INFO_STRING
|
|
283
|
|
- ops->print_info_string = mcd_print_coredump_info_string;
|
|
284
|
|
-#endif
|
|
285
|
287
|
ops->priv = &priv;
|
|
286
|
288
|
priv.cur_idx = -1;
|
|
287
|
289
|
priv.thr_cnts = -1;
|
|
|
290
|
+#endif
|
|
|
291
|
+#if PRINT_COREDUMP_INFO_STRING
|
|
|
292
|
+ ops->print_info_string = mcd_print_coredump_info_string;
|
|
|
293
|
+#endif
|
|
|
294
|
+
|
|
288
|
295
|
}
|
|
289
|
296
|
|
|
290
|
297
|
MCD_WEAK rt_err_t rtt_hard_fault_exception_hook(void *context)
|