]> git.proxmox.com Git - qemu.git/blobdiff - tracetool
ide: Set bus master inactive on error
[qemu.git] / tracetool
index d797ab79a3e2aaff77870af017caee35ff9e4353..fce491c505f55562f212ebdb67fcf97a18fd21e6 100755 (executable)
--- a/tracetool
+++ b/tracetool
@@ -23,14 +23,15 @@ Backends:
   --dtrace  DTrace/SystemTAP backend
 
 Output formats:
-  -h    Generate .h file
-  -c    Generate .c file
-  -d    Generate .d file (DTrace only)
-  -s    Generate .stp file (DTrace with SystemTAP only)
+  -h     Generate .h file
+  -c     Generate .c file
+  -d     Generate .d file (DTrace only)
+  --stap Generate .stp file (DTrace with SystemTAP only)
 
 Options:
-  --bindir [bindir]  QEMU binary install location
-  --target [arch]    QEMU target architecture
+  --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
@@ -383,6 +384,12 @@ linetod_dtrace()
         name=${name##disable }
     fi
 
+    # DTrace provider syntax expects foo() for empty
+    # params, not foo(void)
+    if [ "$args" = "void" ]; then
+       args=""
+    fi
+
     # Define prototype for probe arguments
     cat <<EOF
         probe $name($args);
@@ -396,14 +403,14 @@ linetod_end_dtrace()
 EOF
 }
 
-linetos_begin_dtrace()
+linetostap_begin_dtrace()
 {
     return
 }
 
-linetos_dtrace()
+linetostap_dtrace()
 {
-    local name args arglist state
+    local i arg name args arglist state
     name=$(get_name "$1")
     args=$(get_args "$1")
     arglist=$(get_argnames "$1", "")
@@ -412,22 +419,19 @@ linetos_dtrace()
         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")
+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
@@ -439,7 +443,7 @@ EOF
 EOF
 }
 
-linetos_end_dtrace()
+linetostap_end_dtrace()
 {
     return
 }
@@ -509,57 +513,61 @@ tracetod()
     convert d
 }
 
-tracetos()
+tracetostap()
 {
     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"
+    if [ -z "$binary" ]; then
+       echo "--binary is required for SystemTAP tapset generator"
        exit 1
     fi
-    if [ -z "$bindir" ]; then
-       echo "--bindir is required for SystemTAP tapset generator"
+    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 s
-}
-
-# Choose backend
-case "$1" in
-"--nop" | "--simple" | "--ust" | "--dtrace") backend="${1#--}" ;;
-*) usage ;;
-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
+    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