aboutsummaryrefslogtreecommitdiffstats
path: root/src/intel/tools/intel_sanitize_gpu.in
blob: 912387ae6564343f2fe11c5d94277455e78022f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# -*- mode: sh -*-

function show_help() {
    cat <<EOF
Usage: intel_sanitize_gpu [OPTION]... [--] COMMAND ARGUMENTS

Run COMMAND with ARGUMENTS and verify the GPU doesn't write outside its memory
mapped buffers.

  -g, --gdb          Launch GDB

      --help         Display this help message and exit

EOF

    exit 0
}

gdb=""

while true; do
    case "$1" in
        --gdb)
            gdb=1
            shift
            ;;
        -g)
            gdb=1
            shift
            ;;
        --help)
            show_help
            ;;
        --)
            shift
            break
            ;;
        -*)
            echo "intel_sanitize_gpu: invalid option: $1"
            echo
            show_help
            ;;
        *)
            break
            ;;
    esac
done

[ -z $1 ] && show_help

ld_preload="@install_libexecdir@/libintel_sanitize_gpu.so${LD_PRELOAD:+:$LD_PRELOAD}"
if [ -z $gdb ]; then
    LD_PRELOAD=$ld_preload exec "$@"
else
    gdb -iex "set exec-wrapper env LD_PRELOAD=$ld_preload" --args "$@"
fi