[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v6 13/14] trace-state: [stderr] add support for dyna
From: |
Lluís |
Subject: |
[Qemu-devel] [PATCH v6 13/14] trace-state: [stderr] add support for dynamically enabling/disabling events |
Date: |
Thu, 25 Aug 2011 17:52:57 +0200 |
User-agent: |
StGit/0.15 |
Uses the generic interface provided in "trace/control.h" in order to provide
a programmatic interface as well as command line and monitor controls.
Signed-off-by: Fabien Chouteau <address@hidden>
Signed-off-by: Lluís Vilanova <address@hidden>
---
Makefile.objs | 2 ++
configure | 3 +++
docs/tracing.txt | 5 -----
scripts/tracetool | 33 ++++++++++++++++++++++++++++-----
trace/stderr.c | 30 ++++++++++++++++++++++++++++++
trace/stderr.h | 11 +++++++++++
6 files changed, 74 insertions(+), 10 deletions(-)
create mode 100644 trace/stderr.c
create mode 100644 trace/stderr.h
diff --git a/Makefile.objs b/Makefile.objs
index 8950086..076974c 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -383,6 +383,8 @@ trace-obj-y += trace/control.o
trace-nested-$(CONFIG_TRACE_SIMPLE) += simple.o
trace-obj-$(CONFIG_TRACE_SIMPLE) += qemu-timer-common.o
+trace-nested-$(CONFIG_TRACE_STDERR) += stderr.o
+
trace-nested-y += control.o
trace-obj-y += $(addprefix trace/, $(trace-nested-y))
diff --git a/configure b/configure
index 373d007..8ccd5f4 100755
--- a/configure
+++ b/configure
@@ -3068,6 +3068,9 @@ echo "TRACE_BACKEND=$trace_backend" >> $config_host_mak
if test "$trace_backend" = "simple"; then
echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
fi
+if test "$trace_backend" = "stderr"; then
+ echo "CONFIG_TRACE_STDERR=y" >> $config_host_mak
+fi
# Set the appropriate trace file.
if test "$trace_backend" = "simple"; then
trace_file="\"$trace_file-\" FMT_pid"
diff --git a/docs/tracing.txt b/docs/tracing.txt
index 448fdef..f14dbe3 100644
--- a/docs/tracing.txt
+++ b/docs/tracing.txt
@@ -164,11 +164,6 @@ effectively turns trace events into debug printfs.
This is the simplest backend and can be used together with existing code that
uses DPRINTF().
-Note that with this backend trace events cannot be programmatically
-enabled/disabled. Thus, in order to trim down the amount of output and the
-performance impact of tracing, you might want to add the "disable" property in
-the "trace-events" file for those events you are not interested in.
-
=== Simpletrace ===
The "simple" backend supports common use cases and comes as part of the QEMU
diff --git a/scripts/tracetool b/scripts/tracetool
index c740080..743d246 100755
--- a/scripts/tracetool
+++ b/scripts/tracetool
@@ -241,7 +241,12 @@ linetoh_begin_stderr()
{
cat <<EOF
#include <stdio.h>
+#include "trace/stderr.h"
+
+extern TraceEvent trace_list[];
EOF
+
+ stderr_event_num=0
}
linetoh_stderr()
@@ -260,29 +265,47 @@ linetoh_stderr()
cat <<EOF
static inline void trace_$name($args)
{
- fprintf(stderr, "$name $fmt\n" $argnames);
+ if (trace_list[$stderr_event_num].state != 0) {
+ fprintf(stderr, "$name $fmt\n" $argnames);
+ }
}
EOF
+ stderr_event_num=$((stderr_event_num + 1))
+
}
linetoh_end_stderr()
{
-return
+ cat <<EOF
+#define NR_TRACE_EVENTS $stderr_event_num
+EOF
}
linetoc_begin_stderr()
{
-return
+ cat <<EOF
+#include "trace.h"
+
+TraceEvent trace_list[] = {
+EOF
+ stderr_event_num=0
}
linetoc_stderr()
{
-return
+ local name
+ name=$(get_name "$1")
+ cat <<EOF
+{.tp_name = "$name", .state=0},
+EOF
+ stderr_event_num=$(($stderr_event_num + 1))
}
linetoc_end_stderr()
{
-return
+ cat <<EOF
+};
+EOF
}
#END OF STDERR
diff --git a/trace/stderr.c b/trace/stderr.c
new file mode 100644
index 0000000..a8a9f67
--- /dev/null
+++ b/trace/stderr.c
@@ -0,0 +1,30 @@
+#include "trace.h"
+#include "trace/control.h"
+
+void trace_print_events (FILE *stream, fprintf_function stream_printf)
+{
+ unsigned int i;
+
+ for (i = 0; i < NR_TRACE_EVENTS; i++) {
+ stream_printf(stream, "%s [Event ID %u] : state %u\n",
+ trace_list[i].tp_name, i, trace_list[i].state);
+ }
+}
+
+bool trace_event_set_state (const char *name, bool state)
+{
+ unsigned int i;
+
+ for (i = 0; i < NR_TRACE_EVENTS; i++) {
+ if (!strcmp(trace_list[i].tp_name, name)) {
+ trace_list[i].state = state;
+ return true;
+ }
+ }
+ return false;
+}
+
+bool trace_config_init (void)
+{
+ return true;
+}
diff --git a/trace/stderr.h b/trace/stderr.h
new file mode 100644
index 0000000..d575b61
--- /dev/null
+++ b/trace/stderr.h
@@ -0,0 +1,11 @@
+#ifndef TRACE_STDERR_H
+#define TRACE_STDERR_H
+
+typedef uint64_t TraceEventID;
+
+typedef struct {
+ const char *tp_name;
+ bool state;
+} TraceEvent;
+
+#endif /* ! TRACE_STDERR_H */
- Re: [Qemu-devel] [PATCH v6 02/14] provide support for default implementations using weak symbols, (continued)
- [Qemu-devel] [PATCH v6 03/14] trace: [configure] rename CONFIG_*_TRACE into CONFIG_TRACE_*, Lluís, 2011/08/25
- [Qemu-devel] [PATCH v6 04/14] trace: [make] replace 'ifeq' with values in CONFIG_TRACE_*, Lluís, 2011/08/25
- [Qemu-devel] [PATCH v6 05/14] trace: move backend-specific code into the trace/ directory, Lluís, 2011/08/25
- [Qemu-devel] [PATCH v6 06/14] trace: avoid conditional code compilation during option parsing, Lluís, 2011/08/25
- [Qemu-devel] [PATCH v6 07/14] trace: generalize the "property" concept in the trace-events file, Lluís, 2011/08/25
- [Qemu-devel] [PATCH v6 08/14] trace-state: separate trace event control and query routines from the simple backend, Lluís, 2011/08/25
- [Qemu-devel] [PATCH v6 10/14] trace-state: add "-trace events" argument to control initial state, Lluís, 2011/08/25
- [Qemu-devel] [PATCH v6 09/14] trace-state: always compile support for controlling and querying trace event states, Lluís, 2011/08/25
- [Qemu-devel] [PATCH v6 11/14] trace-state: always use the "nop" backend on events with the "disable" keyword, Lluís, 2011/08/25
- [Qemu-devel] [PATCH v6 13/14] trace-state: [stderr] add support for dynamically enabling/disabling events,
Lluís <=
- [Qemu-devel] [PATCH v6 12/14] trace-state: [simple] disable all trace points by default, Lluís, 2011/08/25
- [Qemu-devel] [PATCH v6 14/14] trace: enable all events, Lluís, 2011/08/25