1 /*
2  * Copyright (C) 2015-2021 Alibaba Group Holding Limited
3  */
4 
5 #include <stddef.h>
6 #include <stdint.h>
7 #include <string.h>
8 #include <limits.h>
9 #include <stdio.h>
10 #include "k_api.h"
11 
12 /* part of ktask_t */
13 typedef struct
14 {
15     void *task_stack;
16 }ktask_t_shadow;
17 
18 //#define OS_BACKTRACE_DEBUG
19 
20 extern void krhino_task_deathbed(void);
21 extern ktask_t_shadow *debug_task_find(char *name);
22 extern int debug_task_is_running(ktask_t_shadow *task);
23 extern void *debug_task_stack_bottom(ktask_t_shadow *task);
24 extern char *k_int2str(int num, char *str);
25 
26 void backtrace_handle(char *PC, int *SP, char *LR, int (*print_func)(const char *fmt, ...));
27 
28 /* printf call stack
29    return levels of call stack */
backtrace_now(int (* print_func)(const char * fmt,...))30 int backtrace_now(int (*print_func)(const char *fmt, ...))
31 {
32     return 0;
33 }
34 
35 /* printf call stack for task
36    return levels of call stack */
backtrace_task(void * task,int (* print_func)(const char * fmt,...))37 void backtrace_task(void *task, int (*print_func)(const char *fmt, ...))
38 {
39 
40 }
41 
42 /* backtrace start with PC and SP, find LR from stack memory
43    return levels of call stack */
backtrace_caller(char * PC,int * SP,int (* print_func)(const char * fmt,...))44 int backtrace_caller(char *PC, int *SP,
45                      int (*print_func)(const char *fmt, ...))
46 {
47     return 0;
48 }
49 
50 /* backtrace start with PC SP and LR
51    return levels of call stack */
backtrace_callee(char * PC,int * SP,char * LR,int (* print_func)(const char * fmt,...))52 int backtrace_callee(char *PC, int *SP, char *LR,
53                      int (*print_func)(const char *fmt, ...))
54 {
55     return 0;
56 }
57 
58 
59 void *g_back_trace;
60 /**
61  Get call stack, return levels of call stack
62  trace[] output buffer
63  size    buffer size
64  offset  which lvl start
65  */
backtrace_now_get(void * trace[],int size,int offset)66 int backtrace_now_get(void *trace[], int size, int offset)
67 {
68     return 0;
69 }
70 
backtrace_handle(char * PC,int * SP,char * LR,int (* print_func)(const char * fmt,...))71 void backtrace_handle(char *PC, int *SP, char *LR,
72                       int (*print_func)(const char *fmt, ...))
73 {
74     return;
75 }
76