From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:54300) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKibF-0002Kv-Bf for qemu-devel@nongnu.org; Sun, 30 Oct 2011 23:31:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RKibD-0000Mj-TB for qemu-devel@nongnu.org; Sun, 30 Oct 2011 23:31:49 -0400 Received: from e28smtp02.in.ibm.com ([122.248.162.2]:37580) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKibD-0000Mb-9k for qemu-devel@nongnu.org; Sun, 30 Oct 2011 23:31:47 -0400 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by e28smtp02.in.ibm.com (8.14.4/8.13.1) with ESMTP id p9V3VhN6014629 for ; Mon, 31 Oct 2011 09:01:43 +0530 Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p9V3VfTM3051590 for ; Mon, 31 Oct 2011 09:01:42 +0530 Received: from d28av03.in.ibm.com (loopback [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p9V3Vet8020644 for ; Mon, 31 Oct 2011 14:31:41 +1100 From: Mark Wu Date: Mon, 31 Oct 2011 11:29:04 +0800 Message-Id: <1320031744-3016-1-git-send-email-wudxw@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v2] trace: Add wildcard trace event support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org A basic wildcard matching is supported in both the monitor command "trace-event" and the events list file. That means you can enable/disable the events having a common prefix in a batch. For example, virtio-blk trace events could be enabled using: trace-event virtio_blk_* on Signed-off-by: Mark Wu --- docs/tracing.txt | 9 ++++++++- net/queue.c | 1 + trace/simple.c | 19 +++++++++++++++++-- trace/stderr.c | 17 ++++++++++++++++- 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/docs/tracing.txt b/docs/tracing.txt index 95ca16c..ea29f2c 100644 --- a/docs/tracing.txt +++ b/docs/tracing.txt @@ -132,12 +132,19 @@ This functionality is also provided through monitor commands: means disabled. * trace-event NAME on|off - Enable/disable a given trace event. + Enable/disable a given trace event or a group of events having common prefix + through wildcard. The "-trace events=" command line argument can be used to enable the events listed in from the very beginning of the program. This file must contain one event name per line. +A basic wildcard matching is supported in both the monitor command "trace +-event" and the events list file. That means you can enable/disable the events +having a common prefix in a batch. For example, virtio-blk trace events could +be enabled using: + trace-event virtio_blk_* on + == Trace backends == The "tracetool" script automates tedious trace event code generation and also diff --git a/net/queue.c b/net/queue.c index 1ab5247..41ffda8 100644 --- a/net/queue.c +++ b/net/queue.c @@ -258,3 +258,4 @@ void qemu_net_queue_flush(NetQueue *queue) g_free(packet); } } +/* */ diff --git a/trace/simple.c b/trace/simple.c index b639dda..6339152 100644 --- a/trace/simple.c +++ b/trace/simple.c @@ -324,14 +324,29 @@ void trace_print_events(FILE *stream, fprintf_function stream_printf) bool trace_event_set_state(const char *name, bool state) { unsigned int i; - + unsigned int len; + bool wildcard = false; + bool matched = false; + + len = strlen(name); + if (len > 0 && name[len - 1] == '*') { + wildcard = true; + len -= 1; + } for (i = 0; i < NR_TRACE_EVENTS; i++) { + if (wildcard) { + if (!strncmp(trace_list[i].tp_name, name, len)) { + trace_list[i].state = state; + matched = true; + } + continue; + } if (!strcmp(trace_list[i].tp_name, name)) { trace_list[i].state = state; return true; } } - return false; + return matched; } /* Helper function to create a thread with signals blocked. Use glib's diff --git a/trace/stderr.c b/trace/stderr.c index 7107c4a..0810d6f 100644 --- a/trace/stderr.c +++ b/trace/stderr.c @@ -15,14 +15,29 @@ void trace_print_events(FILE *stream, fprintf_function stream_printf) bool trace_event_set_state(const char *name, bool state) { unsigned int i; + unsigned int len; + bool wildcard = false; + bool matched = false; + len = strlen(name); + if (len > 0 && name[len - 1] == '*') { + wildcard = true; + len -= 1; + } for (i = 0; i < NR_TRACE_EVENTS; i++) { + if (wildcard) { + if (!strncmp(trace_list[i].tp_name, name, len)) { + trace_list[i].state = state; + matched = true; + } + continue; + } if (!strcmp(trace_list[i].tp_name, name)) { trace_list[i].state = state; return true; } } - return false; + return matched; } bool trace_backend_init(const char *events, const char *file) -- 1.7.1