| 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 | 
| 11 # | 11 # | 
| 12 # Use --help to print full usage instructions. | 12 # Use --help to print full usage instructions. | 
| 13 # | 13 # | 
| 14 | 14 | 
| 15 PROGNAME=$(basename "$0") | 15 PROGNAME=$(basename "$0") | 
| 16 PROGDIR=$(dirname "$0") | 16 PROGDIR=$(dirname "$0") | 
| 17 | 17 | 
| 18 # Location of Chromium-top-level sources. | 18 # Location of Chromium-top-level sources. | 
| 19 CHROMIUM_SRC=$(cd "$PROGDIR"/../.. >/dev/null && pwd 2>/dev/null) | 19 CHROMIUM_SRC=$(cd "$PROGDIR"/../.. >/dev/null && pwd 2>/dev/null) | 
| 20 | 20 | 
| 21 # Location of Chromium out/ directory. | 21 # Location of Chromium out/ directory. | 
| 22 if [ -z "$CHROMIUM_OUT_DIR" ]; then | 22 if [ -z "$CHROMIUM_OUT_DIR" ]; then | 
| 23   CHROMIUM_OUT_DIR=out | 23   CHROMIUM_OUT_DIR=out | 
| 24 fi | 24 fi | 
| 25 | 25 | 
| 26 TMPDIR= | 26 TMPDIR= | 
| 27 GDBSERVER_PIDFILE= | 27 GDBSERVER_PIDFILE= | 
| 28 TARGET_GDBSERVER= | 28 TARGET_GDBSERVER= | 
|  | 29 COMMAND_PREFIX= | 
| 29 | 30 | 
| 30 clean_exit () { | 31 clean_exit () { | 
| 31   if [ "$TMPDIR" ]; then | 32   if [ "$TMPDIR" ]; then | 
| 32     GDBSERVER_PID=$(cat $GDBSERVER_PIDFILE 2>/dev/null) | 33     GDBSERVER_PID=$(cat $GDBSERVER_PIDFILE 2>/dev/null) | 
| 33     if [ "$GDBSERVER_PID" ]; then | 34     if [ "$GDBSERVER_PID" ]; then | 
| 34       log "Killing background gdbserver process: $GDBSERVER_PID" | 35       log "Killing background gdbserver process: $GDBSERVER_PID" | 
| 35       kill -9 $GDBSERVER_PID >/dev/null 2>&1 | 36       kill -9 $GDBSERVER_PID >/dev/null 2>&1 | 
| 36     fi | 37     fi | 
| 37     if [ "$TARGET_GDBSERVER" ]; then | 38     if [ "$TARGET_GDBSERVER" ]; then | 
| 38       log "Removing target gdbserver binary: $TARGET_GDBSERVER." | 39       log "Removing target gdbserver binary: $TARGET_GDBSERVER." | 
| 39       "$ADB" shell run-as "$PACKAGE_NAME" rm "$TARGET_GDBSERVER" >/dev/null 2>&1 | 40       "$ADB" shell "$COMMAND_PREFIX" rm "$TARGET_GDBSERVER" >/dev/null 2>&1 | 
| 40     fi | 41     fi | 
| 41     log "Cleaning up: $TMPDIR" | 42     log "Cleaning up: $TMPDIR" | 
| 42     rm -rf "$TMPDIR" | 43     rm -rf "$TMPDIR" | 
| 43   fi | 44   fi | 
| 44   trap "" EXIT | 45   trap "" EXIT | 
| 45   exit $1 | 46   exit $1 | 
| 46 } | 47 } | 
| 47 | 48 | 
| 48 # Ensure clean exit on Ctrl-C or normal exit. | 49 # Ensure clean exit on Ctrl-C or normal exit. | 
| 49 trap "clean_exit 1" INT HUP QUIT TERM | 50 trap "clean_exit 1" INT HUP QUIT TERM | 
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 901              grep -v "^$" | tr '\n' ':') | 902              grep -v "^$" | tr '\n' ':') | 
| 902 | 903 | 
| 903 # This is a re-implementation of gdbclient, where we use compatible | 904 # This is a re-implementation of gdbclient, where we use compatible | 
| 904 # versions of gdbserver and $GDBNAME to ensure that everything works | 905 # versions of gdbserver and $GDBNAME to ensure that everything works | 
| 905 # properly. | 906 # properly. | 
| 906 # | 907 # | 
| 907 | 908 | 
| 908 # Push gdbserver to the device | 909 # Push gdbserver to the device | 
| 909 log "Pushing gdbserver $GDBSERVER to $TARGET_GDBSERVER" | 910 log "Pushing gdbserver $GDBSERVER to $TARGET_GDBSERVER" | 
| 910 adb push $GDBSERVER $TMP_TARGET_GDBSERVER &>/dev/null | 911 adb push $GDBSERVER $TMP_TARGET_GDBSERVER &>/dev/null | 
| 911 adb shell run-as $PACKAGE_NAME cp $TMP_TARGET_GDBSERVER . | 912 adb shell $COMMAND_PREFIX cp $TMP_TARGET_GDBSERVER $TARGET_GDBSERVER | 
| 912 adb shell rm $TMP_TARGET_GDBSERVER | 913 adb shell rm $TMP_TARGET_GDBSERVER | 
| 913 fail_panic "Could not copy gdbserver to the device!" | 914 fail_panic "Could not copy gdbserver to the device!" | 
| 914 | 915 | 
| 915 PORT=5039 | 916 PORT=5039 | 
| 916 HOST_PORT=$PORT | 917 HOST_PORT=$PORT | 
| 917 TARGET_PORT=$PORT | 918 TARGET_PORT=$PORT | 
| 918 | 919 | 
| 919 # Select correct app_process for architecture. | 920 # Select correct app_process for architecture. | 
| 920 case $TARGET_ARCH in | 921 case $TARGET_ARCH in | 
| 921       arm|x86|mips) GDBEXEC=app_process;; | 922       arm|x86|mips) GDBEXEC=app_process;; | 
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1010 | 1011 | 
| 1011 if [ "$VERBOSE" -gt 0 ]; then | 1012 if [ "$VERBOSE" -gt 0 ]; then | 
| 1012   echo "### START $COMMANDS" | 1013   echo "### START $COMMANDS" | 
| 1013   cat $COMMANDS | 1014   cat $COMMANDS | 
| 1014   echo "### END $COMMANDS" | 1015   echo "### END $COMMANDS" | 
| 1015 fi | 1016 fi | 
| 1016 | 1017 | 
| 1017 log "Launching gdb client: $GDB $GDB_ARGS -x $COMMANDS" | 1018 log "Launching gdb client: $GDB $GDB_ARGS -x $COMMANDS" | 
| 1018 $GDB $GDB_ARGS -x $COMMANDS && | 1019 $GDB $GDB_ARGS -x $COMMANDS && | 
| 1019 rm -f "$GDBSERVER_PIDFILE" | 1020 rm -f "$GDBSERVER_PIDFILE" | 
| OLD | NEW | 
|---|