OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 # | 2 # |
3 # android_gdb: Pushes gdbserver. Connects and enters debugging environment. | 3 # android_gdb: Pushes gdbserver. Connects and enters debugging environment. |
4 | 4 |
5 deviceID="" | |
6 while (( "$#" )); do | |
7 | |
8 if [[ $(echo "$1" | grep "^-d$") != "" ]]; | |
9 then | |
10 deviceID="$2" | |
11 shift | |
12 else | |
13 gdbVars=("${gdbVars[@]}" "$1") | |
14 fi | |
15 | |
16 shift | |
17 done | |
18 | |
19 # hack for x86 support in android_setup.sh | |
20 if [ "$deviceID" == "x86" ] || [ "$deviceID" == "razr_i" ] | |
21 then | |
22 export ANDROID_ARCH=x86 | |
23 fi | |
24 | |
25 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | 5 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 6 source $SCRIPT_DIR/android_setup.sh |
26 | 7 |
27 # setup the gdbserver | 8 # setup the gdbserver |
28 $SCRIPT_DIR/android_gdbserver ${gdbVars[@]} | 9 $SCRIPT_DIR/android_gdbserver -d ${DEVICE_ID} ${APP_ARGS} |
29 | 10 |
30 # quit if gdbserver setup failed | 11 # quit if gdbserver setup failed |
31 if [[ "$?" != "0" ]]; then | 12 if [[ "$?" != "0" ]]; then |
32 echo "ERROR: gdbserver failed to setup properly." | 13 echo "ERROR: gdbserver failed to setup properly." |
33 exit 1 | 14 exit 1 |
34 fi | 15 fi |
35 | 16 |
36 # Wait for gdbserver | 17 # Wait for gdbserver |
37 sleep 2 | 18 sleep 2 |
38 | 19 |
39 # variables that must match those in gdb_server | 20 # variables that must match those in gdb_server |
40 GDB_TMP_DIR=$(pwd)/android_gdb_tmp | 21 GDB_TMP_DIR=$(pwd)/android_gdb_tmp |
41 APP_NAME=$(basename ${gdbVars[0]}) | 22 APP_NAME=${APP_ARGS[0]} |
42 PORT=5039 | 23 PORT=5039 |
43 | 24 |
44 # Set up gdb commands | 25 # Set up gdb commands |
45 GDBSETUP=$GDB_TMP_DIR/gdb.setup | 26 GDBSETUP=$GDB_TMP_DIR/gdb.setup |
46 echo "file $GDB_TMP_DIR/skia_launcher" >> $GDBSETUP | 27 echo "file $GDB_TMP_DIR/skia_launcher" >> $GDBSETUP |
47 echo "target remote :$PORT" >> $GDBSETUP | 28 echo "target remote :$PORT" >> $GDBSETUP |
48 echo "set solib-absolute-prefix $GDB_TMP_DIR" >> $GDBSETUP | 29 echo "set solib-absolute-prefix $GDB_TMP_DIR" >> $GDBSETUP |
49 echo "set solib-search-path $GDB_TMP_DIR" >> $GDBSETUP | 30 echo "set solib-search-path $GDB_TMP_DIR" >> $GDBSETUP |
50 | 31 |
51 # The apps shared library symbols are not loaded by default so we load them here | 32 # The apps shared library symbols are not loaded by default so we load them here |
52 echo "break launch_app" >> $GDBSETUP | 33 echo "break launch_app" >> $GDBSETUP |
53 echo "continue" >> $GDBSETUP | 34 echo "continue" >> $GDBSETUP |
54 echo "sharedLibrary $APP_NAME" >> $GDBSETUP | 35 echo "sharedLibrary $APP_NAME" >> $GDBSETUP |
55 | 36 |
56 source $SCRIPT_DIR/android_setup.sh | |
57 | |
58 # Launch gdb client | 37 # Launch gdb client |
59 echo "Entering gdb client shell" | 38 echo "Entering gdb client shell" |
60 if [ "$ANDROID_ARCH" == "x86" ] | 39 if [ "$ANDROID_ARCH" == "x86" ] |
61 then | 40 then |
62 $ANDROID_TOOLCHAIN/i686-linux-android-gdb -x $GDBSETUP | 41 $ANDROID_TOOLCHAIN/i686-linux-android-gdb -x $GDBSETUP |
63 else | 42 else |
64 $ANDROID_TOOLCHAIN/arm-linux-androideabi-gdb -x $GDBSETUP | 43 $ANDROID_TOOLCHAIN/arm-linux-androideabi-gdb -x $GDBSETUP |
65 fi | 44 fi |
66 | 45 |
67 # Clean up | 46 # Clean up |
68 rm -rf $GDB_TMP_DIR | 47 rm -rf $GDB_TMP_DIR |
OLD | NEW |