From patchwork Thu Sep 1 08:06:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 112842 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C4637B6F8A for ; Thu, 1 Sep 2011 18:47:05 +1000 (EST) Received: from localhost ([::1]:58348 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qz2JD-0005Lz-04 for incoming@patchwork.ozlabs.org; Thu, 01 Sep 2011 04:07:35 -0400 Received: from eggs.gnu.org ([140.186.70.92]:34757) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qz2IM-0002YN-Tq for qemu-devel@nongnu.org; Thu, 01 Sep 2011 04:06:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qz2IE-0007b4-CC for qemu-devel@nongnu.org; Thu, 01 Sep 2011 04:06:42 -0400 Received: from mtagate2.uk.ibm.com ([194.196.100.162]:53893) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qz2IE-0007aK-1L for qemu-devel@nongnu.org; Thu, 01 Sep 2011 04:06:34 -0400 Received: from d06nrmr1806.portsmouth.uk.ibm.com (d06nrmr1806.portsmouth.uk.ibm.com [9.149.39.193]) by mtagate2.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p8186XtV014573 for ; Thu, 1 Sep 2011 08:06:33 GMT Received: from d06av09.portsmouth.uk.ibm.com (d06av09.portsmouth.uk.ibm.com [9.149.37.250]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p8186VCT2285678 for ; Thu, 1 Sep 2011 09:06:32 +0100 Received: from d06av09.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p8186Ulb020128 for ; Thu, 1 Sep 2011 02:06:31 -0600 Received: from stefanha-thinkpad.manchester-maybrook.uk.ibm.com (dyn-9-174-219-30.manchester-maybrook.uk.ibm.com [9.174.219.30]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p8186RXT019938; Thu, 1 Sep 2011 02:06:30 -0600 From: Stefan Hajnoczi To: Date: Thu, 1 Sep 2011 09:06:19 +0100 Message-Id: <1314864386-14202-9-git-send-email-stefanha@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1314864386-14202-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1314864386-14202-1-git-send-email-stefanha@linux.vnet.ibm.com> MIME-Version: 1.0 X-MIME-Autoconverted: from 8bit to quoted-printable by mtagate2.uk.ibm.com id p8186XtV014573 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 194.196.100.162 Cc: Anthony Liguori , =?UTF-8?q?Llu=C3=ADs?= , =?UTF-8?q?Llu=C3=ADs=20Vilanova?= Subject: [Qemu-devel] [PATCH 08/15] trace: separate trace event control and query routines from the simple backend X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Lluís 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 --- hmp-commands.hx | 2 +- monitor.c | 11 ++++++----- trace/control.h | 11 ++++++++++- trace/default.c | 15 +++++++++++++++ trace/simple.c | 16 ++++++++-------- trace/simple.h | 2 -- 6 files changed, 40 insertions(+), 17 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index ad4174f..d77e75f 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -186,7 +186,7 @@ ETEXI .args_type = "name:s,option:b", .params = "name on|off", .help = "changes status of a specific trace event", - .mhandler.cmd = do_change_trace_event_state, + .mhandler.cmd = do_trace_event_set_state, }, STEXI diff --git a/monitor.c b/monitor.c index 935aa33..2cff62d 100644 --- a/monitor.c +++ b/monitor.c @@ -60,6 +60,7 @@ #ifdef CONFIG_TRACE_SIMPLE #include "trace.h" #endif +#include "trace/control.h" #include "ui/qemu-spice.h" //#define DEBUG @@ -593,11 +594,11 @@ static void do_help_cmd(Monitor *mon, const QDict *qdict) } #ifdef CONFIG_TRACE_SIMPLE -static void do_change_trace_event_state(Monitor *mon, const QDict *qdict) +static void do_trace_event_set_state(Monitor *mon, const QDict *qdict) { const char *tp_name = qdict_get_str(qdict, "name"); bool new_state = qdict_get_bool(qdict, "option"); - int ret = st_change_trace_event_state(tp_name, new_state); + int ret = trace_event_set_state(tp_name, new_state); if (!ret) { monitor_printf(mon, "unknown event name \"%s\"\n", tp_name); @@ -1002,9 +1003,9 @@ static void do_info_trace(Monitor *mon) st_print_trace((FILE *)mon, &monitor_fprintf); } -static void do_info_trace_events(Monitor *mon) +static void do_trace_print_events(Monitor *mon) { - st_print_trace_events((FILE *)mon, &monitor_fprintf); + trace_print_events((FILE *)mon, &monitor_fprintf); } #endif @@ -3148,7 +3149,7 @@ static const mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show available trace-events & their state", - .mhandler.info = do_info_trace_events, + .mhandler.info = do_trace_print_events, }, #endif { diff --git a/trace/control.h b/trace/control.h index bb54339..c99b4d5 100644 --- a/trace/control.h +++ b/trace/control.h @@ -10,7 +10,16 @@ #ifndef TRACE_CONTROL_H #define TRACE_CONTROL_H -#include +#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 42fdb6b..3573d5b 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 369e860..70689e9 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 08b9a52..466e75b 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);