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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
728 SYMBOL_DIR=$CHROMIUM_SRC/$CHROMIUM_OUT_DIR/$SUBDIR | 729 SYMBOL_DIR=$CHROMIUM_SRC/$CHROMIUM_OUT_DIR/$SUBDIR |
729 log "Auto-config: --symbol-dir=$SYMBOL_DIR" | 730 log "Auto-config: --symbol-dir=$SYMBOL_DIR" |
730 } | 731 } |
731 | 732 |
732 if [ -z "$SYMBOL_DIR" ]; then | 733 if [ -z "$SYMBOL_DIR" ]; then |
733 detect_symbol_dir "$BUILDTYPE" | 734 detect_symbol_dir "$BUILDTYPE" |
734 fi | 735 fi |
735 | 736 |
736 # Allow several concurrent debugging sessions | 737 # Allow several concurrent debugging sessions |
737 TARGET_GDBSERVER=/data/data/$PACKAGE_NAME/gdbserver-adb-gdb-$TMP_ID | 738 TARGET_GDBSERVER=/data/data/$PACKAGE_NAME/gdbserver-adb-gdb-$TMP_ID |
738 TMP_TARGET_GDBSERVER=/data/local/tmp/gdbserver-adb-gdb-$TMP_ID | 739 ROOT_TARGET_GDBSERVER=/data/local/tmp/gdbserver-adb-gdb-$TMP_ID |
739 | 740 |
740 # Return the build fingerprint contained in a build.prop file. | 741 # Return the build fingerprint contained in a build.prop file. |
741 # $1: path to build.prop file | 742 # $1: path to build.prop file |
742 get_build_fingerprint_from () { | 743 get_build_fingerprint_from () { |
743 cat "$1" | grep -e '^ro.build.fingerprint=' | cut -d= -f2 | 744 cat "$1" | grep -e '^ro.build.fingerprint=' | cut -d= -f2 |
744 } | 745 } |
745 | 746 |
746 | 747 |
747 ORG_PULL_LIBS_DIR=$PULL_LIBS_DIR | 748 ORG_PULL_LIBS_DIR=$PULL_LIBS_DIR |
748 PULL_LIBS_DIR=${PULL_LIBS_DIR:-$DEFAULT_PULL_LIBS_DIR} | 749 PULL_LIBS_DIR=${PULL_LIBS_DIR:-$DEFAULT_PULL_LIBS_DIR} |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
900 SOLIB_DIRS=$(find $PULL_LIBS_DIR -mindepth 1 -maxdepth 4 -type d | \ | 901 SOLIB_DIRS=$(find $PULL_LIBS_DIR -mindepth 1 -maxdepth 4 -type d | \ |
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 $ROOT_TARGET_GDBSERVER &>/dev/null |
911 adb shell run-as $PACKAGE_NAME cp $TMP_TARGET_GDBSERVER . | 912 if ["$COMMAND_PREFIX" == "$SU_PREFIX"]; then |
jbudorick
2015/01/30 15:43:17
What's wrong with just changing this line to
ad
mille
2015/01/30 16:11:59
There is nothing wrong with doing that. I guess th
| |
912 adb shell rm $TMP_TARGET_GDBSERVER | 913 TARGET_GDBSERVER=$ROOT_TARGET_GDBSERVER |
914 else | |
915 log "Moving gdbserver to $TARGET_GDBSERVER" | |
916 adb shell $COMMAND_PREFIX cp $ROOT_TARGET_GDBSERVER . | |
917 adb shell rm $ROOT_TARGET_GDBSERVER | |
918 fi | |
913 fail_panic "Could not copy gdbserver to the device!" | 919 fail_panic "Could not copy gdbserver to the device!" |
914 | 920 |
915 PORT=5039 | 921 PORT=5039 |
916 HOST_PORT=$PORT | 922 HOST_PORT=$PORT |
917 TARGET_PORT=$PORT | 923 TARGET_PORT=$PORT |
918 | 924 |
919 # Select correct app_process for architecture. | 925 # Select correct app_process for architecture. |
920 case $TARGET_ARCH in | 926 case $TARGET_ARCH in |
921 arm|x86|mips) GDBEXEC=app_process;; | 927 arm|x86|mips) GDBEXEC=app_process;; |
922 arm64|x86_64) GDBEXEC=app_process64;; | 928 arm64|x86_64) GDBEXEC=app_process64;; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1010 | 1016 |
1011 if [ "$VERBOSE" -gt 0 ]; then | 1017 if [ "$VERBOSE" -gt 0 ]; then |
1012 echo "### START $COMMANDS" | 1018 echo "### START $COMMANDS" |
1013 cat $COMMANDS | 1019 cat $COMMANDS |
1014 echo "### END $COMMANDS" | 1020 echo "### END $COMMANDS" |
1015 fi | 1021 fi |
1016 | 1022 |
1017 log "Launching gdb client: $GDB $GDB_ARGS -x $COMMANDS" | 1023 log "Launching gdb client: $GDB $GDB_ARGS -x $COMMANDS" |
1018 $GDB $GDB_ARGS -x $COMMANDS && | 1024 $GDB $GDB_ARGS -x $COMMANDS && |
1019 rm -f "$GDBSERVER_PIDFILE" | 1025 rm -f "$GDBSERVER_PIDFILE" |
OLD | NEW |