1 # Copyright (C) 2016 The Android Open Source Project
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
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.
16 # When signal is received, the stracer will get killed
17 # Call this (just to make sure anyway)
19 ps_line=`ps -ef | grep strace | grep adb `
21 echo Killing `echo $ps_line | awk '{s = ""; for (i=8; i <= NF ; i++) s = s \
23 kill `echo $ps_line | awk '{print $2}' `
29 echo "signal INT received, killing streaming trace capture"
37 if [ $i != trace.begin ] && [ $i != trace.tar ];
39 egrep '\/system\/|\/data\/|\/vendor\/' $i > bar
40 # parse out /sys/devices/system/...
41 egrep -v '\/sys\/devices\/system\/' bar > bar0
43 fgrep -v '= -1' bar > foo
45 # begin_time is seconds since epoch
46 begin_time=`cat trace.begin`
47 # replace seconds since epoch with SECONDS SINCE BOOT in the
49 awk -v begin="$begin_time" '{ printf "%f strace ", $1 - begin; $1=""; print $0}' foo > bar
54 compile_ioshark bar $pid.wl
65 adb root && adb wait-for-device
67 adb shell 'ps' | grep zygote > zygote_pids
69 fgrep -v grep zygote_pids > bar
71 pid1=`grep -w zygote zygote_pids | awk '{print $2}' `
72 pid2=`grep -w zygote64 zygote_pids | awk '{print $2}' `
75 trap 'catch_sigint' INT
77 echo "^C this script once you finish running your test"
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"
81 # Remove any remnant tracefiles first
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.tar
88 # Extract the tracefiles from the device
92 # Compile the tracefiles
95 # tar up the .wl files just created
97 tar cf wl.tar ioshark_filenames *.wl