blob: bc71ca371834cacf78a5d2ed5dc26b8a4df0afaf [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
Lalit Magantidb22f372021-11-02 20:18:00 +000059 # Newer versions of Android don't have debugfs mounted at all
60 # anymore so use /sys/kernel/tracing if /d/tracing doesn't exist
Lalit Maganti7030e782021-11-08 13:12:42 +000061 adb shell 'test -d /sys/kernel/tracing && echo 0 > /sys/kernel/tracing/tracing_on || echo 0 > /sys/kernel/debug/tracing/tracing_on'
Primiano Tucci676f0cc2018-12-03 20:03:26 +010062 elif ! is_mac; then
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010063 # shellcheck disable=SC2016
64 local script='
Primiano Tucci2ffd1a52018-03-27 01:01:30 +010065 if [ ! -w /sys/kernel/debug ]; then
66 echo "debugfs not accessible, try sudo chown -R $USER /sys/kernel/debug"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010067 sudo chown -R "$USER" /sys/kernel/debug
Primiano Tucci2ffd1a52018-03-27 01:01:30 +010068 fi
69
70 echo 0 > /sys/kernel/debug/tracing/tracing_on
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010071 '
72
Ryan Savitski6cadb872019-09-06 17:25:15 +010073 if is_ssh_target; then
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010074 # shellcheck disable=SC2029
Matthew Clarkson83987d22019-10-03 17:30:53 +010075 ssh -t "$SSH_TARGET" "sh -c '$script'"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010076 else
77 sh -c "$script"
78 fi
Primiano Tucci2ffd1a52018-03-27 01:01:30 +010079 fi
Hector Dearman0ff07c72018-03-15 09:54:46 +000080}
81
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010082function adb_supports_push_sync() {
83 adb --help 2>&1 | grep 'push.*\[--sync\]' >/dev/null 2>&1
Hector Dearmanc067d412018-03-16 17:01:41 +000084}
85
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010086function push() {
87 if is_android "$OUT"; then
Hector Dearmanc067d412018-03-16 17:01:41 +000088 local maybe_sync=''
89 if adb_supports_push_sync; then
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010090 maybe_sync='--sync'
Hector Dearmanc067d412018-03-16 17:01:41 +000091 fi
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010092 echo adb push $maybe_sync "$1" "$DIR"
93 adb push $maybe_sync "$1" "$DIR"
Ryan Savitski6cadb872019-09-06 17:25:15 +010094 elif is_ssh_target; then
95 echo scp "$1" "$SSH_TARGET:$DIR"
96 scp "$1" "$SSH_TARGET:$DIR"
Hector Dearmanc067d412018-03-16 17:01:41 +000097 else
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +010098 echo cp "$1" "$DIR"
99 cp "$1" "$DIR"
Hector Dearman9b89d472018-02-28 12:07:21 +0000100 fi
Hector Dearmanc067d412018-03-16 17:01:41 +0000101}
102
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100103function pull() {
104 if is_android "$OUT"; then
105 echo adb pull "$DIR/$1" "$2"
106 adb pull "$DIR/$1" "$2"
Ryan Savitski6cadb872019-09-06 17:25:15 +0100107 elif is_ssh_target; then
108 echo scp "$SSH_TARGET:$DIR/$1" "$2"
109 scp "$SSH_TARGET:$DIR/$1" "$2"
Hector Dearmanc067d412018-03-16 17:01:41 +0000110 else
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100111 echo mv "$DIR/$1" "$2"
112 mv "$DIR/$1" "$2"
Hector Dearmanc067d412018-03-16 17:01:41 +0000113 fi
Hector Dearman9b89d472018-02-28 12:07:21 +0000114}
115
Ryan Savitskibf67d302019-07-29 14:00:43 +0100116BACKGROUND=0
117SKIP_CONVERTERS=0
118TMUX_LAYOUT="even-vertical"
Ryan Savitski6cadb872019-09-06 17:25:15 +0100119CPU_MASK=""
Florian Mayerb8433222018-05-15 11:29:18 +0100120
Matthew Clarkson9bace992019-10-17 10:30:27 +0100121while getopts "bl:nt:c:C:z:s:" o; do
Florian Mayerb8433222018-05-15 11:29:18 +0100122 case "$o" in
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100123 b) BACKGROUND=1 ;;
124 l) TMUX_LAYOUT=${OPTARG} ;;
125 n) SKIP_CONVERTERS=1 ;;
Ryan Savitski6cadb872019-09-06 17:25:15 +0100126 t) SSH_TARGET=${OPTARG} ;;
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100127 c) CONFIG=${OPTARG} ;;
128 C) OUT=${OPTARG} ;;
Ryan Savitski6cadb872019-09-06 17:25:15 +0100129 z) CPU_MASK=${OPTARG} ;;
Matthew Clarkson9bace992019-10-17 10:30:27 +0100130 s) SCRIPT=${OPTARG} ;;
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100131 *)
Matthew Clarkson9bace992019-10-17 10:30:27 +0100132 echo >&2 "Invalid option $o"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100133 exit
134 ;;
Florian Mayerb8433222018-05-15 11:29:18 +0100135 esac
136done
137
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100138# Allow out to be passed as argument
139shift $((OPTIND - 1))
140OUT="${OUT:-$1}"
141
Matthew Clarkson83987d22019-10-03 17:30:53 +0100142# Provide useful usage information
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100143if [ -z "$OUT" ]; then
144 echo "Usage: $0 [OPTION]... [OUTPUT]"
145 echo ""
146 echo "Options:"
147 echo " -b run in the background"
Ryan Savitski6cadb872019-09-06 17:25:15 +0100148 echo " -l LAYOUT tmux pane layout"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100149 echo " -n skip post-trace convertors"
150 echo " -t TARGET SSH device target"
151 echo " -c CONFIG trace configuration file"
152 echo " -C OUTPUT output directory"
Ryan Savitski6cadb872019-09-06 17:25:15 +0100153 echo " -z MASK constrain binaries to given cpu mask (taskset syntax)"
Matthew Clarkson9bace992019-10-17 10:30:27 +0100154 echo " -s SCRIPT a script to put into a tmux pane"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100155 echo ""
156 echo "Environment variables:"
Ryan Savitski6cadb872019-09-06 17:25:15 +0100157 echo " SSH_TARGET SSH device target"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100158 echo " CONFIG trace configuration file"
Ryan Savitski6cadb872019-09-06 17:25:15 +0100159 echo " OUT output directory"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100160 exit 1
161fi
162
163# Warn about invalid output directories
Primiano Tuccib7cca202018-01-29 16:30:47 +0000164if [ ! -f "$OUT/args.gn" ]; then
Matthew Clarkson9bace992019-10-17 10:30:27 +0100165 echo >&2 "OUT=$OUT doesn't look like an output directory."
166 echo >&2 "Please specify a directory by doing:"
167 echo >&2 " export OUT=out/xxx $0"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100168 exit 1
169fi
170
Matthew Clarkson83987d22019-10-03 17:30:53 +0100171# Check SSH target is valid
Ryan Savitski6cadb872019-09-06 17:25:15 +0100172if is_ssh_target && ! ssh -q "$SSH_TARGET" exit; then
Matthew Clarkson9bace992019-10-17 10:30:27 +0100173 echo >&2 "SSH_TARGET=$SSH_TARGET doesn't look like a valid SSH target."
174 echo >&2 "Please specify a SSH cross-compilation target by doing:"
175 echo >&2 " export SSH_TARGET=<user>@<host> $0"
Matthew Clarkson83987d22019-10-03 17:30:53 +0100176 exit 1
177fi
178
Matthew Clarkson9bace992019-10-17 10:30:27 +0100179if ! builtin type -P tmux &>/dev/null; then
180 echo >&2 "tmux not found"
Primiano Tuccib7cca202018-01-29 16:30:47 +0000181 exit 1
182fi
183
Hector Dearmanc88a66d2018-02-01 14:07:14 +0000184# You can set the config to one of the files under test/configs e.g.
185# CONFIG=ftrace.cfg or to :test. Defaults to :test.
186CONFIG="${CONFIG:-:test}"
187
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100188if is_android "$OUT"; then
Hector Dearmanc067d412018-03-16 17:01:41 +0000189 DIR=/data/local/tmp
Ryan Savitski6cadb872019-09-06 17:25:15 +0100190elif is_ssh_target; then
191 DIR=$(ssh "$SSH_TARGET" mktemp -d $TMPDIR/perfetto.XXXXXX)
Primiano Tucci676f0cc2018-12-03 20:03:26 +0100192elif is_mac; then
193 DIR=$(mktemp -d $TMPDIR/perfetto.XXXXXX)
Hector Dearmanc067d412018-03-16 17:01:41 +0000194else
Primiano Tucci2ffd1a52018-03-27 01:01:30 +0100195 DIR=$(mktemp -p $TMPDIR -d perfetto.XXXXXX)
Hector Dearmanc067d412018-03-16 17:01:41 +0000196fi
197
Ryan960da792020-05-05 15:43:20 +0100198# (re)build the binaries
199BUILD_TARGETS=(traced traced_probes perfetto test/configs)
200if [[ SKIP_CONVERTERS -eq 0 ]]; then
201 BUILD_TARGETS+=(trace_to_text)
202fi
203
204"$SCRIPT_DIR/ninja" -C "$OUT" ${BUILD_TARGETS[*]}
Primiano Tuccib7cca202018-01-29 16:30:47 +0000205
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100206push "$OUT/traced"
207push "$OUT/traced_probes"
208push "$OUT/perfetto"
Hector Dearman0ff07c72018-03-15 09:54:46 +0000209reset_tracing
Primiano Tuccib7cca202018-01-29 16:30:47 +0000210
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100211if is_android "$OUT"; then
Primiano Tucci301175d2019-01-11 10:10:21 +0000212 PREFIX="PERFETTO_CONSUMER_SOCK_NAME=@perfetto_test_consumer PERFETTO_PRODUCER_SOCK_NAME=@perfetto_test_producer"
Florian Mayerb0f00712018-04-04 16:35:45 +0100213else
214 PREFIX=""
215fi
216
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100217if ! is_monolithic "$OUT"; then
Florian Mayerb0f00712018-04-04 16:35:45 +0100218 PREFIX="$PREFIX LD_LIBRARY_PATH=$DIR"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100219 push "$OUT/libperfetto.so"
Hector Dearmanc9c183a2018-02-08 12:01:12 +0000220fi
221
Primiano Tucci9ba1d842018-12-20 17:31:04 +0100222CONFIG_DEVICE_PATH="$CONFIG"
Hector Dearmanb7fa5442018-11-08 18:39:32 +0000223CMD_OPTS=""
Ryan960da792020-05-05 15:43:20 +0100224# Shorthand for using serialized test configs.
Hector Dearmanb7fa5442018-11-08 18:39:32 +0000225if [[ "$CONFIG" == *.protobuf ]]; then
Hector Dearman696ff772019-04-23 18:38:53 +0100226 CONFIG_DEVICE_PATH="$CONFIG"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100227 CONFIG_PATH=$OUT/$CONFIG
Hector Dearmanc88a66d2018-02-01 14:07:14 +0000228 if [[ ! -f $CONFIG_PATH ]]; then
Matthew Clarkson9bace992019-10-17 10:30:27 +0100229 echo >&2 "Config \"$CONFIG_PATH\" not known."
Hector Dearmanc88a66d2018-02-01 14:07:14 +0000230 exit 1
231 fi
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100232 push "$CONFIG_PATH"
Hector Dearmanb7fa5442018-11-08 18:39:32 +0000233elif [[ "$CONFIG" != ":test" ]]; then
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100234 CONFIG_DEVICE_PATH="$(basename "$CONFIG")"
Ryan960da792020-05-05 15:43:20 +0100235 CONFIG_PATH=$CONFIG
236 # If path isn't valid, assume it's a name of a test config.
Hector Dearmanb7fa5442018-11-08 18:39:32 +0000237 if [[ ! -f $CONFIG_PATH ]]; then
Ryan960da792020-05-05 15:43:20 +0100238 CONFIG_PATH=test/configs/$CONFIG
Ioannis Ilkos482264e2019-01-15 10:46:11 +0000239 if [[ ! -f $CONFIG_PATH ]]; then
Matthew Clarkson9bace992019-10-17 10:30:27 +0100240 echo >&2 "Config \"$CONFIG\" not known."
Ioannis Ilkos482264e2019-01-15 10:46:11 +0000241 exit 1
242 fi
Hector Dearmanb7fa5442018-11-08 18:39:32 +0000243 fi
244 CMD_OPTS="--txt $CMD_OPTS"
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100245 push "$CONFIG_PATH"
Hector Dearmanc88a66d2018-02-01 14:07:14 +0000246fi
247
Matthew Clarkson9bace992019-10-17 10:30:27 +0100248if [[ -f "$SCRIPT" ]]; then
249 push "$SCRIPT"
250fi
251
Florian Mayerb8433222018-05-15 11:29:18 +0100252POSTFIX=""
253
Ryan Savitski6cadb872019-09-06 17:25:15 +0100254if [[ -n "$CPU_MASK" ]]; then
255 PREFIX="$PREFIX taskset $CPU_MASK"
256fi
257
Ryan Savitskibf67d302019-07-29 14:00:43 +0100258if [[ BACKGROUND -eq 1 ]]; then
Florian Mayerb8433222018-05-15 11:29:18 +0100259 PREFIX="$PREFIX nohup"
260 POSTFIX=" &> /dev/null &"
261fi
262
Primiano Tuccib7cca202018-01-29 16:30:47 +0000263if tmux has-session -t demo; then
264 tmux kill-session -t demo
265fi
266tmux -2 new-session -d -s demo
267
Hector Dearman28583e22020-06-08 19:22:45 +0100268if [ ! -z "$ANDROID_ADB_SERVER_PORT" ]; then
269 tmux set-environment -t demo ANDROID_ADB_SERVER_PORT $ANDROID_ADB_SERVER_PORT
270fi
271
Primiano Tuccib7cca202018-01-29 16:30:47 +0000272if tmux -V | awk '{split($2, ver, "."); if (ver[1] < 2) exit 1 ; else if (ver[1] == 2 && ver[2] < 1) exit 1 }'; then
273 tmux set-option -g mouse on
274else
275 tmux set-option -g mode-mouse on
276 tmux set-option -g mouse-resize-pane on
277 tmux set-option -g mouse-select-pane on
278 tmux set-option -g mouse-select-window on
279fi
280
281tmux split-window -v
282tmux split-window -v
283
Matthew Clarkson9bace992019-10-17 10:30:27 +0100284if [[ -n "$SCRIPT" ]]; then
285 tmux split-window -v
286fi
287
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100288tmux select-layout "${TMUX_LAYOUT}"
Primiano Tuccib7cca202018-01-29 16:30:47 +0000289
290tmux select-pane -t 0
291tmux send-keys "clear" C-m
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100292if is_android "$OUT"; then
Hector Dearmanc067d412018-03-16 17:01:41 +0000293 tmux send-keys "adb shell" C-m
294fi
Primiano Tuccib7cca202018-01-29 16:30:47 +0000295
296tmux select-pane -t 1
297tmux send-keys "clear" C-m
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100298if is_android "$OUT"; then
Hector Dearmanc067d412018-03-16 17:01:41 +0000299 tmux send-keys "adb shell" C-m
300fi
Primiano Tuccib7cca202018-01-29 16:30:47 +0000301
302tmux select-pane -t 2
303tmux send-keys "clear" C-m
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100304if is_android "$OUT"; then
Hector Dearmanc067d412018-03-16 17:01:41 +0000305 tmux send-keys "adb shell" C-m
306fi
Primiano Tuccib7cca202018-01-29 16:30:47 +0000307
Matthew Clarkson9bace992019-10-17 10:30:27 +0100308if [[ -n "$SCRIPT" ]]; then
309 tmux select-pane -t 3
310 tmux send-keys "clear" C-m
Matthew Clarksonf8e61102019-10-28 13:26:50 +0000311 if is_android "$OUT"; then
312 tmux send-keys "adb shell" C-m
313 fi
Matthew Clarkson9bace992019-10-17 10:30:27 +0100314fi
315
Hector Dearmanc88a66d2018-02-01 14:07:14 +0000316sleep 2
Primiano Tuccib7cca202018-01-29 16:30:47 +0000317
318tmux select-pane -t 1
Ryan Savitski6cadb872019-09-06 17:25:15 +0100319if is_ssh_target; then
320 tmux send-keys "ssh $SSH_TARGET" Enter
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100321fi
Hector Dearman2407cdd2019-06-04 13:21:34 +0100322tmux_ensure_bash
Ryan Savitskibf67d302019-07-29 14:00:43 +0100323tmux send-keys "PS1='[traced]$ '" Enter
Primiano Tucci9ba1d842018-12-20 17:31:04 +0100324tmux send-keys "cd $DIR" Enter
Matthew Clarkson9bace992019-10-17 10:30:27 +0100325tmux send-keys "clear" C-m
Ryan Savitski6cadb872019-09-06 17:25:15 +0100326tmux send-keys "$PREFIX ./traced $POSTFIX" Enter
Primiano Tuccib7cca202018-01-29 16:30:47 +0000327
Primiano Tuccib7cca202018-01-29 16:30:47 +0000328tmux select-pane -t 0
Ryan Savitski6cadb872019-09-06 17:25:15 +0100329if is_ssh_target; then
330 tmux send-keys "ssh $SSH_TARGET" Enter
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100331fi
Hector Dearman2407cdd2019-06-04 13:21:34 +0100332tmux_ensure_bash
Ryan Savitskibf67d302019-07-29 14:00:43 +0100333tmux send-keys "PS1='[traced_probes]$ '" Enter
Primiano Tucci9ba1d842018-12-20 17:31:04 +0100334tmux send-keys "cd $DIR" Enter
Matthew Clarkson9bace992019-10-17 10:30:27 +0100335tmux send-keys "clear" C-m
Ryan Savitski6cadb872019-09-06 17:25:15 +0100336tmux send-keys "$PREFIX ./traced_probes $POSTFIX" Enter
Primiano Tuccib7cca202018-01-29 16:30:47 +0000337
338tmux select-pane -t 2
Ryan Savitski6cadb872019-09-06 17:25:15 +0100339if is_ssh_target; then
340 tmux send-keys "ssh $SSH_TARGET" Enter
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100341fi
Hector Dearman2407cdd2019-06-04 13:21:34 +0100342tmux_ensure_bash
Primiano Tucci9ba1d842018-12-20 17:31:04 +0100343tmux send-keys "PS1='[consumer]$ '" Enter
344tmux send-keys "cd $DIR" Enter
Matthew Clarkson9bace992019-10-17 10:30:27 +0100345tmux send-keys "clear" C-m
Ryan Savitski6cadb872019-09-06 17:25:15 +0100346tmux send-keys "$PREFIX ./perfetto $CMD_OPTS -c $CONFIG_DEVICE_PATH -o trace $POSTFIX"
Primiano Tuccib7cca202018-01-29 16:30:47 +0000347
Matthew Clarkson9bace992019-10-17 10:30:27 +0100348if [[ -n "$SCRIPT" ]]; then
349 tmux select-pane -t 3
350 if is_ssh_target; then
351 tmux send-keys "ssh $SSH_TARGET" Enter
352 fi
353 tmux_ensure_bash
354 tmux send-keys "PS1='[script]$ '" Enter
355 tmux send-keys "cd $DIR" Enter
356 tmux send-keys "clear" C-m
Matthew Clarksonf8e61102019-10-28 13:26:50 +0000357 if [[ -f "$SCRIPT" ]]; then
358 tmux send-keys "./$(basename "$SCRIPT")"
359 else
360 tmux send-keys "$SCRIPT"
361 fi
Matthew Clarkson9bace992019-10-17 10:30:27 +0100362fi
363
Primiano Tuccib7cca202018-01-29 16:30:47 +0000364# Select consumer pane.
365tmux select-pane -t 2
366
367tmux -2 attach-session -t demo
Ryan Savitskibf67d302019-07-29 14:00:43 +0100368if [[ BACKGROUND -eq 1 ]]; then
Matthew Clarkson7a2a3bd2019-09-04 12:27:17 +0100369 exit 0
Florian Mayerb8433222018-05-15 11:29:18 +0100370fi
Hector Dearmana7c04f82018-03-29 11:31:24 +0100371
Hector Dearman3c4e5c22018-03-29 11:31:55 +0100372reset_tracing
Hector Dearmana7c04f82018-03-29 11:31:24 +0100373
Ryan960da792020-05-05 15:43:20 +0100374TRACE=$TMPDIR/trace
Primiano Tucci03ad8aa2021-06-30 09:55:37 +0100375echo -e "\n\x1b[32mPulling trace into $TRACE.perfetto-trace\x1b[0m"
376pull trace "$TRACE.perfetto-trace"
Ryan Savitskibf67d302019-07-29 14:00:43 +0100377
378if [[ SKIP_CONVERTERS -eq 0 ]]; then
379 echo -e "\n\x1b[32mPulling trace into $TRACE.pbtext\x1b[0m"
Primiano Tucci03ad8aa2021-06-30 09:55:37 +0100380 "$OUT/trace_to_text" text <"$TRACE.perfetto-trace" >"$TRACE.pbtext"
Ryan Savitskibf67d302019-07-29 14:00:43 +0100381 echo -e "\n\x1b[32mPulling trace into $TRACE.json\x1b[0m"
Primiano Tucci03ad8aa2021-06-30 09:55:37 +0100382 "$OUT/trace_to_text" systrace <"$TRACE.perfetto-trace" >"$TRACE.json"
Ryan Savitskibf67d302019-07-29 14:00:43 +0100383 # Keep this last so it can fail.
384fi