1#!/bin/bash 2# -*- mode: sh -*- 3 4function show_help() { 5 cat <<EOF 6Usage: intel_aubdump [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 -c, --command=CMD Execute CMD and write the AUB file's content to its 14 standard input 15 16 --device=ID Override PCI ID of the reported device 17 18 -v Enable verbose output 19 20 --help Display this help message and exit 21 22EOF 23 24 exit 0 25} 26 27args="" 28command="" 29file="" 30 31function add_arg() { 32 arg=$1 33 args="$args$arg\n" 34} 35 36function build_command () { 37 command="" 38 for i in $1; do 39 if [ -z $command ]; then 40 command=$i 41 else 42 command="$command,$i" 43 fi; 44 done 45} 46 47while true; do 48 case "$1" in 49 -o) 50 file=$2 51 add_arg "file=${file:-$(basename ${file}).aub}" 52 shift 2 53 ;; 54 -v) 55 add_arg "verbose=1" 56 shift 1 57 ;; 58 -o*) 59 file=${1##-o} 60 add_arg "file=${file:-$(basename ${file}).aub}" 61 shift 62 ;; 63 --output=*) 64 file=${1##--output=} 65 add_arg "file=${file:-$(basename ${file}).aub}" 66 shift 67 ;; 68 -c) 69 build_command "$2" 70 add_arg "command=$command" 71 shift 2 72 ;; 73 --command=*) 74 build_command "${1##--command=}" 75 add_arg "command=$command" 76 shift 77 ;; 78 --device=*) 79 add_arg "device=${1##--device=}" 80 shift 81 ;; 82 --help) 83 show_help 84 ;; 85 --) 86 shift 87 break 88 ;; 89 -*) 90 echo "intel_aubdump: invalid option: $1" 91 echo 92 show_help 93 ;; 94 *) 95 break 96 ;; 97 esac 98done 99 100[ -z $1 ] && show_help 101 102[ -z $file ] && [ -z $command ] && add_arg "file=intel.aub" 103 104prefix=@prefix@ 105exec_prefix=@exec_prefix@ 106libdir=@libdir@ 107 108LD_PRELOAD=${libdir}/intel_aubdump.so${LD_PPRELOAD:+:${LD_PRELOAD}} \ 109 exec -- "$@" 3<<EOF 110`echo -e $args` 111EOF 112