diff options
author | Lluís <xscript@gmx.net> | 2011-08-31 20:31:18 +0200 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> | 2011-09-01 10:34:54 +0100 |
commit | fc764105397fa55e7c03f42a6d019063ec0cad00 (patch) | |
tree | 554e18aadadccd03db4f95ac6856e97527f2de9f /trace | |
parent | 49926043c1319ce99481d45c87c602c20b9dbb79 (diff) | |
download | qemu-fc764105397fa55e7c03f42a6d019063ec0cad00.tar.gz qemu-fc764105397fa55e7c03f42a6d019063ec0cad00.tar.bz2 qemu-fc764105397fa55e7c03f42a6d019063ec0cad00.zip |
trace: separate trace event control and query routines from the simple backend
Generalize the 'st_print_trace_events' and 'st_change_trace_event_state' into
backend-specific 'trace_print_events' and 'trace_event_set_state' (respectively)
in the "trace/control.h" file.
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Diffstat (limited to 'trace')
-rw-r--r-- | trace/control.h | 11 | ||||
-rw-r--r-- | trace/default.c | 15 | ||||
-rw-r--r-- | trace/simple.c | 16 | ||||
-rw-r--r-- | trace/simple.h | 2 |
4 files changed, 33 insertions, 11 deletions
diff --git a/trace/control.h b/trace/control.h index bb54339258..c99b4d50a8 100644 --- a/trace/control.h +++ b/trace/control.h @@ -10,7 +10,16 @@ #ifndef TRACE_CONTROL_H #define TRACE_CONTROL_H -#include <stdbool.h> +#include "qemu-common.h" + + +/** Print the state of all events. */ +void trace_print_events(FILE *stream, fprintf_function stream_printf); +/** Set the state of an event. + * + * @return Whether the state changed. + */ +bool trace_event_set_state(const char *name, bool state); /** Initialize the tracing backend. diff --git a/trace/default.c b/trace/default.c index 42fdb6b6a4..3573d5b296 100644 --- a/trace/default.c +++ b/trace/default.c @@ -10,6 +10,21 @@ #include "trace/control.h" +void trace_print_events(FILE *stream, fprintf_function stream_printf) +{ + fprintf(stderr, "warning: " + "cannot print the trace events with the current backend\n"); + stream_printf(stream, "error: " + "operation not supported with the current backend\n"); +} + +bool trace_event_set_state(const char *name, bool state) +{ + fprintf(stderr, "warning: " + "cannot set the state of a trace event with the current backend\n"); + return false; +} + bool trace_backend_init(const char *file) { if (file) { diff --git a/trace/simple.c b/trace/simple.c index 369e860305..70689e9484 100644 --- a/trace/simple.c +++ b/trace/simple.c @@ -303,7 +303,12 @@ void st_print_trace(FILE *stream, int (*stream_printf)(FILE *stream, const char } } -void st_print_trace_events(FILE *stream, int (*stream_printf)(FILE *stream, const char *fmt, ...)) +void st_flush_trace_buffer(void) +{ + flush_trace_file(true); +} + +void trace_print_events(FILE *stream, fprintf_function stream_printf) { unsigned int i; @@ -313,24 +318,19 @@ void st_print_trace_events(FILE *stream, int (*stream_printf)(FILE *stream, cons } } -bool st_change_trace_event_state(const char *name, bool enabled) +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 = enabled; + trace_list[i].state = state; return true; } } return false; } -void st_flush_trace_buffer(void) -{ - flush_trace_file(true); -} - bool trace_backend_init(const char *file) { pthread_t thread; diff --git a/trace/simple.h b/trace/simple.h index 08b9a52146..466e75b4ff 100644 --- a/trace/simple.h +++ b/trace/simple.h @@ -30,8 +30,6 @@ void trace4(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3, uint64_t void trace5(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3, uint64_t x4, uint64_t x5); void trace6(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3, uint64_t x4, uint64_t x5, uint64_t x6); void st_print_trace(FILE *stream, fprintf_function stream_printf); -void st_print_trace_events(FILE *stream, fprintf_function stream_printf); -bool st_change_trace_event_state(const char *tname, bool tstate); void st_print_trace_file_status(FILE *stream, fprintf_function stream_printf); void st_set_trace_file_enabled(bool enable); bool st_set_trace_file(const char *file); |