1#!/bin/bash 2# -*- mode: sh -*- 3 4function show_help() { 5 cat <<EOF 6Usage: intel_stub_gpu [OPTION]... [--] COMMAND ARGUMENTS 7 8Run COMMAND with ARGUMENTS faking a particular device. 9 10 -g, --gdb Launch GDB 11 12 -p, --platform=NAME Override PCI ID using a platform name 13 14 --help Display this help message and exit 15 16EOF 17 18 exit 0 19} 20 21gdb="" 22platform="skl" 23 24while true; do 25 case "$1" in 26 --gdb) 27 gdb=1 28 shift 29 ;; 30 -g) 31 gdb=1 32 shift 33 ;; 34 -p) 35 platform=$2 36 shift 2 37 ;; 38 -p*) 39 platform=${1##-p} 40 shift 41 ;; 42 --platform=*) 43 platform=${1##-p} 44 shift 45 ;; 46 --help) 47 show_help 48 ;; 49 --) 50 shift 51 break 52 ;; 53 -*) 54 echo "intel_stub_gpu: invalid option: $1" 55 echo 56 show_help 57 ;; 58 *) 59 break 60 ;; 61 esac 62done 63 64[ -z $1 ] && show_help 65 66INTEL_STUB_GPU_PLATFORM=$platform 67 68ld_preload="@install_libdir@/libintel_noop_drm_shim.so${LD_PRELOAD:+:$LD_PRELOAD}" 69if [ -z $gdb ]; then 70 LD_PRELOAD=$ld_preload INTEL_STUB_GPU_PLATFORM=$platform exec "$@" 71else 72 gdb -iex "set exec-wrapper env LD_PRELOAD=$ld_preload INTEL_STUB_GPU_PLATFORM=$platform" --args "$@" 73fi 74