From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56905) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZQCDF-0002Uv-E5 for qemu-devel@nongnu.org; Fri, 14 Aug 2015 06:27:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZQCDC-0006JD-6I for qemu-devel@nongnu.org; Fri, 14 Aug 2015 06:27:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47253) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZQCDC-0006Is-0g for qemu-devel@nongnu.org; Fri, 14 Aug 2015 06:27:46 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 675C840C22 for ; Fri, 14 Aug 2015 10:27:45 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" Date: Fri, 14 Aug 2015 11:27:43 +0100 Message-Id: <1439548063-18410-1-git-send-email-dgilbert@redhat.com> Subject: [Qemu-devel] [PATCH] trace-events: Add hmp completion List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, lcapitulino@redhat.com From: "Dr. David Alan Gilbert" Add completion for the trace event names in the hmp trace-event command. Signed-off-by: Dr. David Alan Gilbert --- hmp-commands.hx | 1 + hmp.h | 1 + monitor.c | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index d3b7932..94d2c39 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -271,6 +271,7 @@ ETEXI .params = "name on|off", .help = "changes status of a specific trace event", .mhandler.cmd = hmp_trace_event, + .command_completion = trace_event_completion, }, STEXI diff --git a/hmp.h b/hmp.h index 0cf4f2a..b8f5d33 100644 --- a/hmp.h +++ b/hmp.h @@ -113,6 +113,7 @@ void set_link_completion(ReadLineState *rs, int nb_args, const char *str); void netdev_add_completion(ReadLineState *rs, int nb_args, const char *str); void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str); void ringbuf_write_completion(ReadLineState *rs, int nb_args, const char *str); +void trace_event_completion(ReadLineState *rs, int nb_args, const char *str); void watchdog_action_completion(ReadLineState *rs, int nb_args, const char *str); void migrate_set_capability_completion(ReadLineState *rs, int nb_args, diff --git a/monitor.c b/monitor.c index aeea2b5..2e6abac 100644 --- a/monitor.c +++ b/monitor.c @@ -4429,6 +4429,26 @@ void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str) } } +void trace_event_completion(ReadLineState *rs, int nb_args, const char *str) +{ + size_t len; + + len = strlen(str); + readline_set_completion_index(rs, len); + if (nb_args == 2) { + TraceEventID id; + for (id = 0; id < trace_event_count(); id++) { + const char *event_name = trace_event_get_name(trace_event_id(id)); + if (!strncmp(str, event_name, len)) { + readline_add_completion(rs, event_name); + } + } + } else if (nb_args == 3) { + add_completion_option(rs, str, "on"); + add_completion_option(rs, str, "off"); + } +} + void watchdog_action_completion(ReadLineState *rs, int nb_args, const char *str) { int i; -- 2.4.3