root / trace / stderr.c @ 39bffca2
History | View | Annotate | Download (1.3 kB)
1 | 9a82b6a5 | Lluís | #include "trace.h" |
---|---|---|---|
2 | 9a82b6a5 | Lluís | #include "trace/control.h" |
3 | 9a82b6a5 | Lluís | |
4 | 9a82b6a5 | Lluís | |
5 | 9a82b6a5 | Lluís | void trace_print_events(FILE *stream, fprintf_function stream_printf)
|
6 | 9a82b6a5 | Lluís | { |
7 | 9a82b6a5 | Lluís | unsigned int i; |
8 | 9a82b6a5 | Lluís | |
9 | 9a82b6a5 | Lluís | for (i = 0; i < NR_TRACE_EVENTS; i++) { |
10 | 9a82b6a5 | Lluís | stream_printf(stream, "%s [Event ID %u] : state %u\n",
|
11 | 9a82b6a5 | Lluís | trace_list[i].tp_name, i, trace_list[i].state); |
12 | 9a82b6a5 | Lluís | } |
13 | 9a82b6a5 | Lluís | } |
14 | 9a82b6a5 | Lluís | |
15 | 9a82b6a5 | Lluís | bool trace_event_set_state(const char *name, bool state) |
16 | 9a82b6a5 | Lluís | { |
17 | 9a82b6a5 | Lluís | unsigned int i; |
18 | 454e202d | Mark Wu | unsigned int len; |
19 | 454e202d | Mark Wu | bool wildcard = false; |
20 | 454e202d | Mark Wu | bool matched = false; |
21 | 9a82b6a5 | Lluís | |
22 | 454e202d | Mark Wu | len = strlen(name); |
23 | 454e202d | Mark Wu | if (len > 0 && name[len - 1] == '*') { |
24 | 454e202d | Mark Wu | wildcard = true;
|
25 | 454e202d | Mark Wu | len -= 1;
|
26 | 454e202d | Mark Wu | } |
27 | 9a82b6a5 | Lluís | for (i = 0; i < NR_TRACE_EVENTS; i++) { |
28 | 454e202d | Mark Wu | if (wildcard) {
|
29 | 454e202d | Mark Wu | if (!strncmp(trace_list[i].tp_name, name, len)) {
|
30 | 454e202d | Mark Wu | trace_list[i].state = state; |
31 | 454e202d | Mark Wu | matched = true;
|
32 | 454e202d | Mark Wu | } |
33 | 454e202d | Mark Wu | continue;
|
34 | 454e202d | Mark Wu | } |
35 | 9a82b6a5 | Lluís | if (!strcmp(trace_list[i].tp_name, name)) {
|
36 | 9a82b6a5 | Lluís | trace_list[i].state = state; |
37 | 9a82b6a5 | Lluís | return true; |
38 | 9a82b6a5 | Lluís | } |
39 | 9a82b6a5 | Lluís | } |
40 | 454e202d | Mark Wu | return matched;
|
41 | 9a82b6a5 | Lluís | } |
42 | 9a82b6a5 | Lluís | |
43 | 9a82b6a5 | Lluís | bool trace_backend_init(const char *events, const char *file) |
44 | 9a82b6a5 | Lluís | { |
45 | 9a82b6a5 | Lluís | if (file) {
|
46 | 9a82b6a5 | Lluís | fprintf(stderr, "error: -trace file=...: "
|
47 | 9a82b6a5 | Lluís | "option not supported by the selected tracing backend\n");
|
48 | 9a82b6a5 | Lluís | return false; |
49 | 9a82b6a5 | Lluís | } |
50 | 9a82b6a5 | Lluís | trace_backend_init_events(events); |
51 | 9a82b6a5 | Lluís | return true; |
52 | 9a82b6a5 | Lluís | } |