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 <wu...@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