diff options
Diffstat (limited to 'tracetool')
-rwxr-xr-x | tracetool | 128 |
1 files changed, 111 insertions, 17 deletions
@@ -23,9 +23,16 @@ Backends: --dtrace DTrace/SystemTAP backend Output formats: - -h Generate .h file - -c Generate .c file - -d Generate .d file (DTrace only) + -h Generate .h file + -c Generate .c file + -d Generate .d file (DTrace only) + --stap Generate .stp file (DTrace with SystemTAP only) + +Options: + --binary [path] Full path to QEMU binary + --target-arch [arch] QEMU emulator target arch + --target-type [type] QEMU emulator target type ('system' or 'user') + EOF exit 1 } @@ -396,6 +403,51 @@ linetod_end_dtrace() EOF } +linetostap_begin_dtrace() +{ + return +} + +linetostap_dtrace() +{ + local i arg 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 + + # Define prototype for probe arguments + cat <<EOF +probe qemu.$targettype.$targetarch.$name = process("$binary").mark("$name") +{ +EOF + + i=1 + for arg in $arglist + do + # 'limit' is a reserved keyword + if [ "$arg" = "limit" ]; then + arg="_limit" + fi + cat <<EOF + $arg = \$arg$i; +EOF + i="$((i+1))" + done + + cat <<EOF +} +EOF +} + +linetostap_end_dtrace() +{ + return +} + # Process stdin by calling begin, line, and end functions for the backend convert() { @@ -461,19 +513,61 @@ tracetod() convert d } -# Choose backend -case "$1" in -"--nop" | "--simple" | "--ust" | "--dtrace") backend="${1#--}" ;; -*) usage ;; -esac -shift - -case "$1" in -"-h") tracetoh ;; -"-c") tracetoc ;; -"-d") tracetod ;; -"--check-backend") exit 0 ;; # used by ./configure to test for backend -*) usage ;; -esac +tracetostap() +{ + if [ $backend != "dtrace" ]; then + echo "SystemTAP tapset generator not applicable to $backend backend" + exit 1 + fi + if [ -z "$binary" ]; then + echo "--binary is required for SystemTAP tapset generator" + exit 1 + fi + if [ -z "$targettype" ]; then + echo "--target-type is required for SystemTAP tapset generator" + exit 1 + fi + if [ -z "$targetarch" ]; then + echo "--target-arch is required for SystemTAP tapset generator" + exit 1 + fi + echo "/* This file is autogenerated by tracetool, do not edit. */" + convert stap +} + + +backend= +output= +binary= +targettype= +targetarch= + + +until [ -z "$1" ] +do + case "$1" in + "--nop" | "--simple" | "--ust" | "--dtrace") backend="${1#--}" ;; + + "--binary") shift ; binary="$1" ;; + "--target-arch") shift ; targetarch="$1" ;; + "--target-type") shift ; targettype="$1" ;; + + "-h" | "-c" | "-d") output="${1#-}" ;; + "--stap") output="${1#--}" ;; + + "--check-backend") exit 0 ;; # used by ./configure to test for backend + + *) + usage;; + esac + shift +done + +if [ "$backend" = "" -o "$output" = "" ]; then + usage +fi + +gen="traceto$output" +"$gen" exit 0 |