[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/6] trace: Add HMP monitor commands for trace event
From: |
Mark Wu |
Subject: |
[Qemu-devel] [PATCH 2/6] trace: Add HMP monitor commands for trace events group |
Date: |
Thu, 13 Oct 2011 01:14:15 +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 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
address@hidden trace-group
address@hidden 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
- [Qemu-devel] [PATCH 0/6] trace: Add support for trace events grouping, Mark Wu, 2011/10/12
- [Qemu-devel] [PATCH 2/6] trace: Add HMP monitor commands for trace events group,
Mark Wu <=
- [Qemu-devel] [PATCH 1/6] trace: Make "tracetool" generate a group list, Mark Wu, 2011/10/12
- [Qemu-devel] [PATCH 3/6] trace: Add trace events group implementation in the backend "simple", Mark Wu, 2011/10/12
- [Qemu-devel] [PATCH 5/6] trace: Enable "-trace events" argument to control initial state of groups, Mark Wu, 2011/10/12
- [Qemu-devel] [PATCH 4/6] trace: Add trace events group implementation in the backend "stderr", Mark Wu, 2011/10/12
- [Qemu-devel] [PATCH 6/6] trace: Update doc for trace events group, Mark Wu, 2011/10/12
- Re: [Qemu-devel] [PATCH 0/6] trace: Add support for trace events grouping, Mark Wu, 2011/10/13