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