From: Mark Wu <wudxw@linux.vnet.ibm.com>
To: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Cc: Mark Wu <wudxw@linux.vnet.ibm.com>, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 2/6] trace: Add HMP monitor commands for trace events group
Date: Thu, 13 Oct 2011 01:14:15 +0800 [thread overview]
Message-ID: <1318439659-7525-3-git-send-email-wudxw@linux.vnet.ibm.com> (raw)
In-Reply-To: <1318439659-7525-1-git-send-email-wudxw@linux.vnet.ibm.com>
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 <wudxw@linux.vnet.ibm.com>
---
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 9e1cca8..b415616 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
+@item trace-group
+@findex trace-group
+changes status of a group of trace events
+ETEXI
+
#if defined(CONFIG_SIMPLE_TRACE)
{
.name = "trace-file",
diff --git a/monitor.c b/monitor.c
index 88d8228..0b8ca09 100644
--- a/monitor.c
+++ b/monitor.c
@@ -605,6 +605,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_SIMPLE_TRACE
static void do_trace_file(Monitor *mon, const QDict *qdict)
{
@@ -1010,6 +1021,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);
+}
/**
* do_quit(): Quit QEMU execution
*/
@@ -3170,6 +3185,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
next prev parent reply other threads:[~2011-10-12 17:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-12 17:14 [Qemu-devel] [PATCH 0/6] trace: Add support for trace events grouping Mark Wu
2011-10-12 17:14 ` [Qemu-devel] [PATCH 1/6] trace: Make "tracetool" generate a group list Mark Wu
2011-10-14 1:48 ` Sheldon
2011-10-12 17:14 ` Mark Wu [this message]
2011-10-12 17:14 ` [Qemu-devel] [PATCH 3/6] trace: Add trace events group implementation in the backend "simple" Mark Wu
2011-10-12 20:46 ` Ryan Harper
2011-10-12 17:14 ` [Qemu-devel] [PATCH 4/6] trace: Add trace events group implementation in the backend "stderr" Mark Wu
2011-10-12 17:14 ` [Qemu-devel] [PATCH 5/6] trace: Enable "-trace events" argument to control initial state of groups Mark Wu
2011-10-12 17:14 ` [Qemu-devel] [PATCH 6/6] trace: Update doc for trace events group Mark Wu
2011-10-13 8:10 ` [Qemu-devel] [PATCH 0/6] trace: Add support for trace events grouping Mark Wu
2011-10-14 12:16 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1318439659-7525-3-git-send-email-wudxw@linux.vnet.ibm.com \
--to=wudxw@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).