intel/compiler: Get rid of the global compaction table pointers
[mesa.git] / src / intel / tools / intel_dump_gpu.in
index b9887f0ed2ef287f094cff1f832931c4fdbd2456..f486f34d3880a694cd04b87eb127917875647f3d 100755 (executable)
@@ -8,51 +8,45 @@ Usage: intel_dump_gpu [OPTION]... [--] COMMAND ARGUMENTS
 Run COMMAND with ARGUMENTS and dump an AUB file that captures buffer
 contents and execution of the GEM application.
 
 Run COMMAND with ARGUMENTS and dump an AUB file that captures buffer
 contents and execution of the GEM application.
 
-  -o, --output=FILE  Name of AUB file. Defaults to COMMAND.aub
+  -g, --gdb           Launch GDB
 
 
-  -c, --command=CMD  Execute CMD and write the AUB file's content to its
-                     standard input
+  -o, --output=FILE   Name of AUB file. Defaults to COMMAND.aub
 
 
-      --device=ID    Override PCI ID of the reported device
+      --device=ID     Override PCI ID of the reported device
 
 
-  -v                 Enable verbose output
+  -p, --platform=NAME Override PCI ID using a platform name
 
 
-  -vv                Enable extra verbosity - dumps gtt mappings
+  -c, --only-capture  Only write objects flagged with EXEC_OBJECT_CAPTURE into
+                      the output aub file. This helps reducing output file
+                      size greatly but won't produce a file replayable
 
 
-      --help         Display this help message and exit
+  -f, --frame=ID      Only dump objects for frame ID
+
+  -v                  Enable verbose output
+
+  -vv                 Enable extra verbosity - dumps gtt mappings
+
+      --help          Display this help message and exit
 
 EOF
 
     exit 0
 }
 
 
 EOF
 
     exit 0
 }
 
+ld_preload="@install_libexecdir@/libintel_dump_gpu.so${LD_PRELOAD:+:$LD_PRELOAD}"
 args=""
 args=""
-command=""
 file=""
 file=""
+gdb=""
+capture_only=""
+frame=""
 
 function add_arg() {
     arg=$1
     args="$args$arg\n"
 }
 
 
 function add_arg() {
     arg=$1
     args="$args$arg\n"
 }
 
-function build_command () {
-    command=""
-    for i in $1; do
-        if [ -z $command ]; then
-            command=$i
-        else
-            command="$command,$i"
-        fi;
-    done
-}
-
 while true; do
     case "$1" in
 while true; do
     case "$1" in
-        -o)
-            file=$2
-            add_arg "file=${file:-$(basename ${file}).aub}"
-            shift 2
-            ;;
         -v)
             add_arg "verbose=1"
             shift 1
         -v)
             add_arg "verbose=1"
             shift 1
@@ -61,6 +55,11 @@ while true; do
             add_arg "verbose=2"
             shift 1
             ;;
             add_arg "verbose=2"
             shift 1
             ;;
+        -o)
+            file=$2
+            add_arg "file=${file:-$(basename ${file}).aub}"
+            shift 2
+            ;;
         -o*)
             file=${1##-o}
             add_arg "file=${file:-$(basename ${file}).aub}"
         -o*)
             file=${1##-o}
             add_arg "file=${file:-$(basename ${file}).aub}"
@@ -71,18 +70,54 @@ while true; do
             add_arg "file=${file:-$(basename ${file}).aub}"
             shift
             ;;
             add_arg "file=${file:-$(basename ${file}).aub}"
             shift
             ;;
-        -c)
-            build_command "$2"
-            add_arg "command=$command"
+        --device=*)
+            add_arg "device=${1##--device=}"
+            shift
+            ;;
+        -p)
+            platform=$2
+            add_arg "platform=${platform}"
             shift 2
             ;;
             shift 2
             ;;
-        --command=*)
-            build_command "${1##--command=}"
-            add_arg "command=$command"
+        -p*)
+            platform=${1##-p}
+            add_arg "platform=${platform}"
             shift
             ;;
             shift
             ;;
-        --device=*)
-            add_arg "device=${1##--device=}"
+        --platform=*)
+            platform=${1##--platform=}
+            add_arg "platform=${platform}"
+            shift
+            ;;
+        -f)
+            frame=$2
+            add_arg "frame=${frame}"
+            shift 2
+            ;;
+        -f*)
+            frame=${1##-f}
+            add_arg "frame=${frame}"
+            shift
+            ;;
+        --frame=*)
+            frame=${1##--frame=}
+            add_arg "frame=${frame}"
+            shift
+            ;;
+        --gdb)
+            gdb=1
+            shift
+            ;;
+        -g)
+            gdb=1
+            shift
+            ;;
+        -c)
+            add_arg "capture_only=1"
+            shift
+            ;;
+        --only-capture)
+            add_arg "capture_only=1"
             shift
             ;;
         --help)
             shift
             ;;
         --help)
@@ -105,9 +140,17 @@ done
 
 [ -z $1 ] && show_help
 
 
 [ -z $1 ] && show_help
 
-[ -z $file ] && [ -z $command ] && add_arg "file=intel.aub"
+[ -z $file ] && add_arg "file=intel.aub"
 
 
-LD_PRELOAD="@install_libexecdir@/libintel_dump_gpu.so${LD_PPRELOAD:+:$LD_PRELOAD}" \
-          exec -- "$@" 3<<EOF
-`echo -e $args`
-EOF
+tmp_file=`mktemp`
+echo -e $args > $tmp_file
+
+if [ -z $gdb ]; then
+    LD_PRELOAD="$ld_preload" INTEL_DUMP_GPU_CONFIG=$tmp_file "$@"
+else
+    gdb -iex "set exec-wrapper env LD_PRELOAD=$ld_preload INTEL_DUMP_GPU_CONFIG=$tmp_file" --args "$@"
+fi
+
+ret=$?
+rm $tmp_file
+exit $ret