From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:34775) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qz2IN-0002cF-TW for qemu-devel@nongnu.org; Thu, 01 Sep 2011 04:06:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qz2ID-0007aT-QY for qemu-devel@nongnu.org; Thu, 01 Sep 2011 04:06:43 -0400 Received: from mtagate7.uk.ibm.com ([194.196.100.167]:56273) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qz2ID-0007Yu-Ea for qemu-devel@nongnu.org; Thu, 01 Sep 2011 04:06:33 -0400 Received: from d06nrmr1507.portsmouth.uk.ibm.com (d06nrmr1507.portsmouth.uk.ibm.com [9.149.38.233]) by mtagate7.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p8186W80027237 for ; Thu, 1 Sep 2011 08:06:32 GMT Received: from d06av09.portsmouth.uk.ibm.com (d06av09.portsmouth.uk.ibm.com [9.149.37.250]) by d06nrmr1507.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p8186VSb2355400 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 p8186VSc020149 for ; Thu, 1 Sep 2011 02:06:31 -0600 From: Stefan Hajnoczi Date: Thu, 1 Sep 2011 09:06:20 +0100 Message-Id: <1314864386-14202-10-git-send-email-stefanha@linux.vnet.ibm.com> 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 09/15] trace: always compile support for controlling and querying trace event states List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori , =?UTF-8?q?Llu=C3=ADs?= , =?UTF-8?q?Llu=C3=ADs=20Vilanova?= From: Llu=C3=ADs The current interface is generic for this small set of operations, and th= us other backends can easily modify the "trace/control.c" file to add their = own implementation. Signed-off-by: Llu=C3=ADs Vilanova --- docs/tracing.txt | 48 ++++++++++++++++++++++++++++++------------------ hmp-commands.hx | 7 +++++-- monitor.c | 9 +++++---- 3 files changed, 40 insertions(+), 24 deletions(-) diff --git a/docs/tracing.txt b/docs/tracing.txt index 1ad106a..41eb8e6 100644 --- a/docs/tracing.txt +++ b/docs/tracing.txt @@ -108,6 +108,36 @@ portability macros, ensure they are preceded and fol= lowed by double quotes: of trace events. Marking trace events disabled by default saves the = user from having to manually disable noisy trace events. =20 +=3D=3D Generic interface and monitor commands =3D=3D + +You can programmatically query and control the dynamic state of trace ev= ents +through a backend-agnostic interface: + +* trace_print_events + +* trace_event_set_state + Enables or disables trace events at runtime inside QEMU. + The function returns "true" if the state of the event has been success= fully + changed, or "false" otherwise: + + #include "trace/control.h" + =20 + trace_event_set_state("virtio_irq", true); /* enable */ + [...] + trace_event_set_state("virtio_irq", false); /* disable */ + +Note that some of the backends do not provide an 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, s= tate 0 + means disabled. + +* trace-event NAME on|off + Enable/disable a given trace event. + =3D=3D Trace backends =3D=3D =20 The "tracetool" script automates tedious trace event code generation and= also @@ -157,27 +187,9 @@ unless you have specific needs for more advanced bac= kends. flushed and emptied. This means the 'info trace' will display few or = no entries if the buffer has just been flushed. =20 -* info trace-events - View available trace events and their state. State 1 means enabled, s= tate 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. =20 -=3D=3D=3D=3D Enabling/disabling trace events programmatically =3D=3D=3D=3D - -The st_change_trace_event_state() function can be used to enable or disa= ble trace -events at runtime inside QEMU: - - #include "trace.h" - =20 - st_change_trace_event_state("virtio_irq", true); /* enable */ - [...] - st_change_trace_event_state("virtio_irq", false); /* disable */ - =3D=3D=3D=3D Analyzing trace files =3D=3D=3D=3D =20 The "simple" backend produces binary trace files that can be formatted w= ith the diff --git a/hmp-commands.hx b/hmp-commands.hx index d77e75f..9e1cca8 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -180,7 +180,6 @@ STEXI Output logs to @var{filename}. ETEXI =20 -#ifdef CONFIG_TRACE_SIMPLE { .name =3D "trace-event", .args_type =3D "name:s,option:b", @@ -195,6 +194,7 @@ STEXI changes status of a trace event ETEXI =20 +#if defined(CONFIG_SIMPLE_TRACE) { .name =3D "trace-file", .args_type =3D "op:s?,arg:F?", @@ -1358,10 +1358,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 =20 STEXI @end table diff --git a/monitor.c b/monitor.c index 2cff62d..df0f622 100644 --- a/monitor.c +++ b/monitor.c @@ -57,8 +57,9 @@ #include "json-parser.h" #include "osdep.h" #include "cpu.h" +#include "trace/control.h" #ifdef CONFIG_TRACE_SIMPLE -#include "trace.h" +#include "trace/simple.h" #endif #include "trace/control.h" #include "ui/qemu-spice.h" @@ -593,7 +594,6 @@ static void do_help_cmd(Monitor *mon, const QDict *qd= ict) help_cmd(mon, qdict_get_try_str(qdict, "name")); } =20 -#ifdef CONFIG_TRACE_SIMPLE static void do_trace_event_set_state(Monitor *mon, const QDict *qdict) { const char *tp_name =3D qdict_get_str(qdict, "name"); @@ -605,6 +605,7 @@ static void do_trace_event_set_state(Monitor *mon, co= nst QDict *qdict) } } =20 +#ifdef CONFIG_SIMPLE_TRACE static void do_trace_file(Monitor *mon, const QDict *qdict) { const char *op =3D qdict_get_try_str(qdict, "op"); @@ -1002,12 +1003,12 @@ static void do_info_trace(Monitor *mon) { st_print_trace((FILE *)mon, &monitor_fprintf); } +#endif =20 static void do_trace_print_events(Monitor *mon) { trace_print_events((FILE *)mon, &monitor_fprintf); } -#endif =20 /** * do_quit(): Quit QEMU execution @@ -3144,6 +3145,7 @@ static const mon_cmd_t info_cmds[] =3D { .help =3D "show current contents of trace buffer", .mhandler.info =3D do_info_trace, }, +#endif { .name =3D "trace-events", .args_type =3D "", @@ -3151,7 +3153,6 @@ static const mon_cmd_t info_cmds[] =3D { .help =3D "show available trace-events & their state", .mhandler.info =3D do_trace_print_events, }, -#endif { .name =3D NULL, }, --=20 1.7.5.4