intel/tools/dump_gpu: Add option to print ppgtt mappings.
[mesa.git] / src / intel / tools / intel_dump_gpu.in
1 #!/bin/bash
2 # -*- mode: sh -*-
3
4 function show_help() {
5 cat <<EOF
6 Usage: intel_dump_gpu [OPTION]... [--] COMMAND ARGUMENTS
7
8 Run COMMAND with ARGUMENTS and dump an AUB file that captures buffer
9 contents and execution of the GEM application.
10
11 -o, --output=FILE Name of AUB file. Defaults to COMMAND.aub
12
13 -c, --command=CMD Execute CMD and write the AUB file's content to its
14 standard input
15
16 --device=ID Override PCI ID of the reported device
17
18 -v Enable verbose output
19
20 -vv Enable extra verbosity - dumps gtt mappings
21
22 --help Display this help message and exit
23
24 EOF
25
26 exit 0
27 }
28
29 args=""
30 command=""
31 file=""
32
33 function add_arg() {
34 arg=$1
35 args="$args$arg\n"
36 }
37
38 function build_command () {
39 command=""
40 for i in $1; do
41 if [ -z $command ]; then
42 command=$i
43 else
44 command="$command,$i"
45 fi;
46 done
47 }
48
49 while true; do
50 case "$1" in
51 -o)
52 file=$2
53 add_arg "file=${file:-$(basename ${file}).aub}"
54 shift 2
55 ;;
56 -v)
57 add_arg "verbose=1"
58 shift 1
59 ;;
60 -vv)
61 add_arg "verbose=2"
62 shift 1
63 ;;
64 -o*)
65 file=${1##-o}
66 add_arg "file=${file:-$(basename ${file}).aub}"
67 shift
68 ;;
69 --output=*)
70 file=${1##--output=}
71 add_arg "file=${file:-$(basename ${file}).aub}"
72 shift
73 ;;
74 -c)
75 build_command "$2"
76 add_arg "command=$command"
77 shift 2
78 ;;
79 --command=*)
80 build_command "${1##--command=}"
81 add_arg "command=$command"
82 shift
83 ;;
84 --device=*)
85 add_arg "device=${1##--device=}"
86 shift
87 ;;
88 --help)
89 show_help
90 ;;
91 --)
92 shift
93 break
94 ;;
95 -*)
96 echo "intel_aubdump: invalid option: $1"
97 echo
98 show_help
99 ;;
100 *)
101 break
102 ;;
103 esac
104 done
105
106 [ -z $1 ] && show_help
107
108 [ -z $file ] && [ -z $command ] && add_arg "file=intel.aub"
109
110 LD_PRELOAD="@install_libexecdir@/libintel_dump_gpu.so${LD_PPRELOAD:+:$LD_PRELOAD}" \
111 exec -- "$@" 3<<EOF
112 `echo -e $args`
113 EOF