From 9a82b6a590bd7c845ab9754b34b33ffee982ccb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs?= Date: Wed, 31 Aug 2011 20:31:51 +0200 Subject: trace: [stderr] add support for dynamically enabling/disabling events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Uses the generic interface provided in "trace/control.h" in order to provide a programmatic interface as well as command line and monitor controls. Signed-off-by: Fabien Chouteau Signed-off-by: LluĂ­s Vilanova --- trace/stderr.c | 37 +++++++++++++++++++++++++++++++++++++ trace/stderr.h | 11 +++++++++++ 2 files changed, 48 insertions(+) create mode 100644 trace/stderr.c create mode 100644 trace/stderr.h (limited to 'trace') diff --git a/trace/stderr.c b/trace/stderr.c new file mode 100644 index 0000000000..7107c4a131 --- /dev/null +++ b/trace/stderr.c @@ -0,0 +1,37 @@ +#include "trace.h" +#include "trace/control.h" + + +void trace_print_events(FILE *stream, fprintf_function stream_printf) +{ + unsigned int i; + + for (i = 0; i < NR_TRACE_EVENTS; i++) { + stream_printf(stream, "%s [Event ID %u] : state %u\n", + trace_list[i].tp_name, i, trace_list[i].state); + } +} + +bool trace_event_set_state(const char *name, bool state) +{ + unsigned int i; + + for (i = 0; i < NR_TRACE_EVENTS; i++) { + if (!strcmp(trace_list[i].tp_name, name)) { + trace_list[i].state = state; + return true; + } + } + return false; +} + +bool trace_backend_init(const char *events, const char *file) +{ + if (file) { + fprintf(stderr, "error: -trace file=...: " + "option not supported by the selected tracing backend\n"); + return false; + } + trace_backend_init_events(events); + return true; +} diff --git a/trace/stderr.h b/trace/stderr.h new file mode 100644 index 0000000000..d575b613e3 --- /dev/null +++ b/trace/stderr.h @@ -0,0 +1,11 @@ +#ifndef TRACE_STDERR_H +#define TRACE_STDERR_H + +typedef uint64_t TraceEventID; + +typedef struct { + const char *tp_name; + bool state; +} TraceEvent; + +#endif /* ! TRACE_STDERR_H */ -- cgit v1.2.1