From: Lluís <xscript@gmx.net>
To: qemu-devel@nongnu.org
Cc: stefanha@gmail.com, chouteau@adacore.com
Subject: [Qemu-devel] [PATCH v5 09/10] trace-state: [stderr] add support for dynamically enabling/disabling events
Date: Tue, 28 Jun 2011 18:53:55 +0200 [thread overview]
Message-ID: <20110628165355.23482.32230.stgit@ginnungagap.bsc.es> (raw)
In-Reply-To: <20110628165254.23482.17825.stgit@ginnungagap.bsc.es>
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 <chouteau@adacore.com>
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
configure | 3 +++
docs/tracing.txt | 5 -----
scripts/tracetool | 33 ++++++++++++++++++++++++++++-----
trace/control.c | 4 ++--
trace/stderr.h | 11 +++++++++++
5 files changed, 44 insertions(+), 12 deletions(-)
create mode 100644 trace/stderr.h
diff --git a/configure b/configure
index e41dcca..d3ab039 100755
--- a/configure
+++ b/configure
@@ -2947,6 +2947,9 @@ if test "$trace_backend" = "nop"; then
elif test "$trace_backend" = "simple"; then
echo "CONFIG_SIMPLE_TRACE=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 c443171..9c17497 100644
--- a/docs/tracing.txt
+++ b/docs/tracing.txt
@@ -163,11 +163,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/control.c b/trace/control.c
index 0086f1f..fa72164 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -5,7 +5,7 @@
void trace_print_events(FILE *stream, fprintf_function stream_printf)
{
-#if defined(CONFIG_SIMPLE_TRACE)
+#if defined(CONFIG_SIMPLE_TRACE) || defined(CONFIG_TRACE_STDERR)
unsigned int i;
for (i = 0; i < NR_TRACE_EVENTS; i++) {
@@ -20,7 +20,7 @@ void trace_print_events(FILE *stream, fprintf_function stream_printf)
bool trace_event_set_state (const char *name, bool state)
{
-#if defined(CONFIG_SIMPLE_TRACE)
+#if defined(CONFIG_SIMPLE_TRACE) || defined(CONFIG_TRACE_STDERR)
unsigned int i;
for (i = 0; i < NR_TRACE_EVENTS; i++) {
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 */
next prev parent reply other threads:[~2011-06-28 16:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-28 16:52 [Qemu-devel] [PATCH v5 00/10] trace-state: make the behaviour of "disable" consistent across all backends Lluís
2011-06-28 16:53 ` [Qemu-devel] [PATCH v5 01/10] trace: move backend-specific code into the trace/ directory Lluís
2011-07-15 9:40 ` Stefan Hajnoczi
2011-06-28 16:53 ` [Qemu-devel] [PATCH v5 02/10] trace: avoid conditional code compilation during option parsing Lluís
2011-07-15 9:41 ` Stefan Hajnoczi
2011-06-28 16:53 ` [Qemu-devel] [PATCH v5 03/10] trace: generalize the "property" concept in the trace-events file Lluís
2011-06-28 16:53 ` [Qemu-devel] [PATCH v5 04/10] trace-state: separate trace event control and query routines from the simple backend Lluís
2011-07-15 9:41 ` Stefan Hajnoczi
2011-06-28 16:53 ` [Qemu-devel] [PATCH v5 05/10] trace-state: always compile support for controlling and querying trace event states Lluís
2011-06-28 16:53 ` [Qemu-devel] [PATCH v5 06/10] trace-state: add "-trace events" argument to control initial state Lluís
2011-07-15 9:40 ` Stefan Hajnoczi
2011-06-28 16:53 ` [Qemu-devel] [PATCH v5 07/10] trace-state: always use the "nop" backend on events with the "disable" keyword Lluís
2011-06-28 16:53 ` [Qemu-devel] [PATCH v5 08/10] trace-state: [simple] disable all trace points by default Lluís
2011-06-28 16:53 ` Lluís [this message]
2011-06-28 16:54 ` [Qemu-devel] [PATCH v5 10/10] trace: enable all events Lluís
2011-07-12 18:04 ` [Qemu-devel] [PATCH v5 00/10] trace-state: make the behaviour of "disable" consistent across all backends Stefan Hajnoczi
2011-07-15 9:47 ` Stefan Hajnoczi
2011-07-20 19:19 ` Lluís
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110628165355.23482.32230.stgit@ginnungagap.bsc.es \
--to=xscript@gmx.net \
--cc=chouteau@adacore.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).