3 # This function just re-writes the timestamp of the strace entries to be
4 # seconds.usecs since boot. To match the timestamping of ftrace (so we can
9 # parse in data/system/vendor and parse out /sys/devices/system/...
10 egrep '\/system\/|\/data\/|\/vendor\/' $strace | egrep -v '\/sys\/devices\/system\/' > bar
11 fgrep -v '= -1' bar > foo
13 # begin_time is seconds since epoch
14 begin_time=`cat trace.begin`
15 # replace seconds since epoch with SECONDS SINCE BOOT in the
17 awk -v begin="$begin_time" '{ printf "%f strace ", $1 - begin; $1=""; print $0}' bar > $2
22 # This function processes the ftrace file, removing the fields that we don't care
23 # about, breaks up the ftrace file into one file per pid.
24 # Input : One single fstrace file.
25 # Output : Multiple fstrace.pid files.
29 fgrep android_fs_data $1 | sed 's/^.* \[.*\] //' | sed s/://g | sed s/,//g > foo
30 sed 's/android_fs_dataread_start/read/' foo > bar1
32 # First column is timestamp SECONDS SINCE BOOT
33 awk '{ print $2, "ftrace", $3, $5, $7, $9, $13 }' bar > foo
35 # Get all the uniq pids
36 awk '{print $7}' foo | sort | uniq > pidlist
37 for i in `cat pidlist`
39 awk -v pid=$i '{ if (pid == $7) print $0}' foo > fstrace.$i
45 # Merge straces and ftraces.
46 # The goal here is to catch mmap'ed IO (reads) that won't be in the
47 # strace file. The algorithm is to look for mmaps in the strace file,
48 # use the files tha are mmap'ed to search in the ftraces to pick up
49 # tracepoints from there, and merge those with the straces.
50 # The output of this function is a set of parsed_input_trace.<pid>
51 # files, that can then be compiled into .wl files
54 for stracefile in trace.*
56 if [ $stracefile == trace.begin ] || [ $stracefile == trace.tar ];
60 # Get the pid from the strace filename (pid is the extension)
62 process_strace $stracefile foo.$pid
63 if ! [ -s foo.$pid ]; then
68 # If we have matching strace and ftrace files, then look for mmaps in
69 # the strace pluck the corresponding entries for the mmap (mmaped IO)
70 # from the ftrace and merge them into the strace
72 if [ -f fstrace.$pid ]; then
73 fgrep mmap foo.$pid > bar
75 # Get all the unique mmap'ed filenames from the strace
76 awk '{ print $7 }' bar | sed 's/^[^<]*<//g' | sed 's/>,//g' > mapped_files
77 # Pluck all the lines from the ftrace corresponding to the mmaps
78 cat /dev/null > footemp
79 for j in `sort mapped_files | uniq`
81 # Merge the readpage(s) traces from the ftrace into strace
82 # for this mmaped file.
83 grep -w $j fstrace.$pid > foobar
85 sort foo.$pid foobar >> footemp
90 if [ -s footemp ]; then
91 mv footemp parsed_input_trace.$pid
93 mv foo.$pid parsed_input_trace.$pid
96 mv foo.$pid parsed_input_trace.$pid
100 mv foo.$pid parsed_input_trace.$pid
102 echo compiling parsed_input_trace.$pid
103 compile_ioshark parsed_input_trace.$pid $pid.wl
104 rm parsed_input_trace.$pid
115 # Pre-process the ftrace file
117 # Merge the ftrace file(s) with the strace files
120 # tar up the .wl files just created
121 tar cf wl-test.tar ioshark_filenames *.wl