diff mbox

[v7,08/13] trace-state: always compile support for controlling and querying trace event states

Message ID 20110825191824.1413.16777.stgit@ginnungagap.bsc.es
State New
Headers show

Commit Message

=?utf-8?Q?Llu=C3=ADs?= Aug. 25, 2011, 7:18 p.m. UTC
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 <vilanova@ac.upc.edu>
---
 docs/tracing.txt |   39 +++++++++++++++++++++------------------
 hmp-commands.hx  |    7 +++++--
 monitor.c        |    9 +++++----
 3 files changed, 31 insertions(+), 24 deletions(-)

Comments

Stefan Hajnoczi Aug. 31, 2011, 10:10 a.m. UTC | #1
On Thu, Aug 25, 2011 at 09:18:24PM +0200, Lluís wrote:
> 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 <vilanova@ac.upc.edu>
> ---
>  docs/tracing.txt |   39 +++++++++++++++++++++------------------
>  hmp-commands.hx  |    7 +++++--
>  monitor.c        |    9 +++++----
>  3 files changed, 31 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

s/and/an/

> +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 <path>
>    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 */
> -

Please update and move this example to where trace_event_set_state() is
documented.  Having an example makes it clear what this function does.

Stefan
diff mbox

Patch

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 <path>
   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 d77e75f..9e1cca8 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -180,7 +180,6 @@  STEXI
 Output logs to @var{filename}.
 ETEXI
 
-#ifdef CONFIG_TRACE_SIMPLE
     {
         .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?",
@@ -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
 
 STEXI
 @end table
diff --git a/monitor.c b/monitor.c
index 74cb6a2..416533e 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 *qdict)
     help_cmd(mon, qdict_get_try_str(qdict, "name"));
 }
 
-#ifdef CONFIG_TRACE_SIMPLE
 static void do_trace_event_set_state(Monitor *mon, const QDict *qdict)
 {
     const char *tp_name = qdict_get_str(qdict, "name");
@@ -605,6 +605,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 +1003,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
@@ -3144,6 +3145,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  = "",
@@ -3151,7 +3153,6 @@  static const mon_cmd_t info_cmds[] = {
         .help       = "show available trace-events & their state",
         .mhandler.info = do_trace_print_events,
     },
-#endif
     {
         .name       = NULL,
     },