blob: 22073b5c72691c8b1cc6b7514de14826b9e50ff5 (
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
###############################################################################
# @File pvrhtbd
# @Title HTB Log dump tool
# @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
# @Description Script to execute a set of tests and collate the benchmark
# performance into a single report.
# @License Strictly Confidential.
###############################################################################
usage() {
echo ""
echo "Usage: ./pvrhtbd [pvrdebug hostlog options and arguments]"
echo "Dump the processed output of the Host Trace Buffer to a file."
echo ""
echo "This tool starts a reader daemon, then applies any hostlog"
echo "configuration options."
echo "Data logging continues until <enter> is pressed to stop log capture"
echo ""
echo "There are two main use-cases supported by this tool:"
echo "Crash Logging:"
echo " Where the Host Trace Buffer has been configured via powervr.ini"
echo " to drop the oldest logs, this tool can be used without arguments"
echo " after the driver has crashed to capture the logs leading up to"
echo " the crash point."
echo "Continuous Logging:"
echo " The tool may be stated, applying any Host Trace configuration"
echo " options required and left running until the data required has"
echo " been captured."
echo " If the Host Trace Buffer size specified in powervr.ini is large"
echo " enough, and this tool started early enough putting the Host Trace"
echo " in blocking mode, it should be possible to capture all Host Trace"
echo " events"
echo ""
echo " -h, --help prints this message"
echo ""
}
# write_cfg_file(tld_output_folder, cfg_file)
write_cfg_file() {
echo "
[pvrtld]
output_folder_name=$1
output_type=file
omit_header=yes
output_file_save_previous=yes
[PVRHTBuffer]
enabled=yes
output_file_name=$2
wait_for_stream=yes
" > $3
}
PVRINI_FILE="/etc/powervr.ini"
TLD_CFG_FILE="htbtld.conf"
FIFO_FILE="tldctrl.fifo"
HT_BASENAME="hosttrace"
HT_OUTFILE="${HT_BASENAME}.bin"
HOSTTRACE_FILE="${HT_BASENAME}.log"
PVRDBG_DROPLATEST="-hostlogtype droplatest"
BLOCK_STR="block"
APPHINT_EN_STR="EnableHTBLogGroup"
PVRDEBUG_EN_STR="hostloggroups"
PVRDEBUG_ARGS=""
GRAB_LOG=0
init() {
# detect os
if [ -x "/system/bin/logcat" ]; then
OS="Android"
else
OS="Linux"
fi
# set OS dependent variables here
if [ $OS = 'Android' ]; then
TMP_DIR="/data/local/tmp"
BIN_DIR="/system/vendor/bin"
TLD_BIN="$BIN_DIR/pvrtld"
PVRDEBUG_BIN="$BIN_DIR/pvrdebug"
HTB_BIN="$BIN_DIR/pvrhtb2txt"
else
TMP_DIR="/tmp"
TLD_BIN="`command -v \"pvrtld\"`"
PVRDEBUG_BIN="`command -v \"pvrdebug\"`"
HTB_BIN="`command -v \"pvrhtb2txt\"`"
fi
if [ ! -x "$TLD_BIN" ]; then
echo "[Error] pvrtld not found"
exit 1
fi
if [ ! -x "$PVRDEBUG_BIN" ]; then
echo "[Error] pvrdebug not found"
exit 1
fi
if [ ! -x "$HTB_BIN" ]; then
echo "[Error] pvrhtb2txt not found"
exit 1
fi
WORK_DIR="$TMP_DIR/`date +pvrhtbd_%y%m%d%H%M`"
mkdir -p $WORK_DIR
}
arg_parse() {
arg_add=0
for argument in "$@"
do
case "$argument" in
-hostloggroups|-hostlogmode|-hostlogtype|-hostloglevel)
PVRDEBUG_ARGS="$PVRDEBUG_ARGS $argument"
arg_add=1
;;
-h|--help)
usage
exit 0
;;
-g|--grab)
GRAB_LOG=1
;;
*)
if [ "$arg_add" -eq "1" ]; then
PVRDEBUG_ARGS="$PVRDEBUG_ARGS $argument"
arg_add=0
else
echo "[Error] Argument '$argument' not recognized."
echo " Run '$0 -h' for more information."; exit 1
fi
;;
esac
done
}
capture_hosttrace() {
# fifo to send keypress to backgrounded app
# mknod $WORK_DIR/$FIFO_FILE p
# run pvrtld in background
# (redirecting stdout causes pvrtld to fail to write output)
#$TLD_BIN -f=$WORK_DIR/$TLD_CFG_FILE < $WORK_DIR/$FIFO_FILE &
$TLD_BIN -f=$WORK_DIR/$TLD_CFG_FILE &
proc_num=$!
sleep 3
# set the logging parameters as requested
# this has to be done after starting capture to support blocking logs
if [ ! -z "$PVRDEBUG_ARGS" ]; then
echo "Using pvrdebug to set logging parameters:"
echo " $PVRDEBUG_ARGS"
$PVRDEBUG_BIN $PVRDEBUG_ARGS
fi
if [ "0" -eq "$GRAB_LOG" ]; then
# wait for a keypress (Android does not give a lot of options for this)
echo "Please press <Enter> to stop log capture"
dd bs=1 count=1 2> /dev/null
else
sleep 3
fi
# safely stop if reading a blocking log
echo $PVRDEBUG_ARGS | grep -q "$BLOCK_STR"
if [ "0" -eq "$?" ]; then
echo "Using pvrdebug to reset logging parameters:"
echo " $PVRDBG_DROPLATEST"
$PVRDEBUG_BIN $PVRDBG_DROPLATEST
fi
# stop pvrtld
#echo -n "x" > $WORK_DIR/$FIFO_FILE
#rm $WORK_DIR/$FIFO_FILE
kill -s QUIT $proc_num
# wait some because pvrtld is slow to stop
sleep 3
# flush to disk
sync
}
process_binfile() {
$HTB_BIN -bin $WORK_DIR/$HT_OUTFILE > $WORK_DIR/$HOSTTRACE_FILE
echo "Host Trace Data written to: $WORK_DIR/$HOSTTRACE_FILE"
}
perform_check() {
if [ -e $PVRINI_FILE ]; then
grep -q "$APPHINT_EN_STR" $PVRINI_FILE
app_en=$?
else
app_en=1
fi
echo $PVRDEBUG_ARGS > $WORK_DIR/args.tmp
grep -q "$PVRDEBUG_EN_STR" $WORK_DIR/args.tmp
arg_en=$?
if [ "0" -ne "$app_en" -a "0" -ne "$arg_en" ]; then
echo "Host Trace Logging is not enabled in either:"
echo " $PVRINI_FILE"
echo " or cmdline args"
echo "Nothing will be caputured"
exit 1
fi
}
archive() {
if [ $OS = "Android" ]; then
if [ ! -x /system/bin/gzip ]; then
return
fi
else
if ! command gzip -h >/dev/null 2>&1; then
return
fi
fi
echo -n "Archiving data ...................... "
gzip -f $OUT
echo "done"
echo ""
echo "File $OUT.gz was created."
}
run_main() {
echo ""
echo "========================== HTB Log Dump ============================"
init
arg_parse $@
perform_check
write_cfg_file $WORK_DIR $HT_BASENAME $WORK_DIR/$TLD_CFG_FILE
echo ""
echo "======================== Capturing HTB Log ========================="
capture_hosttrace
echo ""
echo "======================== Write out HTB Log ========================="
process_binfile
echo ""
echo ""
}
# main function
run_main $@
|