aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2011-11-01 13:08:33 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2011-11-01 13:08:33 -0500
commit0ffcb2ca8d7508f0e60035a17f3a8e055a7a1b89 (patch)
treece10253ecf5635d92f3f71981d2853cadc125513
parent110fc0864d901cf5954a3663389f9598533d1ef5 (diff)
parent454e202d52a517c631cb750ba65ff8079c08b301 (diff)
downloadqemu-0ffcb2ca8d7508f0e60035a17f3a8e055a7a1b89.zip
qemu-0ffcb2ca8d7508f0e60035a17f3a8e055a7a1b89.tar.gz
qemu-0ffcb2ca8d7508f0e60035a17f3a8e055a7a1b89.tar.bz2
Merge remote-tracking branch 'stefanha/tracing' into staging
-rw-r--r--docs/tracing.txt9
-rw-r--r--trace/simple.c19
-rw-r--r--trace/stderr.c17
3 files changed, 41 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=<file>" command line argument can be used to enable the
events listed in <file> 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/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)