2013-04-29 12:09:31 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2015-02-03 23:07:30 +00:00
|
|
|
# android_gdb_native: Pushes gdbserver, connects to specified Skia app,
|
|
|
|
# and enters command line debugging environment.
|
2013-04-29 12:09:31 +00:00
|
|
|
|
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
2016-12-01 19:37:41 +00:00
|
|
|
source $SCRIPT_DIR/utils/android_setup.sh
|
2013-04-29 12:09:31 +00:00
|
|
|
|
2013-06-27 13:43:04 +00:00
|
|
|
# setup the gdbserver
|
2017-01-05 16:39:04 +00:00
|
|
|
$SCRIPT_DIR/android_gdbserver -C ${SKIA_OUT} ${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
|
2015-07-10 18:05:10 +00:00
|
|
|
GDB_TMP_DIR=$SKIA_OUT/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
|
|
|
{
|
2016-12-01 19:37:41 +00:00
|
|
|
echo "file ${GDB_TMP_DIR}/${APP_NAME}"
|
2014-05-01 15:34:28 +00:00
|
|
|
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
|
|
|
|
2016-12-01 19:37:41 +00:00
|
|
|
echo "break main"
|
2014-05-01 15:34:28 +00:00
|
|
|
echo "continue"
|
|
|
|
} > $GDBSETUP
|
|
|
|
|
2013-04-29 12:09:31 +00:00
|
|
|
|
|
|
|
# Launch gdb client
|
2016-12-01 19:37:41 +00:00
|
|
|
HOST=`uname | tr '[A-Z]' '[a-z]'`
|
|
|
|
if [ $HOST == "darwin" ]; then
|
|
|
|
GDB_HOST=$ANDROID_NDK_ROOT/prebuilt/darwin-x86_64/bin/gdb
|
|
|
|
elif [ $HOST == "linux" ]; then
|
|
|
|
GDB_HOST=$ANDROID_NDK_ROOT/prebuilt/linux-x86_64/bin/gdb
|
|
|
|
else
|
|
|
|
echo "Could not automatically determine OS!"
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
2013-04-29 12:09:31 +00:00
|
|
|
echo "Entering gdb client shell"
|
2016-12-01 19:37:41 +00:00
|
|
|
$GDB_HOST -x $GDBSETUP
|
2013-04-29 12:09:31 +00:00
|
|
|
|
2015-02-03 23:07:30 +00:00
|
|
|
# Clean up:
|
|
|
|
# We could 'rm -rf $GDB_TMP_DIR', but doing so would cause subsequent debugging
|
|
|
|
# sessions to take longer than necessary. The tradeoff is to now force the user
|
|
|
|
# to remove the directory when they are done debugging.
|
|
|
|
rm $GDBSETUP
|