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