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