2013-04-29 12:09:31 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# android_gdb: Pushes gdbserver. Connects and enters debugging environment.
|
|
|
|
|
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
2013-08-06 20:32:29 +00:00
|
|
|
source $SCRIPT_DIR/android_setup.sh
|
2013-04-29 12:09:31 +00:00
|
|
|
|
2013-06-27 13:43:04 +00:00
|
|
|
# setup the gdbserver
|
2014-04-24 18:36:36 +00:00
|
|
|
export BUILDTYPE # from android_setup.sh
|
2013-10-10 17:41:32 +00:00
|
|
|
$SCRIPT_DIR/android_gdbserver -d ${DEVICE_ID} ${APP_ARGS[@]}
|
2013-04-29 12:09:31 +00:00
|
|
|
|
2013-06-27 13:43:04 +00:00
|
|
|
# quit if gdbserver setup failed
|
|
|
|
if [[ "$?" != "0" ]]; then
|
|
|
|
echo "ERROR: gdbserver failed to setup properly."
|
|
|
|
exit 1
|
2013-04-29 12:09:31 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Wait for gdbserver
|
|
|
|
sleep 2
|
|
|
|
|
2013-06-27 13:43:04 +00:00
|
|
|
# variables that must match those in gdb_server
|
|
|
|
GDB_TMP_DIR=$(pwd)/android_gdb_tmp
|
2013-08-06 20:32:29 +00:00
|
|
|
APP_NAME=${APP_ARGS[0]}
|
2013-06-27 13:43:04 +00:00
|
|
|
PORT=5039
|
|
|
|
|
2013-04-29 12:09:31 +00:00
|
|
|
# Set up gdb commands
|
|
|
|
GDBSETUP=$GDB_TMP_DIR/gdb.setup
|
2014-05-01 15:34:28 +00:00
|
|
|
{
|
|
|
|
echo "file ${GDB_TMP_DIR}/skia_launcher"
|
|
|
|
echo "target remote :${PORT}"
|
|
|
|
echo "set solib-absolute-prefix ${GDB_TMP_DIR}"
|
2014-07-16 20:21:15 +00:00
|
|
|
echo "set solib-search-path ${GDB_TMP_DIR}"
|
2014-05-01 15:34:28 +00:00
|
|
|
|
|
|
|
# The apps shared library symbols are not loaded by default so we
|
2014-07-16 20:21:15 +00:00
|
|
|
# load them here.
|
2014-05-01 15:34:28 +00:00
|
|
|
echo "break launch_app"
|
|
|
|
echo "continue"
|
|
|
|
echo "sharedLibrary ${APP_NAME}"
|
2014-07-16 20:21:15 +00:00
|
|
|
|
|
|
|
# Load libskia_android.so here.
|
|
|
|
echo "sharedLibrary skia_android"
|
2014-05-01 15:34:28 +00:00
|
|
|
} > $GDBSETUP
|
|
|
|
|
2013-04-29 12:09:31 +00:00
|
|
|
|
|
|
|
# Launch gdb client
|
|
|
|
echo "Entering gdb client shell"
|
2014-04-24 18:36:36 +00:00
|
|
|
GDB_COMMAND=$(command ls "$ANDROID_TOOLCHAIN"/*-gdb | head -n1)
|
|
|
|
"$GDB_COMMAND" -x $GDBSETUP
|
2013-04-29 12:09:31 +00:00
|
|
|
|
|
|
|
# Clean up
|
2013-08-02 15:14:24 +00:00
|
|
|
rm -rf $GDB_TMP_DIR
|