| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 # | 2 # |
| 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 # | 6 # |
| 7 | 7 |
| 8 # A generic script used to attach to a running Chromium process and | 8 # A generic script used to attach to a running Chromium process and |
| 9 # debug it. Most users should not use this directly, but one of the | 9 # debug it. Most users should not use this directly, but one of the |
| 10 # wrapper scripts like adb_gdb_content_shell | 10 # wrapper scripts like adb_gdb_content_shell |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 PID= | 95 PID= |
| 96 PORT= | 96 PORT= |
| 97 PRIVILEGED= | 97 PRIVILEGED= |
| 98 PRIVILEGED_INDEX= | 98 PRIVILEGED_INDEX= |
| 99 PROGRAM_NAME="activity" | 99 PROGRAM_NAME="activity" |
| 100 PULL_LIBS= | 100 PULL_LIBS= |
| 101 PULL_LIBS_DIR= | 101 PULL_LIBS_DIR= |
| 102 SANDBOXED= | 102 SANDBOXED= |
| 103 SANDBOXED_INDEX= | 103 SANDBOXED_INDEX= |
| 104 START= | 104 START= |
| 105 START_URL= |
| 105 ATTACH_DELAY=1 | 106 ATTACH_DELAY=1 |
| 106 SU_PREFIX= | 107 SU_PREFIX= |
| 107 SYMBOL_DIR= | 108 SYMBOL_DIR= |
| 108 TARGET_ARCH= | 109 TARGET_ARCH= |
| 109 TOOLCHAIN= | 110 TOOLCHAIN= |
| 110 VERBOSE=0 | 111 VERBOSE=0 |
| 111 | 112 |
| 112 for opt; do | 113 for opt; do |
| 113 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') | 114 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') |
| 114 case $opt in | 115 case $opt in |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 --sandboxed) | 168 --sandboxed) |
| 168 SANDBOXED=true | 169 SANDBOXED=true |
| 169 ;; | 170 ;; |
| 170 --sandboxed=*) | 171 --sandboxed=*) |
| 171 SANDBOXED=true | 172 SANDBOXED=true |
| 172 SANDBOXED_INDEX=$optarg | 173 SANDBOXED_INDEX=$optarg |
| 173 ;; | 174 ;; |
| 174 --script=*) | 175 --script=*) |
| 175 GDBINIT=$optarg | 176 GDBINIT=$optarg |
| 176 ;; | 177 ;; |
| 178 --start=*) |
| 179 START_URL=$optarg |
| 180 ;& # fallthrough |
| 177 --start) | 181 --start) |
| 178 START=true | 182 START=true |
| 179 ;; | 183 ;; |
| 180 --attach-delay=*) | 184 --attach-delay=*) |
| 181 ATTACH_DELAY=$optarg | 185 ATTACH_DELAY=$optarg |
| 182 ;; | 186 ;; |
| 183 --su-prefix=*) | 187 --su-prefix=*) |
| 184 SU_PREFIX=$optarg | 188 SU_PREFIX=$optarg |
| 185 ;; | 189 ;; |
| 186 --symbol-dir=*) | 190 --symbol-dir=*) |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 --sandboxed Debug first sandboxed process we find. | 305 --sandboxed Debug first sandboxed process we find. |
| 302 --sandboxed=<num> Debug specific sandboxed process. | 306 --sandboxed=<num> Debug specific sandboxed process. |
| 303 --symbol-dir=<path> Specify directory with symbol shared libraries. | 307 --symbol-dir=<path> Specify directory with symbol shared libraries. |
| 304 --output-directory=<path> Specify the output directory (e.g. "out/Debug"). | 308 --output-directory=<path> Specify the output directory (e.g. "out/Debug"). |
| 305 --package-name=<name> Specify package name (alternative to 1st argument). | 309 --package-name=<name> Specify package name (alternative to 1st argument). |
| 306 --privileged Debug first privileged process we find. | 310 --privileged Debug first privileged process we find. |
| 307 --privileged=<num> Debug specific privileged process. | 311 --privileged=<num> Debug specific privileged process. |
| 308 --program-name=<name> Specify program name (cosmetic only). | 312 --program-name=<name> Specify program name (cosmetic only). |
| 309 --pid=<pid> Specify application process pid. | 313 --pid=<pid> Specify application process pid. |
| 310 --force Kill any previous debugging session, if any. | 314 --force Kill any previous debugging session, if any. |
| 311 --start Start package's activity on device. | 315 --start[=<url>] Start package's activity on device. |
| 312 --attach-delay=<num> Seconds to wait for gdbserver to attach to the | 316 --attach-delay=<num> Seconds to wait for gdbserver to attach to the |
| 313 remote process before starting gdb. Default 1. | 317 remote process before starting gdb. Default 1. |
| 314 <num> may be a float if your sleep(1) supports it. | 318 <num> may be a float if your sleep(1) supports it. |
| 315 --ui Use gdbtui instead of gdb | 319 --ui Use gdbtui instead of gdb |
| 316 --activity=<name> Activity name for --start [$DEFAULT_ACTIVITY]. | 320 --activity=<name> Activity name for --start [$DEFAULT_ACTIVITY]. |
| 317 --annotate=<num> Enable gdb annotation. | 321 --annotate=<num> Enable gdb annotation. |
| 318 --script=<file> Specify extra GDB init script. | 322 --script=<file> Specify extra GDB init script. |
| 319 | 323 |
| 320 --gdbserver=<file> Specify target gdbserver binary. | 324 --gdbserver=<file> Specify target gdbserver binary. |
| 321 --gdb=<file> Specify host gdb client binary. | 325 --gdb=<file> Specify host gdb client binary. |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 if [ "$FORCE" ]; then | 679 if [ "$FORCE" ]; then |
| 676 GDBSERVER_PIDS=$(adb_shell ps | awk '$9 ~ /gdbserver/ { print $2; }') | 680 GDBSERVER_PIDS=$(adb_shell ps | awk '$9 ~ /gdbserver/ { print $2; }') |
| 677 for GDB_PID in $GDBSERVER_PIDS; do | 681 for GDB_PID in $GDBSERVER_PIDS; do |
| 678 log "Killing previous gdbserver (PID=$GDB_PID)" | 682 log "Killing previous gdbserver (PID=$GDB_PID)" |
| 679 adb_shell kill -9 $GDB_PID | 683 adb_shell kill -9 $GDB_PID |
| 680 done | 684 done |
| 681 fi | 685 fi |
| 682 | 686 |
| 683 if [ "$START" ]; then | 687 if [ "$START" ]; then |
| 684 log "Starting $PROGRAM_NAME on device." | 688 log "Starting $PROGRAM_NAME on device." |
| 685 adb_shell am start -n $PACKAGE_NAME/$ACTIVITY 2>/dev/null | 689 adb_shell am start -n $PACKAGE_NAME/$ACTIVITY ${START_URL:+-d "$START_URL"} |
| 686 adb_shell ps | grep -q $PACKAGE_NAME | 690 adb_shell ps | grep -q $PACKAGE_NAME |
| 687 fail_panic "Could not start $PROGRAM_NAME on device. Are you sure the \ | 691 fail_panic "Could not start $PROGRAM_NAME on device. Are you sure the \ |
| 688 package is installed?" | 692 package is installed?" |
| 689 fi | 693 fi |
| 690 | 694 |
| 691 # Return the timestamp of a given file, as number of seconds since epoch. | 695 # Return the timestamp of a given file, as number of seconds since epoch. |
| 692 # $1: file path | 696 # $1: file path |
| 693 # Out: file timestamp | 697 # Out: file timestamp |
| 694 get_file_timestamp () { | 698 get_file_timestamp () { |
| 695 stat -c %Y "$1" 2>/dev/null | 699 stat -c %Y "$1" 2>/dev/null |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 | 1022 |
| 1019 if [ "$VERBOSE" -gt 0 ]; then | 1023 if [ "$VERBOSE" -gt 0 ]; then |
| 1020 echo "### START $COMMANDS" | 1024 echo "### START $COMMANDS" |
| 1021 cat $COMMANDS | 1025 cat $COMMANDS |
| 1022 echo "### END $COMMANDS" | 1026 echo "### END $COMMANDS" |
| 1023 fi | 1027 fi |
| 1024 | 1028 |
| 1025 log "Launching gdb client: $GDB $GDB_ARGS -x $COMMANDS" | 1029 log "Launching gdb client: $GDB $GDB_ARGS -x $COMMANDS" |
| 1026 $GDB $GDB_ARGS -x $COMMANDS && | 1030 $GDB $GDB_ARGS -x $COMMANDS && |
| 1027 rm -f "$GDBSERVER_PIDFILE" | 1031 rm -f "$GDBSERVER_PIDFILE" |
| OLD | NEW |