1 /** 2 * @file debug.h 3 * @copyright Copyright (C) 2015-2021 Alibaba Group Holding Limited 4 */ 5 6 #ifndef AOS_DBG_H 7 #define AOS_DBG_H 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 /** @defgroup debug_aos_api debug 14 * @{ 15 */ 16 17 #include <stdint.h> 18 #include <k_api.h> 19 20 /** 21 * Show current contex backtrace 22 * 23 * @param[in] print_func function to output information, NULL for "printf" 24 * 25 * @retrun NULL 26 */ 27 void aos_debug_backtrace_now(int32_t (*print_func)(const char *fmt, ...)); 28 29 /** 30 * Show task backtrace 31 * 32 * @param[in] taskname the task name which is need to be got 33 * @param[in] print_func function to output information, NULL for "printf" 34 * 35 * @retrun NULL 36 */ 37 void aos_debug_backtrace_task(char *taskname, int32_t (*print_func)(const char *fmt, ...)); 38 39 /** 40 * Show the overview of memory(heap and pool) 41 * 42 * @param[in] print_func function to output information, NULL for "printf" 43 * 44 * @retrun NULL 45 */ 46 void aos_debug_mm_overview(int32_t (*print_func)(const char *fmt, ...)); 47 48 /** 49 * Show the overview of tasks 50 * 51 * @param[in] print_func function to output information, NULL for "printf" 52 * 53 * @retrun NULL 54 */ 55 void aos_debug_task_overview(int32_t (*print_func)(const char *fmt, ...)); 56 57 /** 58 * Show the overview of buf_queue 59 * 60 * @param[in] print_func function to output information, NULL for "printf" 61 * 62 * @retrun NULL 63 */ 64 void aos_debug_buf_queue_overview(int32_t (*print_func)(const char *fmt, ...)); 65 66 /** 67 * Show the overview of queue 68 * 69 * @param[in] print_func function to output information, NULL for "printf" 70 * 71 * @retrun NULL 72 */ 73 void aos_debug_queue_overview(int32_t (*print_func)(const char *fmt, ...)); 74 75 /** 76 * Show the overview of sem 77 * 78 * @param[in] print_func function to output information, NULL for "printf" 79 * 80 * @retrun NULL 81 */ 82 void aos_debug_sem_overview(int32_t (*print_func)(const char *fmt, ...)); 83 84 /** 85 * Show the overview of mutex 86 * 87 * @param[in] print_func function to output information, NULL for "printf" 88 * 89 * @retrun NULL 90 */ 91 void aos_debug_mutex_overview(int32_t (*print_func)(const char *fmt, ...)); 92 93 /** 94 * Show the overview of all(task/memory/bufqueue/queue/sem) 95 * 96 * @param[in] print_func function to output information, NULL for "printf" 97 * 98 * @retrun NULL 99 */ 100 void aos_debug_overview(int32_t (*print_func)(const char *fmt, ...)); 101 102 /** 103 * This function will statistics the task run time in the previous statistics cycle 104 * 105 * @return NULL 106 */ 107 void aos_debug_task_cpu_usage_stats(void); 108 109 /** 110 * This function will get the cpuusage for the specified task 111 * 112 * @param[in] taskname the task name which is need to be got 113 * 114 * @return -1 is error, others is cpuusage, the units are 1/10,000 115 */ 116 int32_t aos_debug_task_cpu_usage_get(char *taskname); 117 118 /** 119 * This function will get the cpuusage for the specified CPU 120 * 121 * @param[in] cpuid the cpu id to obtain CPU utilization 122 * 123 * @return cpuusage, the units are 1/10,000 124 */ 125 uint32_t aos_debug_total_cpu_usage_get(uint32_t cpuid); 126 127 /** 128 * This function will show the statistics for CPU utilization 129 * 130 * @return NULL 131 */ 132 void aos_debug_total_cpu_usage_show(void); 133 134 /** 135 * system assert, called by k_err_proc 136 * 137 * @param[in] err the kernel err status 138 * @param[in] file same as __FILE__ 139 * @param[in] file same as __line__ 140 * @return NULL 141 */ 142 void aos_debug_fatal_error(kstat_t err, char *file, int32_t line); 143 144 /** 145 * This function support debug print same as printf 146 * 147 * @return 0 is ok, others err 148 */ 149 int32_t aos_debug_printf(const char *fmt, ...); 150 #define printk aos_debug_printf 151 152 /** 153 * This function init debug module 154 * 155 * @return NULL 156 */ 157 void aos_debug_init(void); 158 159 /** 160 * @} 161 */ 162 163 #ifdef __cplusplus 164 } 165 #endif 166 167 #endif /* AOS_DBG_H */ 168