1#!/bin/bash 2# -*- mode: sh -*- 3 4function show_help() { 5 cat <<EOF 6Usage: intel_dump_gpu [OPTION]... [--] COMMAND ARGUMENTS 7 8Run COMMAND with ARGUMENTS and dump an AUB file that captures buffer 9contents and execution of the GEM application. 10 11 -g, --gdb Launch GDB 12 13 -o, --output=FILE Name of AUB file. Defaults to COMMAND.aub 14 15 --device=ID Override PCI ID of the reported device 16 17 -p, --platform=NAME Override PCI ID using a platform name 18 19 -c, --only-capture Only write objects flagged with EXEC_OBJECT_CAPTURE into 20 the output aub file. This helps reducing output file 21 size greatly but won't produce a file replayable 22 23 -f, --frame=ID Only dump objects for frame ID 24 25 -v Enable verbose output 26 27 -vv Enable extra verbosity - dumps gtt mappings 28 29 --help Display this help message and exit 30 31EOF 32 33 exit 0 34} 35 36ld_preload="@install_libexecdir@/libintel_dump_gpu.so${LD_PRELOAD:+:$LD_PRELOAD}" 37args="" 38file="" 39gdb="" 40capture_only="" 41frame="" 42 43function add_arg() { 44 arg=$1 45 args="$args$arg\n" 46} 47 48while true; do 49 case "$1" in 50 -v) 51 add_arg "verbose=1" 52 shift 1 53 ;; 54 -vv) 55 add_arg "verbose=2" 56 shift 1 57 ;; 58 -o) 59 file=$2 60 add_arg "file=${file:-$(basename ${file}).aub}" 61 shift 2 62 ;; 63 -o*) 64 file=${1##-o} 65 add_arg "file=${file:-$(basename ${file}).aub}" 66 shift 67 ;; 68 --output=*) 69 file=${1##--output=} 70 add_arg "file=${file:-$(basename ${file}).aub}" 71 shift 72 ;; 73 --device=*) 74 add_arg "device=${1##--device=}" 75 shift 76 ;; 77 -p) 78 platform=$2 79 add_arg "platform=${platform}" 80 shift 2 81 ;; 82 -p*) 83 platform=${1##-p} 84 add_arg "platform=${platform}" 85 shift 86 ;; 87 --platform=*) 88 platform=${1##--platform=} 89 add_arg "platform=${platform}" 90 shift 91 ;; 92 -f) 93 frame=$2 94 add_arg "frame=${frame}" 95 shift 2 96 ;; 97 -f*) 98 frame=${1##-f} 99 add_arg "frame=${frame}" 100 shift 101 ;; 102 --frame=*) 103 frame=${1##--frame=} 104 add_arg "frame=${frame}" 105 shift 106 ;; 107 --gdb) 108 gdb=1 109 shift 110 ;; 111 -g) 112 gdb=1 113 shift 114 ;; 115 -c) 116 add_arg "capture_only=1" 117 shift 118 ;; 119 --only-capture) 120 add_arg "capture_only=1" 121 shift 122 ;; 123 --help) 124 show_help 125 ;; 126 --) 127 shift 128 break 129 ;; 130 -*) 131 echo "intel_aubdump: invalid option: $1" 132 echo 133 show_help 134 ;; 135 *) 136 break 137 ;; 138 esac 139done 140 141[ -z $1 ] && show_help 142 143[ -z $file ] && add_arg "file=intel.aub" 144 145tmp_file=`mktemp` 146echo -e $args > $tmp_file 147 148if [ -z $gdb ]; then 149 LD_PRELOAD="$ld_preload" INTEL_DUMP_GPU_CONFIG=$tmp_file "$@" 150else 151 gdb -iex "set exec-wrapper env LD_PRELOAD=$ld_preload INTEL_DUMP_GPU_CONFIG=$tmp_file" --args "$@" 152fi 153 154ret=$? 155rm $tmp_file 156exit $ret 157