Primiano Tucci | b7cca20 | 2018-01-29 16:30:47 +0000 | [diff] [blame] | 1 | #!/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. |
| 15 | set -e |
Joel Fernandes | 16e8610 | 2019-03-19 13:42:48 -0400 | [diff] [blame] | 16 | CUR_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" |
| 17 | |
| 18 | export PATH="$PATH:$CUR_DIR" |
Primiano Tucci | b7cca20 | 2018-01-29 16:30:47 +0000 | [diff] [blame] | 19 | |
Primiano Tucci | 2ffd1a5 | 2018-03-27 01:01:30 +0100 | [diff] [blame] | 20 | if [ "$TMPDIR" == "" ]; then |
| 21 | TMPDIR=/tmp |
| 22 | fi |
| 23 | |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 24 | function get_gn_value() { |
Hector Dearman | c9c183a | 2018-02-08 12:01:12 +0000 | [diff] [blame] | 25 | local out=$1 |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 26 | local key=$2 |
| 27 | gn args "$out" --list --short | sed -n -e "s/$key = \"\(.*\)\"/\1/p" |
Hector Dearman | c067d41 | 2018-03-16 17:01:41 +0000 | [diff] [blame] | 28 | } |
| 29 | |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 30 | function is_monolithic() { |
Hector Dearman | c067d41 | 2018-03-16 17:01:41 +0000 | [diff] [blame] | 31 | local out=$1 |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 32 | value=$(get_gn_value "$out" "monolithic_binaries") |
| 33 | test "$value" == "true" |
Hector Dearman | c9c183a | 2018-02-08 12:01:12 +0000 | [diff] [blame] | 34 | } |
| 35 | |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 36 | function is_android() { |
| 37 | local out=$1 |
| 38 | value=$(get_gn_value "$out" "target_os") |
| 39 | test "$value" == "android" |
| 40 | } |
| 41 | |
| 42 | function is_gn_target_and_host_value_equal() { |
| 43 | local out=$1 |
| 44 | local key=$2 |
| 45 | local host |
| 46 | local target |
| 47 | host=$(get_gn_value "$out" "host_$key") |
| 48 | target=$(get_gn_value "$out" "target_$key") |
| 49 | [ -z "$target" ] && target="$host" |
| 50 | test "$target" == "$host" |
| 51 | } |
| 52 | |
| 53 | function is_cross_compilation() { |
| 54 | local out=$1 |
| 55 | if is_gn_target_and_host_value_equal "$out" cpu && |
| 56 | is_gn_target_and_host_value_equal "$out" os; then |
| 57 | false |
| 58 | else |
| 59 | true |
| 60 | fi |
| 61 | } |
| 62 | |
| 63 | function is_mac() { |
Primiano Tucci | 676f0cc | 2018-12-03 20:03:26 +0100 | [diff] [blame] | 64 | ! test -d /proc |
| 65 | return $? |
| 66 | } |
| 67 | |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 68 | function tmux_ensure_bash() { |
Hector Dearman | 2407cdd | 2019-06-04 13:21:34 +0100 | [diff] [blame] | 69 | if [[ $SHELL == *"fish" ]]; then |
| 70 | tmux send-keys "bash" Enter |
| 71 | fi |
| 72 | } |
| 73 | |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 74 | function reset_tracing() { |
| 75 | if is_android "$OUT"; then |
Primiano Tucci | 2ffd1a5 | 2018-03-27 01:01:30 +0100 | [diff] [blame] | 76 | adb shell 'echo 0 > /d/tracing/tracing_on' |
Primiano Tucci | 676f0cc | 2018-12-03 20:03:26 +0100 | [diff] [blame] | 77 | elif ! is_mac; then |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 78 | # shellcheck disable=SC2016 |
| 79 | local script=' |
Primiano Tucci | 2ffd1a5 | 2018-03-27 01:01:30 +0100 | [diff] [blame] | 80 | if [ ! -w /sys/kernel/debug ]; then |
| 81 | echo "debugfs not accessible, try sudo chown -R $USER /sys/kernel/debug" |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 82 | sudo chown -R "$USER" /sys/kernel/debug |
Primiano Tucci | 2ffd1a5 | 2018-03-27 01:01:30 +0100 | [diff] [blame] | 83 | fi |
| 84 | |
| 85 | echo 0 > /sys/kernel/debug/tracing/tracing_on |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 86 | ' |
| 87 | |
| 88 | if is_cross_compilation "$OUT"; then |
| 89 | # shellcheck disable=SC2029 |
| 90 | ssh "$TARGET" "sh -c '$script'" |
| 91 | else |
| 92 | sh -c "$script" |
| 93 | fi |
Primiano Tucci | 2ffd1a5 | 2018-03-27 01:01:30 +0100 | [diff] [blame] | 94 | fi |
Hector Dearman | 0ff07c7 | 2018-03-15 09:54:46 +0000 | [diff] [blame] | 95 | } |
| 96 | |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 97 | function adb_supports_push_sync() { |
| 98 | adb --help 2>&1 | grep 'push.*\[--sync\]' >/dev/null 2>&1 |
Hector Dearman | c067d41 | 2018-03-16 17:01:41 +0000 | [diff] [blame] | 99 | } |
| 100 | |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 101 | function push() { |
| 102 | if is_android "$OUT"; then |
Hector Dearman | c067d41 | 2018-03-16 17:01:41 +0000 | [diff] [blame] | 103 | local maybe_sync='' |
| 104 | if adb_supports_push_sync; then |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 105 | maybe_sync='--sync' |
Hector Dearman | c067d41 | 2018-03-16 17:01:41 +0000 | [diff] [blame] | 106 | fi |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 107 | echo adb push $maybe_sync "$1" "$DIR" |
| 108 | adb push $maybe_sync "$1" "$DIR" |
| 109 | elif is_cross_compilation "$OUT"; then |
| 110 | echo scp "$1" "$TARGET:$DIR" |
| 111 | scp "$1" "$TARGET:$DIR" |
Hector Dearman | c067d41 | 2018-03-16 17:01:41 +0000 | [diff] [blame] | 112 | else |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 113 | echo cp "$1" "$DIR" |
| 114 | cp "$1" "$DIR" |
Hector Dearman | 9b89d47 | 2018-02-28 12:07:21 +0000 | [diff] [blame] | 115 | fi |
Hector Dearman | c067d41 | 2018-03-16 17:01:41 +0000 | [diff] [blame] | 116 | } |
| 117 | |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 118 | function pull() { |
| 119 | if is_android "$OUT"; then |
| 120 | echo adb pull "$DIR/$1" "$2" |
| 121 | adb pull "$DIR/$1" "$2" |
| 122 | elif is_cross_compilation "$OUT"; then |
| 123 | echo scp "$TARGET:$DIR/$1" "$2" |
| 124 | scp "$TARGET:$DIR/$1" "$2" |
Hector Dearman | c067d41 | 2018-03-16 17:01:41 +0000 | [diff] [blame] | 125 | else |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 126 | echo mv "$DIR/$1" "$2" |
| 127 | mv "$DIR/$1" "$2" |
Hector Dearman | c067d41 | 2018-03-16 17:01:41 +0000 | [diff] [blame] | 128 | fi |
Hector Dearman | 9b89d47 | 2018-02-28 12:07:21 +0000 | [diff] [blame] | 129 | } |
| 130 | |
Ryan Savitski | bf67d30 | 2019-07-29 14:00:43 +0100 | [diff] [blame] | 131 | BACKGROUND=0 |
| 132 | SKIP_CONVERTERS=0 |
| 133 | TMUX_LAYOUT="even-vertical" |
Florian Mayer | b843322 | 2018-05-15 11:29:18 +0100 | [diff] [blame] | 134 | |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 135 | while getopts "bl:nt:c:C:" o; do |
Florian Mayer | b843322 | 2018-05-15 11:29:18 +0100 | [diff] [blame] | 136 | case "$o" in |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 137 | b) BACKGROUND=1 ;; |
| 138 | l) TMUX_LAYOUT=${OPTARG} ;; |
| 139 | n) SKIP_CONVERTERS=1 ;; |
| 140 | t) TARGET=${OPTARG} ;; |
| 141 | c) CONFIG=${OPTARG} ;; |
| 142 | C) OUT=${OPTARG} ;; |
| 143 | *) |
| 144 | echo "Invalid option $o" |
| 145 | exit |
| 146 | ;; |
Florian Mayer | b843322 | 2018-05-15 11:29:18 +0100 | [diff] [blame] | 147 | esac |
| 148 | done |
| 149 | |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 150 | # Allow out to be passed as argument |
| 151 | shift $((OPTIND - 1)) |
| 152 | OUT="${OUT:-$1}" |
| 153 | |
| 154 | # Warn about invalid output directories |
| 155 | if [ -z "$OUT" ]; then |
| 156 | echo "Usage: $0 [OPTION]... [OUTPUT]" |
| 157 | echo "" |
| 158 | echo "Options:" |
| 159 | echo " -b run in the background" |
| 160 | echo " -l tmux pane layout" |
| 161 | echo " -n skip post-trace convertors" |
| 162 | echo " -t TARGET SSH device target" |
| 163 | echo " -c CONFIG trace configuration file" |
| 164 | echo " -C OUTPUT output directory" |
| 165 | echo "" |
| 166 | echo "Environment variables:" |
| 167 | echo " TARGET SSH device target" |
| 168 | echo " CONFIG trace configuration file" |
| 169 | echo " OUTPUT output directory" |
| 170 | exit 1 |
| 171 | fi |
| 172 | |
| 173 | # Warn about invalid output directories |
Primiano Tucci | b7cca20 | 2018-01-29 16:30:47 +0000 | [diff] [blame] | 174 | if [ ! -f "$OUT/args.gn" ]; then |
| 175 | echo "OUT=$OUT doesn't look like an output directory." |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 176 | echo "Please specify a directory by doing:" |
| 177 | echo " export OUT=out/xxx $0" |
| 178 | exit 1 |
| 179 | fi |
| 180 | |
| 181 | # If we are cross-compiling we need to know the SSH target |
| 182 | if is_cross_compilation "$OUT" && ! ssh -q "$TARGET" exit; then |
| 183 | echo "TARGET=$TARGET doesn't look like a valid SSH target." |
| 184 | echo "Please specify a SSH cross-compilation target by doing:" |
| 185 | echo " export TARGET=<user>@<host> $0" |
Primiano Tucci | b7cca20 | 2018-01-29 16:30:47 +0000 | [diff] [blame] | 186 | exit 1 |
| 187 | fi |
| 188 | |
Hector Dearman | c88a66d | 2018-02-01 14:07:14 +0000 | [diff] [blame] | 189 | # You can set the config to one of the files under test/configs e.g. |
| 190 | # CONFIG=ftrace.cfg or to :test. Defaults to :test. |
| 191 | CONFIG="${CONFIG:-:test}" |
| 192 | |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 193 | if is_android "$OUT"; then |
Hector Dearman | c067d41 | 2018-03-16 17:01:41 +0000 | [diff] [blame] | 194 | DIR=/data/local/tmp |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 195 | elif is_cross_compilation "$OUT"; then |
| 196 | DIR=$(ssh "$TARGET" mktemp -d $TMPDIR/perfetto.XXXXXX) |
Primiano Tucci | 676f0cc | 2018-12-03 20:03:26 +0100 | [diff] [blame] | 197 | elif is_mac; then |
| 198 | DIR=$(mktemp -d $TMPDIR/perfetto.XXXXXX) |
Hector Dearman | c067d41 | 2018-03-16 17:01:41 +0000 | [diff] [blame] | 199 | else |
Primiano Tucci | 2ffd1a5 | 2018-03-27 01:01:30 +0100 | [diff] [blame] | 200 | DIR=$(mktemp -p $TMPDIR -d perfetto.XXXXXX) |
Hector Dearman | c067d41 | 2018-03-16 17:01:41 +0000 | [diff] [blame] | 201 | fi |
| 202 | |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 203 | tools/ninja -C "$OUT" traced traced_probes perfetto trace_to_text test/configs |
Primiano Tucci | b7cca20 | 2018-01-29 16:30:47 +0000 | [diff] [blame] | 204 | |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 205 | push "$OUT/traced" |
| 206 | push "$OUT/traced_probes" |
| 207 | push "$OUT/perfetto" |
Hector Dearman | 0ff07c7 | 2018-03-15 09:54:46 +0000 | [diff] [blame] | 208 | reset_tracing |
Primiano Tucci | b7cca20 | 2018-01-29 16:30:47 +0000 | [diff] [blame] | 209 | |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 210 | if is_android "$OUT"; then |
Primiano Tucci | 301175d | 2019-01-11 10:10:21 +0000 | [diff] [blame] | 211 | PREFIX="PERFETTO_CONSUMER_SOCK_NAME=@perfetto_test_consumer PERFETTO_PRODUCER_SOCK_NAME=@perfetto_test_producer" |
Florian Mayer | b0f0071 | 2018-04-04 16:35:45 +0100 | [diff] [blame] | 212 | else |
| 213 | PREFIX="" |
| 214 | fi |
| 215 | |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 216 | if ! is_monolithic "$OUT"; then |
Florian Mayer | b0f0071 | 2018-04-04 16:35:45 +0100 | [diff] [blame] | 217 | PREFIX="$PREFIX LD_LIBRARY_PATH=$DIR" |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 218 | push "$OUT/libperfetto.so" |
Hector Dearman | c9c183a | 2018-02-08 12:01:12 +0000 | [diff] [blame] | 219 | fi |
| 220 | |
Primiano Tucci | 9ba1d84 | 2018-12-20 17:31:04 +0100 | [diff] [blame] | 221 | CONFIG_DEVICE_PATH="$CONFIG" |
Hector Dearman | b7fa544 | 2018-11-08 18:39:32 +0000 | [diff] [blame] | 222 | CMD_OPTS="" |
| 223 | if [[ "$CONFIG" == *.protobuf ]]; then |
Hector Dearman | 696ff77 | 2019-04-23 18:38:53 +0100 | [diff] [blame] | 224 | CONFIG_DEVICE_PATH="$CONFIG" |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 225 | CONFIG_PATH=$OUT/$CONFIG |
Hector Dearman | c88a66d | 2018-02-01 14:07:14 +0000 | [diff] [blame] | 226 | if [[ ! -f $CONFIG_PATH ]]; then |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 227 | echo "Config \"$CONFIG_PATH\" not known." |
Hector Dearman | c88a66d | 2018-02-01 14:07:14 +0000 | [diff] [blame] | 228 | exit 1 |
| 229 | fi |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 230 | push "$CONFIG_PATH" |
Hector Dearman | b7fa544 | 2018-11-08 18:39:32 +0000 | [diff] [blame] | 231 | elif [[ "$CONFIG" != ":test" ]]; then |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 232 | CONFIG_DEVICE_PATH="$(basename "$CONFIG")" |
Ioannis Ilkos | 482264e | 2019-01-15 10:46:11 +0000 | [diff] [blame] | 233 | CONFIG_PATH=test/configs/$CONFIG |
| 234 | # Check if this is a valid absolute path |
Hector Dearman | b7fa544 | 2018-11-08 18:39:32 +0000 | [diff] [blame] | 235 | if [[ ! -f $CONFIG_PATH ]]; then |
Ioannis Ilkos | 482264e | 2019-01-15 10:46:11 +0000 | [diff] [blame] | 236 | CONFIG_PATH=$CONFIG |
| 237 | if [[ ! -f $CONFIG_PATH ]]; then |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 238 | echo "Config \"$CONFIG\" not known." |
Ioannis Ilkos | 482264e | 2019-01-15 10:46:11 +0000 | [diff] [blame] | 239 | exit 1 |
| 240 | fi |
Hector Dearman | b7fa544 | 2018-11-08 18:39:32 +0000 | [diff] [blame] | 241 | fi |
| 242 | CMD_OPTS="--txt $CMD_OPTS" |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 243 | push "$CONFIG_PATH" |
Hector Dearman | c88a66d | 2018-02-01 14:07:14 +0000 | [diff] [blame] | 244 | fi |
| 245 | |
Florian Mayer | b843322 | 2018-05-15 11:29:18 +0100 | [diff] [blame] | 246 | POSTFIX="" |
| 247 | |
Ryan Savitski | bf67d30 | 2019-07-29 14:00:43 +0100 | [diff] [blame] | 248 | if [[ BACKGROUND -eq 1 ]]; then |
Florian Mayer | b843322 | 2018-05-15 11:29:18 +0100 | [diff] [blame] | 249 | PREFIX="$PREFIX nohup" |
| 250 | POSTFIX=" &> /dev/null &" |
| 251 | fi |
| 252 | |
Primiano Tucci | b7cca20 | 2018-01-29 16:30:47 +0000 | [diff] [blame] | 253 | if tmux has-session -t demo; then |
| 254 | tmux kill-session -t demo |
| 255 | fi |
| 256 | tmux -2 new-session -d -s demo |
| 257 | |
| 258 | if tmux -V | awk '{split($2, ver, "."); if (ver[1] < 2) exit 1 ; else if (ver[1] == 2 && ver[2] < 1) exit 1 }'; then |
| 259 | tmux set-option -g mouse on |
| 260 | else |
| 261 | tmux set-option -g mode-mouse on |
| 262 | tmux set-option -g mouse-resize-pane on |
| 263 | tmux set-option -g mouse-select-pane on |
| 264 | tmux set-option -g mouse-select-window on |
| 265 | fi |
| 266 | |
| 267 | tmux split-window -v |
| 268 | tmux split-window -v |
| 269 | |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 270 | tmux select-layout "${TMUX_LAYOUT}" |
Primiano Tucci | b7cca20 | 2018-01-29 16:30:47 +0000 | [diff] [blame] | 271 | |
| 272 | tmux select-pane -t 0 |
| 273 | tmux send-keys "clear" C-m |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 274 | if is_android "$OUT"; then |
Hector Dearman | c067d41 | 2018-03-16 17:01:41 +0000 | [diff] [blame] | 275 | tmux send-keys "adb shell" C-m |
| 276 | fi |
Primiano Tucci | b7cca20 | 2018-01-29 16:30:47 +0000 | [diff] [blame] | 277 | |
| 278 | tmux select-pane -t 1 |
| 279 | tmux send-keys "clear" C-m |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 280 | if is_android "$OUT"; then |
Hector Dearman | c067d41 | 2018-03-16 17:01:41 +0000 | [diff] [blame] | 281 | tmux send-keys "adb shell" C-m |
| 282 | fi |
Primiano Tucci | b7cca20 | 2018-01-29 16:30:47 +0000 | [diff] [blame] | 283 | |
| 284 | tmux select-pane -t 2 |
| 285 | tmux send-keys "clear" C-m |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 286 | if is_android "$OUT"; then |
Hector Dearman | c067d41 | 2018-03-16 17:01:41 +0000 | [diff] [blame] | 287 | tmux send-keys "adb shell" C-m |
| 288 | fi |
Primiano Tucci | b7cca20 | 2018-01-29 16:30:47 +0000 | [diff] [blame] | 289 | |
Hector Dearman | c88a66d | 2018-02-01 14:07:14 +0000 | [diff] [blame] | 290 | sleep 2 |
Primiano Tucci | b7cca20 | 2018-01-29 16:30:47 +0000 | [diff] [blame] | 291 | |
| 292 | tmux select-pane -t 1 |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 293 | if is_cross_compilation "$OUT"; then |
| 294 | tmux send-keys "ssh $TARGET" Enter |
| 295 | fi |
Hector Dearman | 2407cdd | 2019-06-04 13:21:34 +0100 | [diff] [blame] | 296 | tmux_ensure_bash |
Ryan Savitski | bf67d30 | 2019-07-29 14:00:43 +0100 | [diff] [blame] | 297 | tmux send-keys "PS1='[traced]$ '" Enter |
Primiano Tucci | 9ba1d84 | 2018-12-20 17:31:04 +0100 | [diff] [blame] | 298 | tmux send-keys "cd $DIR" Enter |
Ryan Savitski | bf67d30 | 2019-07-29 14:00:43 +0100 | [diff] [blame] | 299 | tmux send-keys "$PREFIX ./traced 2>&1 | tee traced.log $POSTFIX" Enter |
Primiano Tucci | b7cca20 | 2018-01-29 16:30:47 +0000 | [diff] [blame] | 300 | |
Primiano Tucci | b7cca20 | 2018-01-29 16:30:47 +0000 | [diff] [blame] | 301 | tmux select-pane -t 0 |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 302 | if is_cross_compilation "$OUT"; then |
| 303 | tmux send-keys "ssh $TARGET" Enter |
| 304 | fi |
Hector Dearman | 2407cdd | 2019-06-04 13:21:34 +0100 | [diff] [blame] | 305 | tmux_ensure_bash |
Ryan Savitski | bf67d30 | 2019-07-29 14:00:43 +0100 | [diff] [blame] | 306 | tmux send-keys "PS1='[traced_probes]$ '" Enter |
Primiano Tucci | 9ba1d84 | 2018-12-20 17:31:04 +0100 | [diff] [blame] | 307 | tmux send-keys "cd $DIR" Enter |
Ryan Savitski | bf67d30 | 2019-07-29 14:00:43 +0100 | [diff] [blame] | 308 | tmux send-keys "$PREFIX ./traced_probes 2>&1 | tee traced_probes.log $POSTFIX" Enter |
Primiano Tucci | b7cca20 | 2018-01-29 16:30:47 +0000 | [diff] [blame] | 309 | |
| 310 | tmux select-pane -t 2 |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 311 | if is_cross_compilation "$OUT"; then |
| 312 | tmux send-keys "ssh $TARGET" Enter |
| 313 | fi |
Hector Dearman | 2407cdd | 2019-06-04 13:21:34 +0100 | [diff] [blame] | 314 | tmux_ensure_bash |
Primiano Tucci | 9ba1d84 | 2018-12-20 17:31:04 +0100 | [diff] [blame] | 315 | tmux send-keys "PS1='[consumer]$ '" Enter |
| 316 | tmux send-keys "cd $DIR" Enter |
Ryan Savitski | bf67d30 | 2019-07-29 14:00:43 +0100 | [diff] [blame] | 317 | tmux send-keys "$PREFIX ./perfetto $CMD_OPTS -c $CONFIG_DEVICE_PATH -o trace 2>&1 | tee perfetto.log $POSTFIX" |
Primiano Tucci | b7cca20 | 2018-01-29 16:30:47 +0000 | [diff] [blame] | 318 | |
| 319 | # Select consumer pane. |
| 320 | tmux select-pane -t 2 |
| 321 | |
| 322 | tmux -2 attach-session -t demo |
Ryan Savitski | bf67d30 | 2019-07-29 14:00:43 +0100 | [diff] [blame] | 323 | if [[ BACKGROUND -eq 1 ]]; then |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 324 | exit 0 |
Florian Mayer | b843322 | 2018-05-15 11:29:18 +0100 | [diff] [blame] | 325 | fi |
Hector Dearman | a7c04f8 | 2018-03-29 11:31:24 +0100 | [diff] [blame] | 326 | |
Hector Dearman | 3c4e5c2 | 2018-03-29 11:31:55 +0100 | [diff] [blame] | 327 | reset_tracing |
Hector Dearman | a7c04f8 | 2018-03-29 11:31:24 +0100 | [diff] [blame] | 328 | |
| 329 | TRACE=$HOME/Downloads/trace |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 330 | echo -e "\n\x1b[32mPulling trace into $TRACE.protobuf\x1b[0m" |
| 331 | pull trace "$TRACE.protobuf" |
Ryan Savitski | bf67d30 | 2019-07-29 14:00:43 +0100 | [diff] [blame] | 332 | |
| 333 | if [[ SKIP_CONVERTERS -eq 0 ]]; then |
| 334 | echo -e "\n\x1b[32mPulling trace into $TRACE.pbtext\x1b[0m" |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 335 | "$OUT/trace_to_text" text <"$TRACE.protobuf" >"$TRACE.pbtext" |
Ryan Savitski | bf67d30 | 2019-07-29 14:00:43 +0100 | [diff] [blame] | 336 | echo -e "\n\x1b[32mPulling trace into $TRACE.json\x1b[0m" |
Matthew Clarkson | 7a2a3bd | 2019-09-04 12:27:17 +0100 | [diff] [blame^] | 337 | "$OUT/trace_to_text" systrace <"$TRACE.protobuf" >"$TRACE.json" |
Ryan Savitski | bf67d30 | 2019-07-29 14:00:43 +0100 | [diff] [blame] | 338 | # Keep this last so it can fail. |
| 339 | fi |