intel_dump_gpu.in revision 01e04c3f
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 -o, --output=FILE Name of AUB file. Defaults to COMMAND.aub 12 13 --device=ID Override PCI ID of the reported device 14 15 -v Enable verbose output 16 17 -vv Enable extra verbosity - dumps gtt mappings 18 19 --help Display this help message and exit 20 21EOF 22 23 exit 0 24} 25 26ld_preload="@install_libexecdir@/libintel_dump_gpu.so${LD_PPRELOAD:+:$LD_PRELOAD}" 27args="" 28file="" 29gdb="" 30 31function add_arg() { 32 arg=$1 33 args="$args$arg\n" 34} 35 36while true; do 37 case "$1" in 38 -o) 39 file=$2 40 add_arg "file=${file:-$(basename ${file}).aub}" 41 shift 2 42 ;; 43 -v) 44 add_arg "verbose=1" 45 shift 1 46 ;; 47 -vv) 48 add_arg "verbose=2" 49 shift 1 50 ;; 51 -o*) 52 file=${1##-o} 53 add_arg "file=${file:-$(basename ${file}).aub}" 54 shift 55 ;; 56 --output=*) 57 file=${1##--output=} 58 add_arg "file=${file:-$(basename ${file}).aub}" 59 shift 60 ;; 61 --device=*) 62 add_arg "device=${1##--device=}" 63 shift 64 ;; 65 --gdb) 66 gdb=1 67 shift 68 ;; 69 -g) 70 gdb=1 71 shift 72 ;; 73 --help) 74 show_help 75 ;; 76 --) 77 shift 78 break 79 ;; 80 -*) 81 echo "intel_aubdump: invalid option: $1" 82 echo 83 show_help 84 ;; 85 *) 86 break 87 ;; 88 esac 89done 90 91[ -z $1 ] && show_help 92 93[ -z $file ] && add_arg "file=intel.aub" 94 95tmp_file=`mktemp` 96echo -e $args > $tmp_file 97 98if [ -z $gdb ]; then 99 LD_PRELOAD="$ld_preload" INTEL_DUMP_GPU_CONFIG=$tmp_file $@ 100else 101 gdb -iex "set exec-wrapper env LD_PRELOAD=$ld_preload INTEL_DUMP_GPU_CONFIG=$tmp_file" --args $@ 102fi 103 104ret=$? 105rm $tmp_file 106exit $ret 107