summaryrefslogtreecommitdiffstats
path: root/src/intel/tools/intel_dump_gpu.in
blob: a4ceaba7090dc35f2ab7b31fc3d2aed47ef03879 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/bash
# -*- mode: sh -*-

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

Run COMMAND with ARGUMENTS and dump an AUB file that captures buffer
contents and execution of the GEM application.

  -g, --gdb           Launch GDB

  -o, --output=FILE   Name of AUB file. Defaults to COMMAND.aub

      --device=ID     Override PCI ID of the reported device

  -p, --platform=NAME Override PCI ID using a platform name

  -v                  Enable verbose output

  -vv                 Enable extra verbosity - dumps gtt mappings

      --help          Display this help message and exit

EOF

    exit 0
}

ld_preload="@install_libexecdir@/libintel_dump_gpu.so${LD_PPRELOAD:+:$LD_PRELOAD}"
args=""
file=""
gdb=""

function add_arg() {
    arg=$1
    args="$args$arg\n"
}

while true; do
    case "$1" in
        -v)
            add_arg "verbose=1"
            shift 1
            ;;
        -vv)
            add_arg "verbose=2"
            shift 1
            ;;
        -o)
            file=$2
            add_arg "file=${file:-$(basename ${file}).aub}"
            shift 2
            ;;
        -o*)
            file=${1##-o}
            add_arg "file=${file:-$(basename ${file}).aub}"
            shift
            ;;
        --output=*)
            file=${1##--output=}
            add_arg "file=${file:-$(basename ${file}).aub}"
            shift
            ;;
        --device=*)
            add_arg "device=${1##--device=}"
            shift
            ;;
        -p)
            platform=$2
            add_arg "platform=${platform}"
            shift 2
            ;;
        -p*)
            platform=${1##-p}
            add_arg "platform=${platform}"
            shift
            ;;
        --platform=*)
            platform=${1##-p}
            add_arg "platform=${platform}"
            shift
            ;;
        --gdb)
            gdb=1
            shift
            ;;
        -g)
            gdb=1
            shift
            ;;
        --help)
            show_help
            ;;
        --)
            shift
            break
            ;;
        -*)
            echo "intel_aubdump: invalid option: $1"
            echo
            show_help
            ;;
        *)
            break
            ;;
    esac
done

[ -z $1 ] && show_help

[ -z $file ] && add_arg "file=intel.aub"

tmp_file=`mktemp`
echo -e $args > $tmp_file

if [ -z $gdb ]; then
    LD_PRELOAD="$ld_preload" INTEL_DUMP_GPU_CONFIG=$tmp_file $@
else
    gdb -iex "set exec-wrapper env LD_PRELOAD=$ld_preload INTEL_DUMP_GPU_CONFIG=$tmp_file" --args $@
fi

ret=$?
rm $tmp_file
exit $ret