OLD | NEW |
---|---|
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 3 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
4 # | 4 # |
5 # Use of this source code is governed by a BSD-style license | 5 # Use of this source code is governed by a BSD-style license |
6 # that can be found in the LICENSE file in the root of the source | 6 # that can be found in the LICENSE file in the root of the source |
7 # tree. An additional intellectual property rights grant can be found | 7 # tree. An additional intellectual property rights grant can be found |
8 # in the file PATENTS. All contributing project authors may | 8 # in the file PATENTS. All contributing project authors may |
9 # be found in the AUTHORS file in the root of the source tree. | 9 # be found in the AUTHORS file in the root of the source tree. |
10 # | 10 # |
(...skipping 14 matching lines...) Expand all Loading... | |
25 # resolve kernel symbols (kallsyms) as well. | 25 # resolve kernel symbols (kallsyms) as well. |
26 # | 26 # |
27 # Example usage: | 27 # Example usage: |
28 # | 28 # |
29 # > . tools-webrtc/android/profiling/perf_setup.sh out/Release | 29 # > . tools-webrtc/android/profiling/perf_setup.sh out/Release |
30 # > perf_record 120 | 30 # > perf_record 120 |
31 # > flame_graph | 31 # > flame_graph |
32 # > plot_flame_graph | 32 # > plot_flame_graph |
33 # > perf_cleanup | 33 # > perf_cleanup |
34 | 34 |
35 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" | 35 if [ -n "$ZSH_VERSION" ]; then |
36 # Running inside zsh. | |
37 SCRIPT_PATH="${(%):-%N}" | |
henrika_webrtc
2017/03/02 17:20:56
I can't say how that works but I trust you :-)
| |
38 else | |
39 # Running inside something else (most likely bash). | |
40 SCRIPT_PATH="${BASH_SOURCE[0]}" | |
41 fi | |
42 SCRIPT_DIR="$(cd $(dirname "$SCRIPT_PATH") && pwd -P)" | |
36 source "${SCRIPT_DIR}/utilities.sh" | 43 source "${SCRIPT_DIR}/utilities.sh" |
37 | 44 |
38 # Root directory for local symbol cache. | 45 # Root directory for local symbol cache. |
39 SYMBOL_DIR="${TMPDIR:-/tmp}/android_symbols" | 46 SYMBOL_DIR="${TMPDIR:-/tmp}/android_symbols" |
40 # Used as a temporary folder on the Android device for data storage. | 47 # Used as a temporary folder on the Android device for data storage. |
41 DEV_TMP_DIR="/data/local/tmp" | 48 DEV_TMP_DIR="/data/local/tmp" |
42 # Relative path to native shared library containing symbols. | 49 # Relative path to native shared library containing symbols. |
43 NATIVE_LIB_PATH="/lib.unstripped/libjingle_peerconnection_so.so" | 50 NATIVE_LIB_PATH="/lib.unstripped/libjingle_peerconnection_so.so" |
44 # Name of application package for the AppRTCMobile demo. | 51 # Name of application package for the AppRTCMobile demo. |
45 APP_NAME="org.appspot.apprtc" | 52 APP_NAME="org.appspot.apprtc" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 return 0 | 96 return 0 |
90 else | 97 else |
91 return 1 | 98 return 1 |
92 fi | 99 fi |
93 } | 100 } |
94 | 101 |
95 # Copies the native shared library from the local host to the symbol cache | 102 # Copies the native shared library from the local host to the symbol cache |
96 # which is used by simpleperf as base when searching for symbols. | 103 # which is used by simpleperf as base when searching for symbols. |
97 function copy_native_shared_library_to_symbol_cache() { | 104 function copy_native_shared_library_to_symbol_cache() { |
98 local arm_lib="arm" | 105 local arm_lib="arm" |
99 if [ "$(native_shared_lib_arch)" == "AArch64" ]; then | 106 if [[ "$(native_shared_lib_arch)" == "AArch64" ]]; then |
100 arm_lib="arm64" | 107 arm_lib="arm64" |
101 fi | 108 fi |
102 for num in 1 2; do | 109 for num in 1 2; do |
103 local dir="${SYMBOL_DIR}/data/app/${APP_NAME}-${num}/lib/${arm_lib}" | 110 local dir="${SYMBOL_DIR}/data/app/${APP_NAME}-${num}/lib/${arm_lib}" |
104 mkdir -p "${dir}" | 111 mkdir -p "${dir}" |
105 cp -u $(native_shared_lib_path) "${dir}" | 112 cp -u $(native_shared_lib_path) "${dir}" |
106 done | 113 done |
107 } | 114 } |
108 | 115 |
109 # Copy kernel symbols from device to symbol cache in tmp. | 116 # Copy kernel symbols from device to symbol cache in tmp. |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 # Given that envsetup is sourced, the adb tool should be accessible but | 355 # Given that envsetup is sourced, the adb tool should be accessible but |
349 # do one extra check just in case. | 356 # do one extra check just in case. |
350 local adb_full_path=$(which adb); | 357 local adb_full_path=$(which adb); |
351 if [[ ! -x "${adb_full_path}" ]]; then | 358 if [[ ! -x "${adb_full_path}" ]]; then |
352 error "unable to find the Android Debug Bridge (adb) tool" | 359 error "unable to find the Android Debug Bridge (adb) tool" |
353 return 1 | 360 return 1 |
354 fi | 361 fi |
355 ok "adb tool is working" | 362 ok "adb tool is working" |
356 | 363 |
357 # Exactly one Android device must be connected. | 364 # Exactly one Android device must be connected. |
358 if [[ ! one_device_connected ]]; then | 365 if ! one_device_connected; then |
359 error "one device must be connected" | 366 error "one device must be connected" |
360 return 1 | 367 return 1 |
361 fi | 368 fi |
362 ok "one device is connected via USB" | 369 ok "one device is connected via USB" |
363 | 370 |
364 # Restart adb with root permissions if needed. | 371 # Restart adb with root permissions if needed. |
365 if image_is_root && adb_has_no_root_permissions; then | 372 if image_is_root && adb_has_no_root_permissions; then |
366 adb root | 373 adb root |
367 ok "adb is running as root" | 374 ok "adb is running as root" |
368 fi | 375 fi |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
454 | 461 |
455 cleanup | 462 cleanup |
456 | 463 |
457 return 0 | 464 return 0 |
458 } | 465 } |
459 | 466 |
460 # Only call main() if proper input parameter has been provided. | 467 # Only call main() if proper input parameter has been provided. |
461 if is_set $BUILD_DIR; then | 468 if is_set $BUILD_DIR; then |
462 main "$@" | 469 main "$@" |
463 fi | 470 fi |
OLD | NEW |