Debian Codegraph @

ioshark/collect-straces.sh

raw symbols SCIP
1 # Copyright (C) 2016 The Android Open Source Project
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 # # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 #!/bin/sh
15
16 # When signal is received, the stracer will get killed
17 # Call this (just to make sure anyway)
18 kill_stracescip-shell shell android-platform-system-extras 10.0.0+r36+ds-2.1 kill_strace().() {
19 ps_line=`psscip-shell system . . ps. -ef | grepscip-shell system . . grep. strace | grepscip-shell system . . grep. adb `
20 if [scip-shell system . . `[`. $? == 0 ]; then
21 echoscip-shell system . . echo. Killing `echoscip-shell system . . echo. $ps_line | awkscip-shell system . . awk. '{s = ""; for (i=8; i <= NF ; i++) s = s \
22 $i " "; print s}' `
23 killscip-shell system . . kill. `echoscip-shell system . . echo. $ps_line | awkscip-shell system . . awk. '{print $2}' `
24 fi
25 }
26
27 catch_sigintscip-shell shell android-platform-system-extras 10.0.0+r36+ds-2.1 catch_sigint().()
28 {
29 echoscip-shell system . . echo. "signal INT received, killing streaming trace capture"
30 kill_stracescip-shell shell android-platform-system-extras 10.0.0+r36+ds-2.1 kill_strace().
31 }
32
33 compile_tracefilesscip-shell shell android-platform-system-extras 10.0.0+r36+ds-2.1 compile_tracefiles().()
34 {
35 for i in trace.*
36 do
37 if [scip-shell system . . `[`. $i != trace.begin ] && [scip-shell system . . `[`. $i != trace.tar ];
38 then
39 egrepscip-shell system . . egrep. '\/system\/|\/data\/|\/vendor\/' $i > bar
40 # parse out /sys/devices/system/...
41 egrepscip-shell system . . egrep. -v '\/sys\/devices\/system\/' bar > bar0
42 mvscip-shell system . . mv. bar0 bar
43 fgrepscip-shell system . . fgrep. -v '= -1' bar > foo
44 rmscip-shell system . . rm. bar
45 # begin_time is seconds since epoch
46 begin_time=`catscip-shell system . . cat. trace.begin`
47 # replace seconds since epoch with SECONDS SINCE BOOT in the
48 # strace files
49 awkscip-shell system . . awk. -v begin="$begin_time" '{ printf "%f strace ", $1 - begin; $1=""; print $0}' foo > bar
50 if [scip-shell system . . `[`. -s bar ]
51 then
52 echoscip-shell system . . echo. parsing $i
53 pid=${i##*.}
54 compile_ioshark bar $pid.wl
55 rmscip-shell system . . rm. -f bar
56 else
57 rmscip-shell system . . rm. -f $i bar
58 fi
59 fi
60 done
61 }
62
63 # main() starts here
64
65 adb root && adb wait-for-device
66
67 adb shell 'ps' | grepscip-shell system . . grep. zygote > zygote_pids
68
69 fgrepscip-shell system . . fgrep. -v grep zygote_pids > bar
70 mvscip-shell system . . mv. bar zygote_pids
71 pid1=`grepscip-shell system . . grep. -w zygote zygote_pids | awkscip-shell system . . awk. '{print $2}' `
72 pid2=`grepscip-shell system . . grep. -w zygote64 zygote_pids | awkscip-shell system . . awk. '{print $2}' `
73 rmscip-shell system . . rm. -f zygote_pids
74
75 trap 'catch_sigint' INT
76
77 echoscip-shell system . . echo. "^C this script once you finish running your test"
78
79 adb shell "date +%s > /data/local/tmp/trace.begin ; strace -p $pid1,$pid2 -o /data/local/tmp/trace -q -qq -f -ff -y -ttt -e trace=mmap2,read,write,pread64,pwrite64,fsync,fdatasync,openat,close,lseek,_llseek"
80
81 # Remove any remnant tracefiles first
82 rmscip-shell system . . rm. -f trace.*
83
84 # Get the tracefiles from the device
85 adb shell 'cd /data/local/tmp ; tar cvf trace.tar trace.*'
86 adb pull /data/local/tmp/trace.tarscip-shell filesystem . . `/data/local/tmp/trace.tar`.
87
88 # Extract the tracefiles from the device
89 rmscip-shell system . . rm. -f *.wl
90 tarscip-shell system . . tar. xf trace.tar
91
92 # Compile the tracefiles
93 compile_tracefilesscip-shell shell android-platform-system-extras 10.0.0+r36+ds-2.1 compile_tracefiles().
94
95 # tar up the .wl files just created
96 rmscip-shell system . . rm. -f wl.tar
97 tarscip-shell system . . tar. cf wl.tar ioshark_filenames *.wl