summaryrefslogtreecommitdiff
path: root/tracetool
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2010-05-22 19:24:51 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2010-09-09 16:22:44 -0500
commit26f7227bfe9a9abee3fe5190cbfc35dd876e06d9 (patch)
tree8faec109ee82f27d466787dbfa9620682fb76d6e /tracetool
parent94a420b170b3e997a185a4148accc87bdcd18156 (diff)
downloadqemu-26f7227bfe9a9abee3fe5190cbfc35dd876e06d9.tar.gz
trace: Add simple built-in tracing backend
This patch adds a simple tracer which produces binary trace files. To try out the simple backend: $ ./configure --trace-backend=simple $ make After running QEMU you can pretty-print the trace: $ ./simpletrace.py trace-events trace.log The output of simpletrace.py looks like this: qemu_realloc 0.699 ptr=0x24363f0 size=0x3 newptr=0x24363f0 qemu_free 0.768 ptr=0x24363f0 ^ ^---- timestamp delta (us) |____ trace event name Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> trace: Make trace record fields 64-bit Explicitly use 64-bit fields in trace records so that timestamps and magic numbers work for 32-bit host builds. Includes fixes from Prerna Saxena <prerna@linux.vnet.ibm.com>. Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Diffstat (limited to 'tracetool')
-rwxr-xr-xtracetool78
1 files changed, 75 insertions, 3 deletions
diff --git a/tracetool b/tracetool
index 01de580c44..19b1659bc0 100755
--- a/tracetool
+++ b/tracetool
@@ -13,11 +13,12 @@ set -f
usage()
{
cat >&2 <<EOF
-usage: $0 --nop [-h | -c]
+usage: $0 [--nop | --simple] [-h | -c]
Generate tracing code for a file on stdin.
Backends:
- --nop Tracing disabled
+ --nop Tracing disabled
+ --simple Simple built-in backend
Output formats:
-h Generate .h file
@@ -66,6 +67,17 @@ get_argnames()
fi
}
+# Get the number of arguments to a trace event
+get_argc()
+{
+ local name argc
+ argc=0
+ for name in $(get_argnames "$1"); do
+ argc=$((argc + 1))
+ done
+ echo $argc
+}
+
# Get the format string for a trace event
get_fmt()
{
@@ -115,6 +127,66 @@ linetoc_end_nop()
return
}
+linetoh_begin_simple()
+{
+ cat <<EOF
+#include "simpletrace.h"
+EOF
+
+ simple_event_num=0
+}
+
+cast_args_to_uint64_t()
+{
+ local arg
+ for arg in $(get_argnames "$1"); do
+ printf "%s" "(uint64_t)(uintptr_t)$arg"
+ done
+}
+
+linetoh_simple()
+{
+ local name args argc trace_args
+ name=$(get_name "$1")
+ args=$(get_args "$1")
+ argc=$(get_argc "$1")
+
+ trace_args="$simple_event_num"
+ if [ "$argc" -gt 0 ]
+ then
+ trace_args="$trace_args, $(cast_args_to_uint64_t "$1")"
+ fi
+
+ cat <<EOF
+static inline void trace_$name($args)
+{
+ trace$argc($trace_args);
+}
+EOF
+
+ simple_event_num=$((simple_event_num + 1))
+}
+
+linetoh_end_simple()
+{
+ return
+}
+
+linetoc_begin_simple()
+{
+ return
+}
+
+linetoc_simple()
+{
+ return
+}
+
+linetoc_end_simple()
+{
+ return
+}
+
# Process stdin by calling begin, line, and end functions for the backend
convert()
{
@@ -160,7 +232,7 @@ tracetoc()
# Choose backend
case "$1" in
-"--nop") backend="${1#--}" ;;
+"--nop" | "--simple") backend="${1#--}" ;;
*) usage ;;
esac
shift