1 /*
2  * Copyright (C) 2015-2021 Alibaba Group Holding Limited
3  */
4 
5 #include "debug_api.h"
6 
7 typedef int32_t (*BT_PRINT)(const char *fmt, ...);
8 
aos_debug_backtrace_now(int32_t (* print_func)(const char * fmt,...))9 void aos_debug_backtrace_now(int32_t (*print_func)(const char *fmt, ...))
10 {
11     BT_PRINT bt_printf = print_func ?  print_func : printf;
12 
13     debug_backtrace_now(bt_printf);
14 }
15 
aos_debug_backtrace_task(char * taskname,int32_t (* print_func)(const char * fmt,...))16 void aos_debug_backtrace_task(char *taskname, int32_t (*print_func)(const char *fmt, ...))
17 {
18     BT_PRINT bt_printf = print_func ?  print_func : printf;
19 
20     debug_backtrace_task(taskname, bt_printf);
21 }
22 
aos_debug_mm_overview(int32_t (* print_func)(const char * fmt,...))23 void aos_debug_mm_overview(int32_t (*print_func)(const char *fmt, ...))
24 {
25     BT_PRINT bt_printf = print_func ?  print_func : printf;
26 
27     debug_mm_overview(bt_printf);
28 }
29 
aos_debug_task_overview(int32_t (* print_func)(const char * fmt,...))30 void aos_debug_task_overview(int32_t (*print_func)(const char *fmt, ...))
31 {
32     BT_PRINT bt_printf = print_func ?  print_func : printf;
33 
34     debug_task_overview(bt_printf);
35 }
36 
aos_debug_buf_queue_overview(int32_t (* print_func)(const char * fmt,...))37 void aos_debug_buf_queue_overview(int32_t (*print_func)(const char *fmt, ...))
38 {
39     BT_PRINT bt_printf = print_func ?  print_func : printf;
40 
41     debug_buf_queue_overview(bt_printf);
42 }
43 
aos_debug_queue_overview(int32_t (* print_func)(const char * fmt,...))44 void aos_debug_queue_overview(int32_t (*print_func)(const char *fmt, ...))
45 {
46     BT_PRINT bt_printf = print_func ?  print_func : printf;
47 
48     debug_queue_overview(bt_printf);
49 }
50 
aos_debug_sem_overview(int32_t (* print_func)(const char * fmt,...))51 void aos_debug_sem_overview(int32_t (*print_func)(const char *fmt, ...))
52 {
53     BT_PRINT bt_printf = print_func ?  print_func : printf;
54 
55     debug_sem_overview(bt_printf);
56 }
57 
aos_debug_mutex_overview(int32_t (* print_func)(const char * fmt,...))58 void aos_debug_mutex_overview(int32_t (*print_func)(const char *fmt, ...))
59 {
60     BT_PRINT bt_printf = print_func ?  print_func : printf;
61 
62     debug_mutex_overview(bt_printf);
63 }
64 
aos_debug_overview(int32_t (* print_func)(const char * fmt,...))65 void aos_debug_overview(int32_t (*print_func)(const char *fmt, ...))
66 {
67     BT_PRINT bt_printf = print_func ?  print_func : printf;
68 
69     debug_overview(bt_printf);
70 }
71 
72 #if (RHINO_CONFIG_SYS_STATS > 0)
aos_debug_task_cpu_usage_stats(void)73 void aos_debug_task_cpu_usage_stats(void)
74 {
75     debug_task_cpu_usage_stats();
76 }
77 
aos_debug_task_cpu_usage_get(char * taskname)78 int32_t aos_debug_task_cpu_usage_get(char *taskname)
79 {
80     ktask_t *task;
81     task = krhino_task_find(taskname);
82     if (task == NULL) {
83         return -1;
84     }
85 
86     return debug_task_cpu_usage_get(task);
87 }
88 
aos_debug_total_cpu_usage_get(uint32_t cpuid)89 uint32_t aos_debug_total_cpu_usage_get(uint32_t cpuid)
90 {
91     return debug_total_cpu_usage_get(cpuid);
92 }
93 
aos_debug_total_cpu_usage_show(void)94 void aos_debug_total_cpu_usage_show(void)
95 {
96     debug_total_cpu_usage_show(NULL, 0, 0);
97 }
98 #endif
99 
aos_debug_fatal_error(kstat_t err,char * file,int32_t line)100 void aos_debug_fatal_error(kstat_t err, char *file, int32_t line)
101 {
102     debug_fatal_error(err, file, line);
103 }
104 
aos_debug_init(void)105 void aos_debug_init(void)
106 {
107     debug_init();
108 }