Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(485)

Side by Side Diff: build/android/adb_gdb

Issue 884993003: Make gdb debugging on un-rooted devices work for Android 5.x. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address debugging Release builds Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 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 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 728
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/local/tmp/gdbserver-adb-gdb-$TMP_ID 738 TARGET_GDBSERVER=/data/data/$PACKAGE_NAME/gdbserver-adb-gdb-$TMP_ID
739 ROOT_TARGET_GDBSERVER=/data/local/tmp/gdbserver-adb-gdb-$TMP_ID
738 740
739 # Return the build fingerprint contained in a build.prop file. 741 # Return the build fingerprint contained in a build.prop file.
740 # $1: path to build.prop file 742 # $1: path to build.prop file
741 get_build_fingerprint_from () { 743 get_build_fingerprint_from () {
742 cat "$1" | grep -e '^ro.build.fingerprint=' | cut -d= -f2 744 cat "$1" | grep -e '^ro.build.fingerprint=' | cut -d= -f2
743 } 745 }
744 746
745 747
746 ORG_PULL_LIBS_DIR=$PULL_LIBS_DIR 748 ORG_PULL_LIBS_DIR=$PULL_LIBS_DIR
747 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
899 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 | \
900 grep -v "^$" | tr '\n' ':') 902 grep -v "^$" | tr '\n' ':')
901 903
902 # This is a re-implementation of gdbclient, where we use compatible 904 # This is a re-implementation of gdbclient, where we use compatible
903 # versions of gdbserver and $GDBNAME to ensure that everything works 905 # versions of gdbserver and $GDBNAME to ensure that everything works
904 # properly. 906 # properly.
905 # 907 #
906 908
907 # Push gdbserver to the device 909 # Push gdbserver to the device
908 log "Pushing gdbserver $GDBSERVER to $TARGET_GDBSERVER" 910 log "Pushing gdbserver $GDBSERVER to $TARGET_GDBSERVER"
909 adb push $GDBSERVER $TARGET_GDBSERVER &>/dev/null 911 adb push $GDBSERVER $ROOT_TARGET_GDBSERVER &>/dev/null
912 if ["$COMMAND_PREFIX" == "$SU_PREFIX"]; then
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
910 fail_panic "Could not copy gdbserver to the device!" 919 fail_panic "Could not copy gdbserver to the device!"
911 920
912 PORT=5039 921 PORT=5039
913 HOST_PORT=$PORT 922 HOST_PORT=$PORT
914 TARGET_PORT=$PORT 923 TARGET_PORT=$PORT
915 924
916 # Select correct app_process for architecture. 925 # Select correct app_process for architecture.
917 case $TARGET_ARCH in 926 case $TARGET_ARCH in
918 arm|x86|mips) GDBEXEC=app_process;; 927 arm|x86|mips) GDBEXEC=app_process;;
919 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
1007 1016
1008 if [ "$VERBOSE" -gt 0 ]; then 1017 if [ "$VERBOSE" -gt 0 ]; then
1009 echo "### START $COMMANDS" 1018 echo "### START $COMMANDS"
1010 cat $COMMANDS 1019 cat $COMMANDS
1011 echo "### END $COMMANDS" 1020 echo "### END $COMMANDS"
1012 fi 1021 fi
1013 1022
1014 log "Launching gdb client: $GDB $GDB_ARGS -x $COMMANDS" 1023 log "Launching gdb client: $GDB $GDB_ARGS -x $COMMANDS"
1015 $GDB $GDB_ARGS -x $COMMANDS && 1024 $GDB $GDB_ARGS -x $COMMANDS &&
1016 rm -f "$GDBSERVER_PIDFILE" 1025 rm -f "$GDBSERVER_PIDFILE"
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698