1 /*
2  * Copyright (C) 2015-2021 Alibaba Group Holding Limited
3  */
4 #if AOS_COMP_CLI
5 #include "aos/debug.h"
6 #include "aos/cli.h"
7 
debug_help_show(void)8 static void debug_help_show(void)
9 {
10     aos_cli_printf("You can use debug cmd to show api test:\r\n");
11 	aos_cli_printf("debug_api help  --- show this\r\n");
12 	aos_cli_printf("debug_api 1     --- show memory info\r\n");
13 	aos_cli_printf("debug_api 2     --- show task info\r\n");
14 	aos_cli_printf("debug_api 3     --- show bufqueue info\r\n");
15 	aos_cli_printf("debug_api 4     --- show queue info\r\n");
16 	aos_cli_printf("debug_api 5     --- show sem info\r\n");
17 	aos_cli_printf("debug_api 6     --- show mutex info\r\n");
18 	aos_cli_printf("debug_api 7     --- show backtrace now\r\n");
19 	aos_cli_printf("debug_api 8     --- show backtrace task\r\n");
20 	aos_cli_printf("debug_api all   --- show all above\r\n");
21 }
22 
23 
debug_api_example(int argc,char ** argv)24 static void debug_api_example(int argc, char **argv)
25 {
26 	if (argc != 2) {
27 		aos_cli_printf("use 'debug_api help' for test\r\n");
28 		return;
29 	}
30 
31 	if (strcmp(argv[1], "help") == 0) {
32 		debug_help_show();
33 	} else if (strcmp(argv[1], "1") == 0) {
34 		aos_debug_mm_overview(aos_cli_printf);
35 	} else if (strcmp(argv[1], "2") == 0) {
36 		aos_debug_task_overview(aos_cli_printf);
37 	} else if (strcmp(argv[1], "3") == 0) {
38 		aos_debug_buf_queue_overview(aos_cli_printf);
39 	} else if (strcmp(argv[1], "4") == 0) {
40 		aos_debug_queue_overview(aos_cli_printf);
41 	} else if (strcmp(argv[1], "5") == 0) {
42 		aos_debug_sem_overview(aos_cli_printf);
43 	} else if (strcmp(argv[1], "6") == 0) {
44 		aos_debug_mutex_overview(aos_cli_printf);
45 	} else if (strcmp(argv[1], "7") == 0) {
46 		aos_debug_backtrace_now(aos_cli_printf);
47 	} else if (strcmp(argv[1], "8") == 0) {
48 		aos_debug_backtrace_task("idle_task", aos_cli_printf);
49 	} else if (strcmp(argv[1], "all") == 0) {
50 		aos_debug_overview(aos_cli_printf);
51 	} else {
52 		aos_cli_printf("debug example cmd not exist\r\n");
53 	}
54 }
55 
56 /* reg args: fun, cmd, description*/
57 ALIOS_CLI_CMD_REGISTER(debug_api_example, debug_api, debug api example)
58 #endif /* AOS_COMP_CLI */
59