From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:56713) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RE2OO-0005Mx-Ke for qemu-devel@nongnu.org; Wed, 12 Oct 2011 13:14:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RE2OM-0003CT-Qd for qemu-devel@nongnu.org; Wed, 12 Oct 2011 13:14:56 -0400 Received: from e23smtp04.au.ibm.com ([202.81.31.146]:51336) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RE2OM-0003C8-5L for qemu-devel@nongnu.org; Wed, 12 Oct 2011 13:14:54 -0400 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [202.81.31.246]) by e23smtp04.au.ibm.com (8.14.4/8.13.1) with ESMTP id p9CH861m008175 for ; Thu, 13 Oct 2011 04:08:06 +1100 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p9CHCUiY2416780 for ; Thu, 13 Oct 2011 04:12:30 +1100 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p9CHEqb9030807 for ; Thu, 13 Oct 2011 04:14:52 +1100 From: Mark Wu Date: Thu, 13 Oct 2011 01:14:15 +0800 Message-Id: <1318439659-7525-3-git-send-email-wudxw@linux.vnet.ibm.com> In-Reply-To: <1318439659-7525-1-git-send-email-wudxw@linux.vnet.ibm.com> References: <1318439659-7525-1-git-send-email-wudxw@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 2/6] trace: Add HMP monitor commands for trace events group List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Mark Wu , qemu-devel@nongnu.org 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 --- 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