qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2 2/6] trace: Add HMP monitor commands for trace ev


From: Mark Wu
Subject: [Qemu-devel] [PATCH v2 2/6] trace: Add HMP monitor commands for trace events group
Date: Thu, 20 Oct 2011 14:42:20 +0800

Add monitor commands 'trace-group NAME on|off' and 'info trace-groups'
to set and query the state of a given group of trace events.

Signed-off-by: Mark Wu <address@hidden>
---
 hmp-commands.hx |   14 ++++++++++++++
 monitor.c       |   22 ++++++++++++++++++++++
 trace/control.h |    9 +++++++++
 trace/default.c |   15 +++++++++++++++
 4 files changed, 60 insertions(+), 0 deletions(-)

diff --git a/hmp-commands.hx b/hmp-commands.hx
index ab08d58..251b84f 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -194,6 +194,20 @@ STEXI
 changes status of a trace event
 ETEXI
 
+    {
+        .name       = "trace-group",
+        .args_type  = "name:s,option:b",
+        .params     = "name on|off",
+        .help       = "changes status of a specific trace event",
+        .mhandler.cmd = do_trace_event_group_set_state,
+    },
+
+STEXI
address@hidden trace-group
address@hidden trace-group
+changes status of a group of trace events
+ETEXI
+
 #if defined(CONFIG_TRACE_SIMPLE)
     {
         .name       = "trace-file",
diff --git a/monitor.c b/monitor.c
index ffda0fe..bedb011 100644
--- a/monitor.c
+++ b/monitor.c
@@ -617,6 +617,17 @@ static void do_trace_event_set_state(Monitor *mon, const 
QDict *qdict)
     }
 }
 
+static void do_trace_event_group_set_state(Monitor *mon, const QDict *qdict)
+{
+    const char *gp_name = qdict_get_str(qdict, "name");
+    bool new_state = qdict_get_bool(qdict, "option");
+    int ret = trace_event_group_set_state(gp_name, new_state);
+
+    if (!ret) {
+        monitor_printf(mon, "unknown group name \"%s\"\n", gp_name);
+    }
+}
+
 #ifdef CONFIG_TRACE_SIMPLE
 static void do_trace_file(Monitor *mon, const QDict *qdict)
 {
@@ -954,6 +965,10 @@ static void do_trace_print_events(Monitor *mon)
     trace_print_events((FILE *)mon, &monitor_fprintf);
 }
 
+static void do_trace_print_groups(Monitor *mon)
+{
+    trace_print_groups((FILE *)mon, &monitor_fprintf);
+}
 #ifdef CONFIG_VNC
 static int change_vnc_password(const char *password)
 {
@@ -3050,6 +3065,13 @@ static const mon_cmd_t info_cmds[] = {
         .mhandler.info = do_trace_print_events,
     },
     {
+        .name       = "trace-groups",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show available trace-groups & their state",
+        .mhandler.info = do_trace_print_groups,
+    },
+    {
         .name       = NULL,
     },
 };
diff --git a/trace/control.h b/trace/control.h
index 2acaa42..97ecce7 100644
--- a/trace/control.h
+++ b/trace/control.h
@@ -15,12 +15,21 @@
 
 /** Print the state of all events. */
 void trace_print_events(FILE *stream, fprintf_function stream_printf);
+
+/** Print the state of all groups. */
+void trace_print_groups(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);
 
+/** Set the state of a group of  events.
+ *
+ * @return Whether the state changed.
+ */
+bool trace_event_group_set_state(const char *name, bool state);
 
 /** Initialize the tracing backend.
  *
diff --git a/trace/default.c b/trace/default.c
index c9b27a2..c7e70c7 100644
--- a/trace/default.c
+++ b/trace/default.c
@@ -18,6 +18,14 @@ void trace_print_events(FILE *stream, fprintf_function 
stream_printf)
                   "operation not supported with the current backend\n");
 }
 
+void trace_print_groups(FILE *stream, fprintf_function stream_printf)
+{
+    fprintf(stderr, "warning: "
+            "cannot print the trace groups 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: "
@@ -25,6 +33,13 @@ bool trace_event_set_state(const char *name, bool state)
     return false;
 }
 
+bool trace_event_group_set_state(const char *gp_name, bool state)
+{
+    fprintf(stderr, "warning: "
+            "cannot set the state of a trace group with the current 
backend\n");
+    return false;
+}
+
 bool trace_backend_init(const char *events, const char *file)
 {
     if (events) {
-- 
1.7.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]