aboutsummaryrefslogtreecommitdiff
path: root/tracetool
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2010-11-08 19:33:08 +0000
committerAnthony Liguori <aliguori@us.ibm.com>2010-11-16 09:31:18 -0600
commit2834c3e0140c3b0ed4422909dfa0607b7213d95d (patch)
tree0fad835a8f7c742b07710793915c9dd2fcb92e82 /tracetool
parent4addb1127f6327c7ebcbd150a6b589e7677adc92 (diff)
Add support for generating a systemtap tapset static probes
This introduces generation of a qemu.stp/qemu-system-XXX.stp files which provides tapsets with friendly names for static probes & their arguments. Instead of probe process("qemu").mark("qemu_malloc") { printf("Malloc %d %p\n", $arg1, $arg2); } It is now possible todo probe qemu.system.i386.qemu_malloc { printf("Malloc %d %p\n", size, ptr); } There is one tapset defined per target arch. * Makefile: Generate a qemu.stp file for systemtap * tracetool: Support for generating systemtap tapsets Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'tracetool')
-rwxr-xr-xtracetool92
1 files changed, 92 insertions, 0 deletions
diff --git a/tracetool b/tracetool
index 5b6636ac27..d797ab79a3 100755
--- a/tracetool
+++ b/tracetool
@@ -26,6 +26,12 @@ Output formats:
-h Generate .h file
-c Generate .c file
-d Generate .d file (DTrace only)
+ -s Generate .stp file (DTrace with SystemTAP only)
+
+Options:
+ --bindir [bindir] QEMU binary install location
+ --target [arch] QEMU target architecture
+
EOF
exit 1
}
@@ -390,6 +396,54 @@ linetod_end_dtrace()
EOF
}
+linetos_begin_dtrace()
+{
+ return
+}
+
+linetos_dtrace()
+{
+ local name args arglist state
+ name=$(get_name "$1")
+ args=$(get_args "$1")
+ arglist=$(get_argnames "$1", "")
+ state=$(get_state "$1")
+ if [ "$state" = "0" ] ; then
+ name=${name##disable }
+ fi
+
+ if [ "$target" = "i386" ]
+ then
+ binary="qemu"
+ else
+ binary="qemu-system-$target"
+ fi
+
+ # Define prototype for probe arguments
+ cat <<EOF
+probe qemu.system.$target.$name = process("$bindir/$binary").mark("$name")
+{
+EOF
+
+ i=1
+ for arg in $arglist
+ do
+ cat <<EOF
+ $arg = \$arg$i;
+EOF
+ i="$((i+1))"
+ done
+
+ cat <<EOF
+}
+EOF
+}
+
+linetos_end_dtrace()
+{
+ return
+}
+
# Process stdin by calling begin, line, and end functions for the backend
convert()
{
@@ -455,6 +509,24 @@ tracetod()
convert d
}
+tracetos()
+{
+ if [ $backend != "dtrace" ]; then
+ echo "SystemTAP tapset generator not applicable to $backend backend"
+ exit 1
+ fi
+ if [ -z "$target" ]; then
+ echo "--target is required for SystemTAP tapset generator"
+ exit 1
+ fi
+ if [ -z "$bindir" ]; then
+ echo "--bindir is required for SystemTAP tapset generator"
+ exit 1
+ fi
+ echo "/* This file is autogenerated by tracetool, do not edit. */"
+ convert s
+}
+
# Choose backend
case "$1" in
"--nop" | "--simple" | "--ust" | "--dtrace") backend="${1#--}" ;;
@@ -462,10 +534,30 @@ case "$1" in
esac
shift
+bindir=
+case "$1" in
+ "--bindir")
+ bindir=$2
+ shift
+ shift
+ ;;
+esac
+
+target=
+case "$1" in
+ "--target")
+ target=$2
+ shift
+ shift
+ ;;
+esac
+
+
case "$1" in
"-h") tracetoh ;;
"-c") tracetoc ;;
"-d") tracetod ;;
+"-s") tracetos ;;
"--check-backend") exit 0 ;; # used by ./configure to test for backend
*) usage ;;
esac