From patchwork Tue May 3 18:44:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?Q?Llu=C3=ADs?= X-Patchwork-Id: 93882 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 A52CCB6F5C for ; Wed, 4 May 2011 04:44:30 +1000 (EST) Received: from localhost ([::1]:45279 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QHKaA-0007t5-GK for incoming@patchwork.ozlabs.org; Tue, 03 May 2011 14:44:26 -0400 Received: from eggs.gnu.org ([140.186.70.92]:35308) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QHKa1-0007sm-UE for qemu-devel@nongnu.org; Tue, 03 May 2011 14:44:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QHKa0-00035i-EK for qemu-devel@nongnu.org; Tue, 03 May 2011 14:44:17 -0400 Received: from mailout-de.gmx.net ([213.165.64.23]:36837) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1QHKa0-00035L-2N for qemu-devel@nongnu.org; Tue, 03 May 2011 14:44:16 -0400 Received: (qmail invoked by alias); 03 May 2011 18:44:14 -0000 Received: from unknown (EHLO localhost) [84.88.53.92] by mail.gmx.net (mp001) with SMTP; 03 May 2011 20:44:14 +0200 X-Authenticated: #12333383 X-Provags-ID: V01U2FsdGVkX1+LIKtMdR+LcK8QL0PFifXV6+5DUQRWDW2wDsF7qH o68nQZzClwpPGr From: =?utf-8?Q?Llu=C3=ADs?= To: qemu-devel@nongnu.org References: <20110502131131.24596.1053.stgit@ginnungagap.bsc.es> <20110502131210.24596.95254.stgit@ginnungagap.bsc.es> User-Agent: StGit/0.15 Mail-Followup-To: qemu-devel@nongnu.org, stefanha@gmail.com, chouteau@adacore.com Date: Tue, 03 May 2011 20:44:43 +0200 In-Reply-To: <20110502131210.24596.95254.stgit@ginnungagap.bsc.es> (=?utf-8?Q?=22Llu=C3=ADs=22's?= message of "Mon, 02 May 2011 15:12:10 +0200") Message-ID: <87oc3jmxno.fsf_-_@ginnungagap.bsc.es> MIME-Version: 1.0 X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 213.165.64.23 Cc: stefanha@gmail.com, chouteau@adacore.com Subject: [Qemu-devel] [PATCH v3 05/10] trace-state: always compile support for controlling and querying trace event states 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 The current interface is generic for this small set of operations, and thus other backends can easily modify the "trace/control.c" file to add their own implementation. Signed-off-by: LluĂ­s Vilanova --- docs/tracing.txt | 39 +++++++++++++++++++++------------------ hmp-commands.hx | 7 +++++-- monitor.c | 8 ++++---- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/docs/tracing.txt b/docs/tracing.txt index 1ad106a..017ff59 100644 --- a/docs/tracing.txt +++ b/docs/tracing.txt @@ -108,6 +108,27 @@ portability macros, ensure they are preceded and followed by double quotes: of trace events. Marking trace events disabled by default saves the user from having to manually disable noisy trace events. +== Generic interface and monitor commands == + +You can programmatically query and control the dynamic state of trace events +through a backend-agnostic interface: + +* trace_print_events + +* trace_event_set_state + +Note that some of the backends do not provide and implementation for this +interface, in which case QEMU will just print a warning. + +This functionality is also provided through monitor commands: + +* info trace-events + View available trace events and their state. State 1 means enabled, state 0 + means disabled. + +* trace-event NAME on|off + Enable/disable a given trace event. + == Trace backends == The "tracetool" script automates tedious trace event code generation and also @@ -157,27 +178,9 @@ unless you have specific needs for more advanced backends. flushed and emptied. This means the 'info trace' will display few or no entries if the buffer has just been flushed. -* info trace-events - View available trace events and their state. State 1 means enabled, state 0 - means disabled. - -* trace-event NAME on|off - Enable/disable a given trace event. - * trace-file on|off|flush|set Enable/disable/flush the trace file or set the trace file name. -==== Enabling/disabling trace events programmatically ==== - -The st_change_trace_event_state() function can be used to enable or disable trace -events at runtime inside QEMU: - - #include "trace.h" - - st_change_trace_event_state("virtio_irq", true); /* enable */ - [...] - st_change_trace_event_state("virtio_irq", false); /* disable */ - ==== Analyzing trace files ==== The "simple" backend produces binary trace files that can be formatted with the diff --git a/hmp-commands.hx b/hmp-commands.hx index 5eec93e..25148c2 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -180,7 +180,6 @@ STEXI Output logs to @var{filename}. ETEXI -#ifdef CONFIG_SIMPLE_TRACE { .name = "trace-event", .args_type = "name:s,option:b", @@ -195,6 +194,7 @@ STEXI changes status of a trace event ETEXI +#if defined(CONFIG_SIMPLE_TRACE) { .name = "trace-file", .args_type = "op:s?,arg:F?", @@ -1359,10 +1359,13 @@ ETEXI STEXI @item info trace show contents of trace buffer +ETEXI +#endif + +STEXI @item info trace-events show available trace events and their state ETEXI -#endif STEXI @end table diff --git a/monitor.c b/monitor.c index b6f78ef..1d9bddd 100644 --- a/monitor.c +++ b/monitor.c @@ -57,9 +57,9 @@ #include "json-parser.h" #include "osdep.h" #include "exec-all.h" +#include "trace/control.h" #ifdef CONFIG_SIMPLE_TRACE #include "trace/simple.h" -#include "trace/control.h" #endif #include "ui/qemu-spice.h" @@ -593,7 +593,6 @@ static void do_help_cmd(Monitor *mon, const QDict *qdict) help_cmd(mon, qdict_get_try_str(qdict, "name")); } -#ifdef CONFIG_SIMPLE_TRACE static void do_trace_event_set_state(Monitor *mon, const QDict *qdict) { const char *tp_name = qdict_get_str(qdict, "name"); @@ -605,6 +604,7 @@ static void do_trace_event_set_state(Monitor *mon, const QDict *qdict) } } +#ifdef CONFIG_SIMPLE_TRACE static void do_trace_file(Monitor *mon, const QDict *qdict) { const char *op = qdict_get_try_str(qdict, "op"); @@ -1002,12 +1002,12 @@ static void do_info_trace(Monitor *mon) { st_print_trace((FILE *)mon, &monitor_fprintf); } +#endif static void do_trace_print_events(Monitor *mon) { trace_print_events((FILE *)mon, &monitor_fprintf); } -#endif /** * do_quit(): Quit QEMU execution @@ -3093,6 +3093,7 @@ static const mon_cmd_t info_cmds[] = { .help = "show current contents of trace buffer", .mhandler.info = do_info_trace, }, +#endif { .name = "trace-events", .args_type = "", @@ -3100,7 +3101,6 @@ static const mon_cmd_t info_cmds[] = { .help = "show available trace-events & their state", .mhandler.info = do_trace_print_events, }, -#endif { .name = NULL, },