1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/**
* @file debug_cmd.c Debug commands
*
* Copyright (C) 2010 - 2016 Creytiv.com
*/
#include <stdlib.h>
#include <time.h>
#include <re.h>
#include <baresip.h>
static uint64_t start_ticks; /**< Ticks when app started */
static time_t start_time; /**< Start time of application */
static int cmd_net_debug(struct re_printf *pf, void *unused)
{
(void)unused;
return net_debug(pf, baresip_network());
}
static int print_system_info(struct re_printf *pf, void *arg)
{
uint32_t uptime;
int err = 0;
(void)arg;
uptime = (uint32_t)((long long)(tmr_jiffies() - start_ticks)/1000);
err |= re_hprintf(pf, "\n--- System info: ---\n");
err |= re_hprintf(pf, " Machine: %s/%s\n", sys_arch_get(),
sys_os_get());
err |= re_hprintf(pf, " Version: %s (libre v%s)\n",
BARESIP_VERSION, sys_libre_version_get());
err |= re_hprintf(pf, " Build: %H\n", sys_build_get, NULL);
err |= re_hprintf(pf, " Kernel: %H\n", sys_kernel_get, NULL);
err |= re_hprintf(pf, " Uptime: %H\n", fmt_human_time, &uptime);
err |= re_hprintf(pf, " Started: %s", ctime(&start_time));
#ifdef __VERSION__
err |= re_hprintf(pf, " Compiler: %s\n", __VERSION__);
#endif
return err;
}
static int cmd_config_print(struct re_printf *pf, void *unused)
{
(void)unused;
return config_print(pf, conf_config());
}
static int cmd_ua_debug(struct re_printf *pf, void *unused)
{
(void)unused;
return ua_debug(pf, uag_current());
}
static const struct cmd debugcmdv[] = {
{"main", 0, 0, "Main loop debug", re_debug },
{"config", 'g', 0, "Print configuration", cmd_config_print },
{"sipstat", 'i', 0, "SIP debug", ua_print_sip_status },
{"modules", 'm', 0, "Module debug", mod_debug },
{"netstat", 'n', 0, "Network debug", cmd_net_debug },
{"sysinfo", 's', 0, "System info", print_system_info },
{"timers", 0, 0, "Timer debug", tmr_status },
{"uastat", 'u', 0, "UA debug", cmd_ua_debug },
{"memstat", 'y', 0, "Memory status", mem_status },
};
static int module_init(void)
{
int err;
start_ticks = tmr_jiffies();
(void)time(&start_time);
err = cmd_register(baresip_commands(),
debugcmdv, ARRAY_SIZE(debugcmdv));
return err;
}
static int module_close(void)
{
cmd_unregister(baresip_commands(), debugcmdv);
return 0;
}
const struct mod_export DECL_EXPORTS(debug_cmd) = {
"debug_cmd",
"application",
module_init,
module_close
};
|