blob: f8e889f2f5e193a17a8f513efddd5de135a73b69 [file] [log] [blame]
Primiano Tuccib7cca202018-01-29 16:30:47 +00001#!/bin/bash
2# Copyright (C) 2018 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15set -e
Joel Fernandes16e86102019-03-19 13:42:48 -040016CUR_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
17
18export PATH="$PATH:$CUR_DIR"
Primiano Tuccib7cca202018-01-29 16:30:47 +000019
Primiano Tucci2ffd1a52018-03-27 01:01:30 +010020if [ "$TMPDIR" == "" ]; then
21 TMPDIR=/tmp
22fi
23
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010024function get_gn_value() {
Hector Dearmanc9c183a2018-02-08 12:01:12 +000025 local out=$1
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010026 local key=$2
Ryan Savitski7b0c2c12019-11-19 17:51:43 +000027 gn args "$out" --list=$key --short | awk '{print $3}' | tr -d '"'
Hector Dearmanc067d412018-03-16 17:01:41 +000028}
29
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010030function is_monolithic() {
Hector Dearmanc067d412018-03-16 17:01:41 +000031 local out=$1
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010032 value=$(get_gn_value "$out" "monolithic_binaries")
33 test "$value" == "true"
Hector Dearmanc9c183a2018-02-08 12:01:12 +000034}
35
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010036function is_android() {
37 local out=$1
38 value=$(get_gn_value "$out" "target_os")
39 test "$value" == "android"
40}
41
Ryan Savitski6cadb872019-09-06 17:25:15 +010042function is_ssh_target() {
Matthew Clarkson9bace992019-10-17 10:30:27 +010043 [[ -n "$SSH_TARGET" ]]
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010044}
45
46function is_mac() {
Matthew Clarkson83987d22019-10-03 17:30:53 +010047 # shellcheck disable=2251
Primiano Tucci676f0cc2018-12-03 20:03:26 +010048 ! test -d /proc
49 return $?
50}
51
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010052function tmux_ensure_bash() {
Hector Dearman2407cdd2019-06-04 13:21:34 +010053 if [[ $SHELL == *"fish" ]]; then
54 tmux send-keys "bash" Enter
55 fi
56}
57
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010058function reset_tracing() {
59 if is_android "$OUT"; then
Primiano Tucci2ffd1a52018-03-27 01:01:30 +010060 adb shell 'echo 0 > /d/tracing/tracing_on'
Primiano Tucci676f0cc2018-12-03 20:03:26 +010061 elif ! is_mac; then
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010062 # shellcheck disable=SC2016
63 local script='
Primiano Tucci2ffd1a52018-03-27 01:01:30 +010064 if [ ! -w /sys/kernel/debug ]; then
65 echo "debugfs not accessible, try sudo chown -R $USER /sys/kernel/debug"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010066 sudo chown -R "$USER" /sys/kernel/debug
Primiano Tucci2ffd1a52018-03-27 01:01:30 +010067 fi
68
69 echo 0 > /sys/kernel/debug/tracing/tracing_on
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010070 '
71
Ryan Savitski6cadb872019-09-06 17:25:15 +010072 if is_ssh_target; then
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010073 # shellcheck disable=SC2029
Matthew Clarkson83987d22019-10-03 17:30:53 +010074 ssh -t "$SSH_TARGET" "sh -c '$script'"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010075 else
76 sh -c "$script"
77 fi
Primiano Tucci2ffd1a52018-03-27 01:01:30 +010078 fi
Hector Dearman0ff07c72018-03-15 09:54:46 +000079}
80
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010081function adb_supports_push_sync() {
82 adb --help 2>&1 | grep 'push.*\[--sync\]' >/dev/null 2>&1
Hector Dearmanc067d412018-03-16 17:01:41 +000083}
84
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010085function push() {
86 if is_android "$OUT"; then
Hector Dearmanc067d412018-03-16 17:01:41 +000087 local maybe_sync=''
88 if adb_supports_push_sync; then
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010089 maybe_sync='--sync'
Hector Dearmanc067d412018-03-16 17:01:41 +000090 fi
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010091 echo adb push $maybe_sync "$1" "$DIR"
92 adb push $maybe_sync "$1" "$DIR"
Ryan Savitski6cadb872019-09-06 17:25:15 +010093 elif is_ssh_target; then
94 echo scp "$1" "$SSH_TARGET:$DIR"
95 scp "$1" "$SSH_TARGET:$DIR"
Hector Dearmanc067d412018-03-16 17:01:41 +000096 else
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010097 echo cp "$1" "$DIR"
98 cp "$1" "$DIR"
Hector Dearman9b89d472018-02-28 12:07:21 +000099 fi
Hector Dearmanc067d412018-03-16 17:01:41 +0000100}
101
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100102function pull() {
103 if is_android "$OUT"; then
104 echo adb pull "$DIR/$1" "$2"
105 adb pull "$DIR/$1" "$2"
Ryan Savitski6cadb872019-09-06 17:25:15 +0100106 elif is_ssh_target; then
107 echo scp "$SSH_TARGET:$DIR/$1" "$2"
108 scp "$SSH_TARGET:$DIR/$1" "$2"
Hector Dearmanc067d412018-03-16 17:01:41 +0000109 else
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100110 echo mv "$DIR/$1" "$2"
111 mv "$DIR/$1" "$2"
Hector Dearmanc067d412018-03-16 17:01:41 +0000112 fi
Hector Dearman9b89d472018-02-28 12:07:21 +0000113}
114
Ryan Savitskibf67d302019-07-29 14:00:43 +0100115BACKGROUND=0
116SKIP_CONVERTERS=0
117TMUX_LAYOUT="even-vertical"
Ryan Savitski6cadb872019-09-06 17:25:15 +0100118CPU_MASK=""
Florian Mayerb8433222018-05-15 11:29:18 +0100119
Matthew Clarkson9bace992019-10-17 10:30:27 +0100120while getopts "bl:nt:c:C:z:s:" o; do
Florian Mayerb8433222018-05-15 11:29:18 +0100121 case "$o" in
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100122 b) BACKGROUND=1 ;;
123 l) TMUX_LAYOUT=${OPTARG} ;;
124 n) SKIP_CONVERTERS=1 ;;
Ryan Savitski6cadb872019-09-06 17:25:15 +0100125 t) SSH_TARGET=${OPTARG} ;;
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100126 c) CONFIG=${OPTARG} ;;
127 C) OUT=${OPTARG} ;;
Ryan Savitski6cadb872019-09-06 17:25:15 +0100128 z) CPU_MASK=${OPTARG} ;;
Matthew Clarkson9bace992019-10-17 10:30:27 +0100129 s) SCRIPT=${OPTARG} ;;
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100130 *)
Matthew Clarkson9bace992019-10-17 10:30:27 +0100131 echo >&2 "Invalid option $o"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100132 exit
133 ;;
Florian Mayerb8433222018-05-15 11:29:18 +0100134 esac
135done
136
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100137# Allow out to be passed as argument
138shift $((OPTIND - 1))
139OUT="${OUT:-$1}"
140
Matthew Clarkson83987d22019-10-03 17:30:53 +0100141# Provide useful usage information
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100142if [ -z "$OUT" ]; then
143 echo "Usage: $0 [OPTION]... [OUTPUT]"
144 echo ""
145 echo "Options:"
146 echo " -b run in the background"
Ryan Savitski6cadb872019-09-06 17:25:15 +0100147 echo " -l LAYOUT tmux pane layout"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100148 echo " -n skip post-trace convertors"
149 echo " -t TARGET SSH device target"
150 echo " -c CONFIG trace configuration file"
151 echo " -C OUTPUT output directory"
Ryan Savitski6cadb872019-09-06 17:25:15 +0100152 echo " -z MASK constrain binaries to given cpu mask (taskset syntax)"
Matthew Clarkson9bace992019-10-17 10:30:27 +0100153 echo " -s SCRIPT a script to put into a tmux pane"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100154 echo ""
155 echo "Environment variables:"
Ryan Savitski6cadb872019-09-06 17:25:15 +0100156 echo " SSH_TARGET SSH device target"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100157 echo " CONFIG trace configuration file"
Ryan Savitski6cadb872019-09-06 17:25:15 +0100158 echo " OUT output directory"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100159 exit 1
160fi
161
162# Warn about invalid output directories
Primiano Tuccib7cca202018-01-29 16:30:47 +0000163if [ ! -f "$OUT/args.gn" ]; then
Matthew Clarkson9bace992019-10-17 10:30:27 +0100164 echo >&2 "OUT=$OUT doesn't look like an output directory."
165 echo >&2 "Please specify a directory by doing:"
166 echo >&2 " export OUT=out/xxx $0"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100167 exit 1
168fi
169
Matthew Clarkson83987d22019-10-03 17:30:53 +0100170# Check SSH target is valid
Ryan Savitski6cadb872019-09-06 17:25:15 +0100171if is_ssh_target && ! ssh -q "$SSH_TARGET" exit; then
Matthew Clarkson9bace992019-10-17 10:30:27 +0100172 echo >&2 "SSH_TARGET=$SSH_TARGET doesn't look like a valid SSH target."
173 echo >&2 "Please specify a SSH cross-compilation target by doing:"
174 echo >&2 " export SSH_TARGET=<user>@<host> $0"
Matthew Clarkson83987d22019-10-03 17:30:53 +0100175 exit 1
176fi
177
Matthew Clarkson9bace992019-10-17 10:30:27 +0100178if ! builtin type -P tmux &>/dev/null; then
179 echo >&2 "tmux not found"
Primiano Tuccib7cca202018-01-29 16:30:47 +0000180 exit 1
181fi
182
Hector Dearmanc88a66d2018-02-01 14:07:14 +0000183# You can set the config to one of the files under test/configs e.g.
184# CONFIG=ftrace.cfg or to :test. Defaults to :test.
185CONFIG="${CONFIG:-:test}"
186
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100187if is_android "$OUT"; then
Hector Dearmanc067d412018-03-16 17:01:41 +0000188 DIR=/data/local/tmp
Ryan Savitski6cadb872019-09-06 17:25:15 +0100189elif is_ssh_target; then
190 DIR=$(ssh "$SSH_TARGET" mktemp -d $TMPDIR/perfetto.XXXXXX)
Primiano Tucci676f0cc2018-12-03 20:03:26 +0100191elif is_mac; then
192 DIR=$(mktemp -d $TMPDIR/perfetto.XXXXXX)
Hector Dearmanc067d412018-03-16 17:01:41 +0000193else
Primiano Tucci2ffd1a52018-03-27 01:01:30 +0100194 DIR=$(mktemp -p $TMPDIR -d perfetto.XXXXXX)
Hector Dearmanc067d412018-03-16 17:01:41 +0000195fi
196
Matthew Clarksonfc8ccd02019-11-26 13:58:09 +0000197"$CUR_DIR/ninja" -C "$OUT" \
198 traced traced_probes perfetto trace_to_text test/configs
Primiano Tuccib7cca202018-01-29 16:30:47 +0000199
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100200push "$OUT/traced"
201push "$OUT/traced_probes"
202push "$OUT/perfetto"
Hector Dearman0ff07c72018-03-15 09:54:46 +0000203reset_tracing
Primiano Tuccib7cca202018-01-29 16:30:47 +0000204
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100205if is_android "$OUT"; then
Primiano Tucci301175d2019-01-11 10:10:21 +0000206 PREFIX="PERFETTO_CONSUMER_SOCK_NAME=@perfetto_test_consumer PERFETTO_PRODUCER_SOCK_NAME=@perfetto_test_producer"
Florian Mayerb0f00712018-04-04 16:35:45 +0100207else
208 PREFIX=""
209fi
210
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100211if ! is_monolithic "$OUT"; then
Florian Mayerb0f00712018-04-04 16:35:45 +0100212 PREFIX="$PREFIX LD_LIBRARY_PATH=$DIR"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100213 push "$OUT/libperfetto.so"
Hector Dearmanc9c183a2018-02-08 12:01:12 +0000214fi
215
Primiano Tucci9ba1d842018-12-20 17:31:04 +0100216CONFIG_DEVICE_PATH="$CONFIG"
Hector Dearmanb7fa5442018-11-08 18:39:32 +0000217CMD_OPTS=""
218if [[ "$CONFIG" == *.protobuf ]]; then
Hector Dearman696ff772019-04-23 18:38:53 +0100219 CONFIG_DEVICE_PATH="$CONFIG"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100220 CONFIG_PATH=$OUT/$CONFIG
Hector Dearmanc88a66d2018-02-01 14:07:14 +0000221 if [[ ! -f $CONFIG_PATH ]]; then
Matthew Clarkson9bace992019-10-17 10:30:27 +0100222 echo >&2 "Config \"$CONFIG_PATH\" not known."
Hector Dearmanc88a66d2018-02-01 14:07:14 +0000223 exit 1
224 fi
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100225 push "$CONFIG_PATH"
Hector Dearmanb7fa5442018-11-08 18:39:32 +0000226elif [[ "$CONFIG" != ":test" ]]; then
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100227 CONFIG_DEVICE_PATH="$(basename "$CONFIG")"
Ioannis Ilkos482264e2019-01-15 10:46:11 +0000228 CONFIG_PATH=test/configs/$CONFIG
229 # Check if this is a valid absolute path
Hector Dearmanb7fa5442018-11-08 18:39:32 +0000230 if [[ ! -f $CONFIG_PATH ]]; then
Ioannis Ilkos482264e2019-01-15 10:46:11 +0000231 CONFIG_PATH=$CONFIG
232 if [[ ! -f $CONFIG_PATH ]]; then
Matthew Clarkson9bace992019-10-17 10:30:27 +0100233 echo >&2 "Config \"$CONFIG\" not known."
Ioannis Ilkos482264e2019-01-15 10:46:11 +0000234 exit 1
235 fi
Hector Dearmanb7fa5442018-11-08 18:39:32 +0000236 fi
237 CMD_OPTS="--txt $CMD_OPTS"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100238 push "$CONFIG_PATH"
Hector Dearmanc88a66d2018-02-01 14:07:14 +0000239fi
240
Matthew Clarkson9bace992019-10-17 10:30:27 +0100241if [[ -f "$SCRIPT" ]]; then
242 push "$SCRIPT"
243fi
244
Florian Mayerb8433222018-05-15 11:29:18 +0100245POSTFIX=""
246
Ryan Savitski6cadb872019-09-06 17:25:15 +0100247if [[ -n "$CPU_MASK" ]]; then
248 PREFIX="$PREFIX taskset $CPU_MASK"
249fi
250
Ryan Savitskibf67d302019-07-29 14:00:43 +0100251if [[ BACKGROUND -eq 1 ]]; then
Florian Mayerb8433222018-05-15 11:29:18 +0100252 PREFIX="$PREFIX nohup"
253 POSTFIX=" &> /dev/null &"
254fi
255
Primiano Tuccib7cca202018-01-29 16:30:47 +0000256if tmux has-session -t demo; then
257 tmux kill-session -t demo
258fi
259tmux -2 new-session -d -s demo
260
261if tmux -V | awk '{split($2, ver, "."); if (ver[1] < 2) exit 1 ; else if (ver[1] == 2 && ver[2] < 1) exit 1 }'; then
262 tmux set-option -g mouse on
263else
264 tmux set-option -g mode-mouse on
265 tmux set-option -g mouse-resize-pane on
266 tmux set-option -g mouse-select-pane on
267 tmux set-option -g mouse-select-window on
268fi
269
270tmux split-window -v
271tmux split-window -v
272
Matthew Clarkson9bace992019-10-17 10:30:27 +0100273if [[ -n "$SCRIPT" ]]; then
274 tmux split-window -v
275fi
276
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100277tmux select-layout "${TMUX_LAYOUT}"
Primiano Tuccib7cca202018-01-29 16:30:47 +0000278
279tmux select-pane -t 0
280tmux send-keys "clear" C-m
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100281if is_android "$OUT"; then
Hector Dearmanc067d412018-03-16 17:01:41 +0000282 tmux send-keys "adb shell" C-m
283fi
Primiano Tuccib7cca202018-01-29 16:30:47 +0000284
285tmux select-pane -t 1
286tmux send-keys "clear" C-m
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100287if is_android "$OUT"; then
Hector Dearmanc067d412018-03-16 17:01:41 +0000288 tmux send-keys "adb shell" C-m
289fi
Primiano Tuccib7cca202018-01-29 16:30:47 +0000290
291tmux select-pane -t 2
292tmux send-keys "clear" C-m
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100293if is_android "$OUT"; then
Hector Dearmanc067d412018-03-16 17:01:41 +0000294 tmux send-keys "adb shell" C-m
295fi
Primiano Tuccib7cca202018-01-29 16:30:47 +0000296
Matthew Clarkson9bace992019-10-17 10:30:27 +0100297if [[ -n "$SCRIPT" ]]; then
298 tmux select-pane -t 3
299 tmux send-keys "clear" C-m
Matthew Clarksonf8e61102019-10-28 13:26:50 +0000300 if is_android "$OUT"; then
301 tmux send-keys "adb shell" C-m
302 fi
Matthew Clarkson9bace992019-10-17 10:30:27 +0100303fi
304
Hector Dearmanc88a66d2018-02-01 14:07:14 +0000305sleep 2
Primiano Tuccib7cca202018-01-29 16:30:47 +0000306
307tmux select-pane -t 1
Ryan Savitski6cadb872019-09-06 17:25:15 +0100308if is_ssh_target; then
309 tmux send-keys "ssh $SSH_TARGET" Enter
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100310fi
Hector Dearman2407cdd2019-06-04 13:21:34 +0100311tmux_ensure_bash
Ryan Savitskibf67d302019-07-29 14:00:43 +0100312tmux send-keys "PS1='[traced]$ '" Enter
Primiano Tucci9ba1d842018-12-20 17:31:04 +0100313tmux send-keys "cd $DIR" Enter
Matthew Clarkson9bace992019-10-17 10:30:27 +0100314tmux send-keys "clear" C-m
Ryan Savitski6cadb872019-09-06 17:25:15 +0100315tmux send-keys "$PREFIX ./traced $POSTFIX" Enter
Primiano Tuccib7cca202018-01-29 16:30:47 +0000316
Primiano Tuccib7cca202018-01-29 16:30:47 +0000317tmux select-pane -t 0
Ryan Savitski6cadb872019-09-06 17:25:15 +0100318if is_ssh_target; then
319 tmux send-keys "ssh $SSH_TARGET" Enter
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100320fi
Hector Dearman2407cdd2019-06-04 13:21:34 +0100321tmux_ensure_bash
Ryan Savitskibf67d302019-07-29 14:00:43 +0100322tmux send-keys "PS1='[traced_probes]$ '" Enter
Primiano Tucci9ba1d842018-12-20 17:31:04 +0100323tmux send-keys "cd $DIR" Enter
Matthew Clarkson9bace992019-10-17 10:30:27 +0100324tmux send-keys "clear" C-m
Ryan Savitski6cadb872019-09-06 17:25:15 +0100325tmux send-keys "$PREFIX ./traced_probes $POSTFIX" Enter
Primiano Tuccib7cca202018-01-29 16:30:47 +0000326
327tmux select-pane -t 2
Ryan Savitski6cadb872019-09-06 17:25:15 +0100328if is_ssh_target; then
329 tmux send-keys "ssh $SSH_TARGET" Enter
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100330fi
Hector Dearman2407cdd2019-06-04 13:21:34 +0100331tmux_ensure_bash
Primiano Tucci9ba1d842018-12-20 17:31:04 +0100332tmux send-keys "PS1='[consumer]$ '" Enter
333tmux send-keys "cd $DIR" Enter
Matthew Clarkson9bace992019-10-17 10:30:27 +0100334tmux send-keys "clear" C-m
Ryan Savitski6cadb872019-09-06 17:25:15 +0100335tmux send-keys "$PREFIX ./perfetto $CMD_OPTS -c $CONFIG_DEVICE_PATH -o trace $POSTFIX"
Primiano Tuccib7cca202018-01-29 16:30:47 +0000336
Matthew Clarkson9bace992019-10-17 10:30:27 +0100337if [[ -n "$SCRIPT" ]]; then
338 tmux select-pane -t 3
339 if is_ssh_target; then
340 tmux send-keys "ssh $SSH_TARGET" Enter
341 fi
342 tmux_ensure_bash
343 tmux send-keys "PS1='[script]$ '" Enter
344 tmux send-keys "cd $DIR" Enter
345 tmux send-keys "clear" C-m
Matthew Clarksonf8e61102019-10-28 13:26:50 +0000346 if [[ -f "$SCRIPT" ]]; then
347 tmux send-keys "./$(basename "$SCRIPT")"
348 else
349 tmux send-keys "$SCRIPT"
350 fi
Matthew Clarkson9bace992019-10-17 10:30:27 +0100351fi
352
Primiano Tuccib7cca202018-01-29 16:30:47 +0000353# Select consumer pane.
354tmux select-pane -t 2
355
356tmux -2 attach-session -t demo
Ryan Savitskibf67d302019-07-29 14:00:43 +0100357if [[ BACKGROUND -eq 1 ]]; then
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100358 exit 0
Florian Mayerb8433222018-05-15 11:29:18 +0100359fi
Hector Dearmana7c04f82018-03-29 11:31:24 +0100360
Hector Dearman3c4e5c22018-03-29 11:31:55 +0100361reset_tracing
Hector Dearmana7c04f82018-03-29 11:31:24 +0100362
363TRACE=$HOME/Downloads/trace
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100364echo -e "\n\x1b[32mPulling trace into $TRACE.protobuf\x1b[0m"
365pull trace "$TRACE.protobuf"
Ryan Savitskibf67d302019-07-29 14:00:43 +0100366
367if [[ SKIP_CONVERTERS -eq 0 ]]; then
368 echo -e "\n\x1b[32mPulling trace into $TRACE.pbtext\x1b[0m"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100369 "$OUT/trace_to_text" text <"$TRACE.protobuf" >"$TRACE.pbtext"
Ryan Savitskibf67d302019-07-29 14:00:43 +0100370 echo -e "\n\x1b[32mPulling trace into $TRACE.json\x1b[0m"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100371 "$OUT/trace_to_text" systrace <"$TRACE.protobuf" >"$TRACE.json"
Ryan Savitskibf67d302019-07-29 14:00:43 +0100372 # Keep this last so it can fail.
373fi