blob: 51d140070566241538dfbe95f7ecffc06e517e2b [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
Ryan960da792020-05-05 15:43:20 +010016SCRIPT_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
Joel Fernandes16e86102019-03-19 13:42:48 -040017
Primiano Tucci2ffd1a52018-03-27 01:01:30 +010018if [ "$TMPDIR" == "" ]; then
19 TMPDIR=/tmp
20fi
21
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010022function get_gn_value() {
Hector Dearmanc9c183a2018-02-08 12:01:12 +000023 local out=$1
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010024 local key=$2
Hector Dearmanb58022c2020-06-10 10:33:13 +010025 "$SCRIPT_DIR/gn" args "$out" --list=$key --short | awk '{print $3}' \
26 | tr -d '"'
Hector Dearmanc067d412018-03-16 17:01:41 +000027}
28
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010029function is_monolithic() {
Hector Dearmanc067d412018-03-16 17:01:41 +000030 local out=$1
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010031 value=$(get_gn_value "$out" "monolithic_binaries")
32 test "$value" == "true"
Hector Dearmanc9c183a2018-02-08 12:01:12 +000033}
34
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010035function is_android() {
36 local out=$1
37 value=$(get_gn_value "$out" "target_os")
38 test "$value" == "android"
39}
40
Ryan Savitski6cadb872019-09-06 17:25:15 +010041function is_ssh_target() {
Matthew Clarkson9bace992019-10-17 10:30:27 +010042 [[ -n "$SSH_TARGET" ]]
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010043}
44
45function is_mac() {
Matthew Clarkson83987d22019-10-03 17:30:53 +010046 # shellcheck disable=2251
Primiano Tucci676f0cc2018-12-03 20:03:26 +010047 ! test -d /proc
48 return $?
49}
50
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010051function tmux_ensure_bash() {
Hector Dearman2407cdd2019-06-04 13:21:34 +010052 if [[ $SHELL == *"fish" ]]; then
53 tmux send-keys "bash" Enter
54 fi
55}
56
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010057function reset_tracing() {
58 if is_android "$OUT"; then
Primiano Tucci2ffd1a52018-03-27 01:01:30 +010059 adb shell 'echo 0 > /d/tracing/tracing_on'
Primiano Tucci676f0cc2018-12-03 20:03:26 +010060 elif ! is_mac; then
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010061 # shellcheck disable=SC2016
62 local script='
Primiano Tucci2ffd1a52018-03-27 01:01:30 +010063 if [ ! -w /sys/kernel/debug ]; then
64 echo "debugfs not accessible, try sudo chown -R $USER /sys/kernel/debug"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010065 sudo chown -R "$USER" /sys/kernel/debug
Primiano Tucci2ffd1a52018-03-27 01:01:30 +010066 fi
67
68 echo 0 > /sys/kernel/debug/tracing/tracing_on
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010069 '
70
Ryan Savitski6cadb872019-09-06 17:25:15 +010071 if is_ssh_target; then
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010072 # shellcheck disable=SC2029
Matthew Clarkson83987d22019-10-03 17:30:53 +010073 ssh -t "$SSH_TARGET" "sh -c '$script'"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010074 else
75 sh -c "$script"
76 fi
Primiano Tucci2ffd1a52018-03-27 01:01:30 +010077 fi
Hector Dearman0ff07c72018-03-15 09:54:46 +000078}
79
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010080function adb_supports_push_sync() {
81 adb --help 2>&1 | grep 'push.*\[--sync\]' >/dev/null 2>&1
Hector Dearmanc067d412018-03-16 17:01:41 +000082}
83
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010084function push() {
85 if is_android "$OUT"; then
Hector Dearmanc067d412018-03-16 17:01:41 +000086 local maybe_sync=''
87 if adb_supports_push_sync; then
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010088 maybe_sync='--sync'
Hector Dearmanc067d412018-03-16 17:01:41 +000089 fi
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010090 echo adb push $maybe_sync "$1" "$DIR"
91 adb push $maybe_sync "$1" "$DIR"
Ryan Savitski6cadb872019-09-06 17:25:15 +010092 elif is_ssh_target; then
93 echo scp "$1" "$SSH_TARGET:$DIR"
94 scp "$1" "$SSH_TARGET:$DIR"
Hector Dearmanc067d412018-03-16 17:01:41 +000095 else
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010096 echo cp "$1" "$DIR"
97 cp "$1" "$DIR"
Hector Dearman9b89d472018-02-28 12:07:21 +000098 fi
Hector Dearmanc067d412018-03-16 17:01:41 +000099}
100
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100101function pull() {
102 if is_android "$OUT"; then
103 echo adb pull "$DIR/$1" "$2"
104 adb pull "$DIR/$1" "$2"
Ryan Savitski6cadb872019-09-06 17:25:15 +0100105 elif is_ssh_target; then
106 echo scp "$SSH_TARGET:$DIR/$1" "$2"
107 scp "$SSH_TARGET:$DIR/$1" "$2"
Hector Dearmanc067d412018-03-16 17:01:41 +0000108 else
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100109 echo mv "$DIR/$1" "$2"
110 mv "$DIR/$1" "$2"
Hector Dearmanc067d412018-03-16 17:01:41 +0000111 fi
Hector Dearman9b89d472018-02-28 12:07:21 +0000112}
113
Ryan Savitskibf67d302019-07-29 14:00:43 +0100114BACKGROUND=0
115SKIP_CONVERTERS=0
116TMUX_LAYOUT="even-vertical"
Ryan Savitski6cadb872019-09-06 17:25:15 +0100117CPU_MASK=""
Florian Mayerb8433222018-05-15 11:29:18 +0100118
Matthew Clarkson9bace992019-10-17 10:30:27 +0100119while getopts "bl:nt:c:C:z:s:" o; do
Florian Mayerb8433222018-05-15 11:29:18 +0100120 case "$o" in
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100121 b) BACKGROUND=1 ;;
122 l) TMUX_LAYOUT=${OPTARG} ;;
123 n) SKIP_CONVERTERS=1 ;;
Ryan Savitski6cadb872019-09-06 17:25:15 +0100124 t) SSH_TARGET=${OPTARG} ;;
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100125 c) CONFIG=${OPTARG} ;;
126 C) OUT=${OPTARG} ;;
Ryan Savitski6cadb872019-09-06 17:25:15 +0100127 z) CPU_MASK=${OPTARG} ;;
Matthew Clarkson9bace992019-10-17 10:30:27 +0100128 s) SCRIPT=${OPTARG} ;;
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100129 *)
Matthew Clarkson9bace992019-10-17 10:30:27 +0100130 echo >&2 "Invalid option $o"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100131 exit
132 ;;
Florian Mayerb8433222018-05-15 11:29:18 +0100133 esac
134done
135
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100136# Allow out to be passed as argument
137shift $((OPTIND - 1))
138OUT="${OUT:-$1}"
139
Matthew Clarkson83987d22019-10-03 17:30:53 +0100140# Provide useful usage information
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100141if [ -z "$OUT" ]; then
142 echo "Usage: $0 [OPTION]... [OUTPUT]"
143 echo ""
144 echo "Options:"
145 echo " -b run in the background"
Ryan Savitski6cadb872019-09-06 17:25:15 +0100146 echo " -l LAYOUT tmux pane layout"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100147 echo " -n skip post-trace convertors"
148 echo " -t TARGET SSH device target"
149 echo " -c CONFIG trace configuration file"
150 echo " -C OUTPUT output directory"
Ryan Savitski6cadb872019-09-06 17:25:15 +0100151 echo " -z MASK constrain binaries to given cpu mask (taskset syntax)"
Matthew Clarkson9bace992019-10-17 10:30:27 +0100152 echo " -s SCRIPT a script to put into a tmux pane"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100153 echo ""
154 echo "Environment variables:"
Ryan Savitski6cadb872019-09-06 17:25:15 +0100155 echo " SSH_TARGET SSH device target"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100156 echo " CONFIG trace configuration file"
Ryan Savitski6cadb872019-09-06 17:25:15 +0100157 echo " OUT output directory"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100158 exit 1
159fi
160
161# Warn about invalid output directories
Primiano Tuccib7cca202018-01-29 16:30:47 +0000162if [ ! -f "$OUT/args.gn" ]; then
Matthew Clarkson9bace992019-10-17 10:30:27 +0100163 echo >&2 "OUT=$OUT doesn't look like an output directory."
164 echo >&2 "Please specify a directory by doing:"
165 echo >&2 " export OUT=out/xxx $0"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100166 exit 1
167fi
168
Matthew Clarkson83987d22019-10-03 17:30:53 +0100169# Check SSH target is valid
Ryan Savitski6cadb872019-09-06 17:25:15 +0100170if is_ssh_target && ! ssh -q "$SSH_TARGET" exit; then
Matthew Clarkson9bace992019-10-17 10:30:27 +0100171 echo >&2 "SSH_TARGET=$SSH_TARGET doesn't look like a valid SSH target."
172 echo >&2 "Please specify a SSH cross-compilation target by doing:"
173 echo >&2 " export SSH_TARGET=<user>@<host> $0"
Matthew Clarkson83987d22019-10-03 17:30:53 +0100174 exit 1
175fi
176
Matthew Clarkson9bace992019-10-17 10:30:27 +0100177if ! builtin type -P tmux &>/dev/null; then
178 echo >&2 "tmux not found"
Primiano Tuccib7cca202018-01-29 16:30:47 +0000179 exit 1
180fi
181
Hector Dearmanc88a66d2018-02-01 14:07:14 +0000182# You can set the config to one of the files under test/configs e.g.
183# CONFIG=ftrace.cfg or to :test. Defaults to :test.
184CONFIG="${CONFIG:-:test}"
185
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100186if is_android "$OUT"; then
Hector Dearmanc067d412018-03-16 17:01:41 +0000187 DIR=/data/local/tmp
Ryan Savitski6cadb872019-09-06 17:25:15 +0100188elif is_ssh_target; then
189 DIR=$(ssh "$SSH_TARGET" mktemp -d $TMPDIR/perfetto.XXXXXX)
Primiano Tucci676f0cc2018-12-03 20:03:26 +0100190elif is_mac; then
191 DIR=$(mktemp -d $TMPDIR/perfetto.XXXXXX)
Hector Dearmanc067d412018-03-16 17:01:41 +0000192else
Primiano Tucci2ffd1a52018-03-27 01:01:30 +0100193 DIR=$(mktemp -p $TMPDIR -d perfetto.XXXXXX)
Hector Dearmanc067d412018-03-16 17:01:41 +0000194fi
195
Ryan960da792020-05-05 15:43:20 +0100196# (re)build the binaries
197BUILD_TARGETS=(traced traced_probes perfetto test/configs)
198if [[ SKIP_CONVERTERS -eq 0 ]]; then
199 BUILD_TARGETS+=(trace_to_text)
200fi
201
202"$SCRIPT_DIR/ninja" -C "$OUT" ${BUILD_TARGETS[*]}
Primiano Tuccib7cca202018-01-29 16:30:47 +0000203
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100204push "$OUT/traced"
205push "$OUT/traced_probes"
206push "$OUT/perfetto"
Hector Dearman0ff07c72018-03-15 09:54:46 +0000207reset_tracing
Primiano Tuccib7cca202018-01-29 16:30:47 +0000208
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100209if is_android "$OUT"; then
Primiano Tucci301175d2019-01-11 10:10:21 +0000210 PREFIX="PERFETTO_CONSUMER_SOCK_NAME=@perfetto_test_consumer PERFETTO_PRODUCER_SOCK_NAME=@perfetto_test_producer"
Florian Mayerb0f00712018-04-04 16:35:45 +0100211else
212 PREFIX=""
213fi
214
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100215if ! is_monolithic "$OUT"; then
Florian Mayerb0f00712018-04-04 16:35:45 +0100216 PREFIX="$PREFIX LD_LIBRARY_PATH=$DIR"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100217 push "$OUT/libperfetto.so"
Hector Dearmanc9c183a2018-02-08 12:01:12 +0000218fi
219
Primiano Tucci9ba1d842018-12-20 17:31:04 +0100220CONFIG_DEVICE_PATH="$CONFIG"
Hector Dearmanb7fa5442018-11-08 18:39:32 +0000221CMD_OPTS=""
Ryan960da792020-05-05 15:43:20 +0100222# Shorthand for using serialized test configs.
Hector Dearmanb7fa5442018-11-08 18:39:32 +0000223if [[ "$CONFIG" == *.protobuf ]]; then
Hector Dearman696ff772019-04-23 18:38:53 +0100224 CONFIG_DEVICE_PATH="$CONFIG"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100225 CONFIG_PATH=$OUT/$CONFIG
Hector Dearmanc88a66d2018-02-01 14:07:14 +0000226 if [[ ! -f $CONFIG_PATH ]]; then
Matthew Clarkson9bace992019-10-17 10:30:27 +0100227 echo >&2 "Config \"$CONFIG_PATH\" not known."
Hector Dearmanc88a66d2018-02-01 14:07:14 +0000228 exit 1
229 fi
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100230 push "$CONFIG_PATH"
Hector Dearmanb7fa5442018-11-08 18:39:32 +0000231elif [[ "$CONFIG" != ":test" ]]; then
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100232 CONFIG_DEVICE_PATH="$(basename "$CONFIG")"
Ryan960da792020-05-05 15:43:20 +0100233 CONFIG_PATH=$CONFIG
234 # If path isn't valid, assume it's a name of a test config.
Hector Dearmanb7fa5442018-11-08 18:39:32 +0000235 if [[ ! -f $CONFIG_PATH ]]; then
Ryan960da792020-05-05 15:43:20 +0100236 CONFIG_PATH=test/configs/$CONFIG
Ioannis Ilkos482264e2019-01-15 10:46:11 +0000237 if [[ ! -f $CONFIG_PATH ]]; then
Matthew Clarkson9bace992019-10-17 10:30:27 +0100238 echo >&2 "Config \"$CONFIG\" not known."
Ioannis Ilkos482264e2019-01-15 10:46:11 +0000239 exit 1
240 fi
Hector Dearmanb7fa5442018-11-08 18:39:32 +0000241 fi
242 CMD_OPTS="--txt $CMD_OPTS"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100243 push "$CONFIG_PATH"
Hector Dearmanc88a66d2018-02-01 14:07:14 +0000244fi
245
Matthew Clarkson9bace992019-10-17 10:30:27 +0100246if [[ -f "$SCRIPT" ]]; then
247 push "$SCRIPT"
248fi
249
Florian Mayerb8433222018-05-15 11:29:18 +0100250POSTFIX=""
251
Ryan Savitski6cadb872019-09-06 17:25:15 +0100252if [[ -n "$CPU_MASK" ]]; then
253 PREFIX="$PREFIX taskset $CPU_MASK"
254fi
255
Ryan Savitskibf67d302019-07-29 14:00:43 +0100256if [[ BACKGROUND -eq 1 ]]; then
Florian Mayerb8433222018-05-15 11:29:18 +0100257 PREFIX="$PREFIX nohup"
258 POSTFIX=" &> /dev/null &"
259fi
260
Primiano Tuccib7cca202018-01-29 16:30:47 +0000261if tmux has-session -t demo; then
262 tmux kill-session -t demo
263fi
264tmux -2 new-session -d -s demo
265
Hector Dearman28583e22020-06-08 19:22:45 +0100266if [ ! -z "$ANDROID_ADB_SERVER_PORT" ]; then
267 tmux set-environment -t demo ANDROID_ADB_SERVER_PORT $ANDROID_ADB_SERVER_PORT
268fi
269
Primiano Tuccib7cca202018-01-29 16:30:47 +0000270if tmux -V | awk '{split($2, ver, "."); if (ver[1] < 2) exit 1 ; else if (ver[1] == 2 && ver[2] < 1) exit 1 }'; then
271 tmux set-option -g mouse on
272else
273 tmux set-option -g mode-mouse on
274 tmux set-option -g mouse-resize-pane on
275 tmux set-option -g mouse-select-pane on
276 tmux set-option -g mouse-select-window on
277fi
278
279tmux split-window -v
280tmux split-window -v
281
Matthew Clarkson9bace992019-10-17 10:30:27 +0100282if [[ -n "$SCRIPT" ]]; then
283 tmux split-window -v
284fi
285
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100286tmux select-layout "${TMUX_LAYOUT}"
Primiano Tuccib7cca202018-01-29 16:30:47 +0000287
288tmux select-pane -t 0
289tmux send-keys "clear" C-m
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100290if is_android "$OUT"; then
Hector Dearmanc067d412018-03-16 17:01:41 +0000291 tmux send-keys "adb shell" C-m
292fi
Primiano Tuccib7cca202018-01-29 16:30:47 +0000293
294tmux select-pane -t 1
295tmux send-keys "clear" C-m
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100296if is_android "$OUT"; then
Hector Dearmanc067d412018-03-16 17:01:41 +0000297 tmux send-keys "adb shell" C-m
298fi
Primiano Tuccib7cca202018-01-29 16:30:47 +0000299
300tmux select-pane -t 2
301tmux send-keys "clear" C-m
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100302if is_android "$OUT"; then
Hector Dearmanc067d412018-03-16 17:01:41 +0000303 tmux send-keys "adb shell" C-m
304fi
Primiano Tuccib7cca202018-01-29 16:30:47 +0000305
Matthew Clarkson9bace992019-10-17 10:30:27 +0100306if [[ -n "$SCRIPT" ]]; then
307 tmux select-pane -t 3
308 tmux send-keys "clear" C-m
Matthew Clarksonf8e61102019-10-28 13:26:50 +0000309 if is_android "$OUT"; then
310 tmux send-keys "adb shell" C-m
311 fi
Matthew Clarkson9bace992019-10-17 10:30:27 +0100312fi
313
Hector Dearmanc88a66d2018-02-01 14:07:14 +0000314sleep 2
Primiano Tuccib7cca202018-01-29 16:30:47 +0000315
316tmux select-pane -t 1
Ryan Savitski6cadb872019-09-06 17:25:15 +0100317if is_ssh_target; then
318 tmux send-keys "ssh $SSH_TARGET" Enter
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100319fi
Hector Dearman2407cdd2019-06-04 13:21:34 +0100320tmux_ensure_bash
Ryan Savitskibf67d302019-07-29 14:00:43 +0100321tmux send-keys "PS1='[traced]$ '" Enter
Primiano Tucci9ba1d842018-12-20 17:31:04 +0100322tmux send-keys "cd $DIR" Enter
Matthew Clarkson9bace992019-10-17 10:30:27 +0100323tmux send-keys "clear" C-m
Ryan Savitski6cadb872019-09-06 17:25:15 +0100324tmux send-keys "$PREFIX ./traced $POSTFIX" Enter
Primiano Tuccib7cca202018-01-29 16:30:47 +0000325
Primiano Tuccib7cca202018-01-29 16:30:47 +0000326tmux select-pane -t 0
Ryan Savitski6cadb872019-09-06 17:25:15 +0100327if is_ssh_target; then
328 tmux send-keys "ssh $SSH_TARGET" Enter
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100329fi
Hector Dearman2407cdd2019-06-04 13:21:34 +0100330tmux_ensure_bash
Ryan Savitskibf67d302019-07-29 14:00:43 +0100331tmux send-keys "PS1='[traced_probes]$ '" Enter
Primiano Tucci9ba1d842018-12-20 17:31:04 +0100332tmux send-keys "cd $DIR" Enter
Matthew Clarkson9bace992019-10-17 10:30:27 +0100333tmux send-keys "clear" C-m
Ryan Savitski6cadb872019-09-06 17:25:15 +0100334tmux send-keys "$PREFIX ./traced_probes $POSTFIX" Enter
Primiano Tuccib7cca202018-01-29 16:30:47 +0000335
336tmux select-pane -t 2
Ryan Savitski6cadb872019-09-06 17:25:15 +0100337if is_ssh_target; then
338 tmux send-keys "ssh $SSH_TARGET" Enter
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100339fi
Hector Dearman2407cdd2019-06-04 13:21:34 +0100340tmux_ensure_bash
Primiano Tucci9ba1d842018-12-20 17:31:04 +0100341tmux send-keys "PS1='[consumer]$ '" Enter
342tmux send-keys "cd $DIR" Enter
Matthew Clarkson9bace992019-10-17 10:30:27 +0100343tmux send-keys "clear" C-m
Ryan Savitski6cadb872019-09-06 17:25:15 +0100344tmux send-keys "$PREFIX ./perfetto $CMD_OPTS -c $CONFIG_DEVICE_PATH -o trace $POSTFIX"
Primiano Tuccib7cca202018-01-29 16:30:47 +0000345
Matthew Clarkson9bace992019-10-17 10:30:27 +0100346if [[ -n "$SCRIPT" ]]; then
347 tmux select-pane -t 3
348 if is_ssh_target; then
349 tmux send-keys "ssh $SSH_TARGET" Enter
350 fi
351 tmux_ensure_bash
352 tmux send-keys "PS1='[script]$ '" Enter
353 tmux send-keys "cd $DIR" Enter
354 tmux send-keys "clear" C-m
Matthew Clarksonf8e61102019-10-28 13:26:50 +0000355 if [[ -f "$SCRIPT" ]]; then
356 tmux send-keys "./$(basename "$SCRIPT")"
357 else
358 tmux send-keys "$SCRIPT"
359 fi
Matthew Clarkson9bace992019-10-17 10:30:27 +0100360fi
361
Primiano Tuccib7cca202018-01-29 16:30:47 +0000362# Select consumer pane.
363tmux select-pane -t 2
364
365tmux -2 attach-session -t demo
Ryan Savitskibf67d302019-07-29 14:00:43 +0100366if [[ BACKGROUND -eq 1 ]]; then
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100367 exit 0
Florian Mayerb8433222018-05-15 11:29:18 +0100368fi
Hector Dearmana7c04f82018-03-29 11:31:24 +0100369
Hector Dearman3c4e5c22018-03-29 11:31:55 +0100370reset_tracing
Hector Dearmana7c04f82018-03-29 11:31:24 +0100371
Ryan960da792020-05-05 15:43:20 +0100372TRACE=$TMPDIR/trace
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100373echo -e "\n\x1b[32mPulling trace into $TRACE.protobuf\x1b[0m"
374pull trace "$TRACE.protobuf"
Ryan Savitskibf67d302019-07-29 14:00:43 +0100375
376if [[ SKIP_CONVERTERS -eq 0 ]]; then
377 echo -e "\n\x1b[32mPulling trace into $TRACE.pbtext\x1b[0m"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100378 "$OUT/trace_to_text" text <"$TRACE.protobuf" >"$TRACE.pbtext"
Ryan Savitskibf67d302019-07-29 14:00:43 +0100379 echo -e "\n\x1b[32mPulling trace into $TRACE.json\x1b[0m"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100380 "$OUT/trace_to_text" systrace <"$TRACE.protobuf" >"$TRACE.json"
Ryan Savitskibf67d302019-07-29 14:00:43 +0100381 # Keep this last so it can fail.
382fi