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