| 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 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | 5 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 6 source $SCRIPT_DIR/android_setup.sh | 6 source $SCRIPT_DIR/android_setup.sh |
| 7 | 7 |
| 8 # setup the gdbserver | 8 # setup the gdbserver |
| 9 export BUILDTYPE # from android_setup.sh | 9 export BUILDTYPE # from android_setup.sh |
| 10 $SCRIPT_DIR/android_gdbserver -d ${DEVICE_ID} ${APP_ARGS[@]} | 10 $SCRIPT_DIR/android_gdbserver -d ${DEVICE_ID} ${APP_ARGS[@]} |
| 11 | 11 |
| 12 # quit if gdbserver setup failed | 12 # quit if gdbserver setup failed |
| 13 if [[ "$?" != "0" ]]; then | 13 if [[ "$?" != "0" ]]; then |
| 14 echo "ERROR: gdbserver failed to setup properly." | 14 echo "ERROR: gdbserver failed to setup properly." |
| 15 exit 1 | 15 exit 1 |
| 16 fi | 16 fi |
| 17 | 17 |
| 18 # Wait for gdbserver | 18 # Wait for gdbserver |
| 19 sleep 2 | 19 sleep 2 |
| 20 | 20 |
| 21 # variables that must match those in gdb_server | 21 # variables that must match those in gdb_server |
| 22 GDB_TMP_DIR=$(pwd)/android_gdb_tmp | 22 GDB_TMP_DIR=$(pwd)/android_gdb_tmp |
| 23 APP_NAME=${APP_ARGS[0]} | 23 APP_NAME=${APP_ARGS[0]} |
| 24 PORT=5039 | 24 PORT=5039 |
| 25 | 25 |
| 26 # Set up gdb commands | 26 # Set up gdb commands |
| 27 GDBSETUP=$GDB_TMP_DIR/gdb.setup | 27 GDBSETUP=$GDB_TMP_DIR/gdb.setup |
| 28 { | 28 echo "file $GDB_TMP_DIR/skia_launcher" >> $GDBSETUP |
| 29 echo "file ${GDB_TMP_DIR}/skia_launcher" | 29 echo "target remote :$PORT" >> $GDBSETUP |
| 30 echo "target remote :${PORT}" | 30 echo "set solib-absolute-prefix $GDB_TMP_DIR" >> $GDBSETUP |
| 31 echo "set solib-absolute-prefix ${GDB_TMP_DIR}" | 31 echo "set solib-search-path $GDB_TMP_DIR" >> $GDBSETUP |
| 32 echo "set solib-search-path ${GDB_TMP_DIR} | |
| 33 | 32 |
| 34 # The apps shared library symbols are not loaded by default so we | 33 # The apps shared library symbols are not loaded by default so we load them here |
| 35 # load them here." | 34 echo "break launch_app" >> $GDBSETUP |
| 36 echo "break launch_app" | 35 echo "continue" >> $GDBSETUP |
| 37 echo "continue" | 36 echo "sharedLibrary $APP_NAME" >> $GDBSETUP |
| 38 echo "sharedLibrary ${APP_NAME}" | |
| 39 } > $GDBSETUP | |
| 40 | |
| 41 | 37 |
| 42 # Launch gdb client | 38 # Launch gdb client |
| 43 echo "Entering gdb client shell" | 39 echo "Entering gdb client shell" |
| 44 GDB_COMMAND=$(command ls "$ANDROID_TOOLCHAIN"/*-gdb | head -n1) | 40 GDB_COMMAND=$(command ls "$ANDROID_TOOLCHAIN"/*-gdb | head -n1) |
| 45 "$GDB_COMMAND" -x $GDBSETUP | 41 "$GDB_COMMAND" -x $GDBSETUP |
| 46 | 42 |
| 47 # Clean up | 43 # Clean up |
| 48 rm -rf $GDB_TMP_DIR | 44 rm -rf $GDB_TMP_DIR |
| OLD | NEW |