From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: Blue Swirl <blauwirbel@gmail.com>,
William Cohen <wcohen@redhat.com>,
Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH 2/4] trace: allow PRI*64 at beginning and ending of format string
Date: Tue, 13 Sep 2011 13:34:35 +0100 [thread overview]
Message-ID: <1315917277-20670-3-git-send-email-stefanha@linux.vnet.ibm.com> (raw)
In-Reply-To: <1315917277-20670-1-git-send-email-stefanha@linux.vnet.ibm.com>
The tracetool parser only picks up PRI*64 and other format string macros
when enclosed between double quoted strings. Lift this restriction by
extracting everything after the closing ')' as the format string:
cpu_set_apic_base(uint64_t val) "%016"PRIx64
^^ ^^
One trick here: it turns out that backslashes in the format string like
"\n" were being interpreted by echo(1). Fix this by using the POSIX
printf(1) command instead. Although it normally does not make sense to
include backslashes in trace event format strings, an injected newline
causes tracetool to emit a broken header file and I want to eliminate
cases where broken output is emitted, even if the input was bad.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
docs/tracing.txt | 5 +----
scripts/tracetool | 20 +++++++++++++-------
2 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/docs/tracing.txt b/docs/tracing.txt
index e130a61..2c33a62 100644
--- a/docs/tracing.txt
+++ b/docs/tracing.txt
@@ -75,10 +75,7 @@ Trace events should use types as follows:
Format strings should reflect the types defined in the trace event. Take
special care to use PRId64 and PRIu64 for int64_t and uint64_t types,
-respectively. This ensures portability between 32- and 64-bit platforms. Note
-that format strings must begin and end with double quotes. When using
-portability macros, ensure they are preceded and followed by double quotes:
-"value %"PRIx64"".
+respectively. This ensures portability between 32- and 64-bit platforms.
=== Hints for adding new trace events ===
diff --git a/scripts/tracetool b/scripts/tracetool
index 743d246..4c9951d 100755
--- a/scripts/tracetool
+++ b/scripts/tracetool
@@ -40,6 +40,15 @@ EOF
exit 1
}
+# Print a line without interpreting backslash escapes
+#
+# The built-in echo command may interpret backslash escapes without an option
+# to disable this behavior.
+puts()
+{
+ printf "%s\n" "$1"
+}
+
# Get the name of a trace event
get_name()
{
@@ -111,13 +120,10 @@ get_argc()
echo $argc
}
-# Get the format string for a trace event
+# Get the format string including double quotes for a trace event
get_fmt()
{
- local fmt
- fmt=${1#*\"}
- fmt=${fmt%\"*}
- echo "$fmt"
+ puts "${1#*)}"
}
linetoh_begin_nop()
@@ -266,7 +272,7 @@ linetoh_stderr()
static inline void trace_$name($args)
{
if (trace_list[$stderr_event_num].state != 0) {
- fprintf(stderr, "$name $fmt\n" $argnames);
+ fprintf(stderr, "$name " $fmt "\n" $argnames);
}
}
EOF
@@ -366,7 +372,7 @@ DEFINE_TRACE(ust_$name);
static void ust_${name}_probe($args)
{
- trace_mark(ust, $name, "$fmt"$argnames);
+ trace_mark(ust, $name, $fmt$argnames);
}
EOF
--
1.7.5.4
next prev parent reply other threads:[~2011-09-13 12:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-13 12:34 [Qemu-devel] [PATCH 0/4] Remove trailing double quote limitation and add virtio_set_status trace event Stefan Hajnoczi
2011-09-13 12:34 ` [Qemu-devel] [PATCH 1/4] trace: remove newline from grlib_irqmp_check_irqs format string Stefan Hajnoczi
2011-09-13 12:34 ` Stefan Hajnoczi [this message]
2011-09-13 12:34 ` [Qemu-devel] [PATCH 3/4] trace: remove trailing double quotes after PRI*64 Stefan Hajnoczi
2011-09-13 12:34 ` [Qemu-devel] [PATCH 4/4] trace: add virtio_set_status() trace event Stefan Hajnoczi
2011-09-17 18:49 ` [Qemu-devel] [PATCH 0/4] Remove trailing double quote limitation and add virtio_set_status " Blue Swirl
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=1315917277-20670-3-git-send-email-stefanha@linux.vnet.ibm.com \
--to=stefanha@linux.vnet.ibm.com \
--cc=blauwirbel@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=wcohen@redhat.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).