1bf215546Sopenharmony_ci#!/bin/bash 2bf215546Sopenharmony_ci# -*- mode: sh -*- 3bf215546Sopenharmony_ci 4bf215546Sopenharmony_cifunction show_help() { 5bf215546Sopenharmony_ci cat <<EOF 6bf215546Sopenharmony_ciUsage: intel_sanitize_gpu [OPTION]... [--] COMMAND ARGUMENTS 7bf215546Sopenharmony_ci 8bf215546Sopenharmony_ciRun COMMAND with ARGUMENTS and verify the GPU doesn't write outside its memory 9bf215546Sopenharmony_cimapped buffers. 10bf215546Sopenharmony_ci 11bf215546Sopenharmony_ci -g, --gdb Launch GDB 12bf215546Sopenharmony_ci 13bf215546Sopenharmony_ci --help Display this help message and exit 14bf215546Sopenharmony_ci 15bf215546Sopenharmony_ciEOF 16bf215546Sopenharmony_ci 17bf215546Sopenharmony_ci exit 0 18bf215546Sopenharmony_ci} 19bf215546Sopenharmony_ci 20bf215546Sopenharmony_cigdb="" 21bf215546Sopenharmony_ci 22bf215546Sopenharmony_ciwhile true; do 23bf215546Sopenharmony_ci case "$1" in 24bf215546Sopenharmony_ci --gdb) 25bf215546Sopenharmony_ci gdb=1 26bf215546Sopenharmony_ci shift 27bf215546Sopenharmony_ci ;; 28bf215546Sopenharmony_ci -g) 29bf215546Sopenharmony_ci gdb=1 30bf215546Sopenharmony_ci shift 31bf215546Sopenharmony_ci ;; 32bf215546Sopenharmony_ci --help) 33bf215546Sopenharmony_ci show_help 34bf215546Sopenharmony_ci ;; 35bf215546Sopenharmony_ci --) 36bf215546Sopenharmony_ci shift 37bf215546Sopenharmony_ci break 38bf215546Sopenharmony_ci ;; 39bf215546Sopenharmony_ci -*) 40bf215546Sopenharmony_ci echo "intel_sanitize_gpu: invalid option: $1" 41bf215546Sopenharmony_ci echo 42bf215546Sopenharmony_ci show_help 43bf215546Sopenharmony_ci ;; 44bf215546Sopenharmony_ci *) 45bf215546Sopenharmony_ci break 46bf215546Sopenharmony_ci ;; 47bf215546Sopenharmony_ci esac 48bf215546Sopenharmony_cidone 49bf215546Sopenharmony_ci 50bf215546Sopenharmony_ci[ -z $1 ] && show_help 51bf215546Sopenharmony_ci 52bf215546Sopenharmony_cild_preload="@install_libexecdir@/libintel_sanitize_gpu.so${LD_PRELOAD:+:$LD_PRELOAD}" 53bf215546Sopenharmony_ciif [ -z $gdb ]; then 54bf215546Sopenharmony_ci LD_PRELOAD=$ld_preload exec "$@" 55bf215546Sopenharmony_cielse 56bf215546Sopenharmony_ci gdb -iex "set exec-wrapper env LD_PRELOAD=$ld_preload" --args "$@" 57bf215546Sopenharmony_cifi 58