2013-06-27 13:43:04 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# android_gdbserver: Pushes gdbserver. Starts 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-08-12 12:30:04 +00:00
|
|
|
source $SCRIPT_DIR/utils/setup_adb.sh
|
|
|
|
|
2014-04-24 18:36:36 +00:00
|
|
|
APP_NAME=${APP_ARGS[0]}
|
2013-08-06 20:32:29 +00:00
|
|
|
PORT=5039
|
2013-06-27 13:43:04 +00:00
|
|
|
|
2014-04-24 18:36:36 +00:00
|
|
|
BUILD_DIR="${SKIA_OUT}/${BUILDTYPE}"
|
|
|
|
TARGET_LIBRARY="${BUILD_DIR}/lib/lib${APP_NAME}.so"
|
|
|
|
if [ ! -f "$TARGET_LIBRARY" ]
|
2013-08-12 12:30:04 +00:00
|
|
|
then
|
2014-04-24 18:36:36 +00:00
|
|
|
echo "Unable to find the ${APP_NAME} library at ${TARGET_LIBRARY}."
|
2013-08-12 12:30:04 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2013-06-27 13:43:04 +00:00
|
|
|
|
|
|
|
# We need the debug symbols from these files
|
|
|
|
GDB_TMP_DIR=$(pwd)/android_gdb_tmp
|
2014-05-01 15:34:28 +00:00
|
|
|
mkdir -p $GDB_TMP_DIR
|
2013-08-12 12:30:04 +00:00
|
|
|
|
2013-06-27 13:43:04 +00:00
|
|
|
echo "Copying symbol files"
|
2014-07-16 20:21:15 +00:00
|
|
|
if [[ $ANDROID_ARCH == *64* ]]; then
|
|
|
|
SYSTEM_LIBRARY_PATH=/system/lib64
|
|
|
|
else
|
|
|
|
SYSTEM_LIBRARY_PATH=/system/lib
|
|
|
|
fi
|
2014-04-29 19:04:21 +00:00
|
|
|
for library_file in \
|
|
|
|
libc.so \
|
2014-11-12 19:52:23 +00:00
|
|
|
libc++.so \
|
2014-04-29 19:04:21 +00:00
|
|
|
libstdc++.so \
|
|
|
|
libm.so \
|
|
|
|
liblog.so \
|
|
|
|
libz.so \
|
|
|
|
libgccdemangle.so \
|
2014-07-17 15:18:23 +00:00
|
|
|
libsigchain.so \
|
|
|
|
libcutils.so \
|
|
|
|
libunwind.so \
|
|
|
|
libunwind-ptrace.so \
|
|
|
|
libbacktrace.so \
|
2014-04-29 19:04:21 +00:00
|
|
|
libutils.so \
|
|
|
|
libstlport.so \
|
|
|
|
libGLES_trace.so \
|
|
|
|
libEGL.so \
|
|
|
|
libGLESv2.so \
|
|
|
|
; do
|
2014-07-17 15:18:23 +00:00
|
|
|
ANDROID_LS=`$ADB $DEVICE_SERIAL shell ls -ld ${SYSTEM_LIBRARY_PATH}/${library_file}`
|
|
|
|
if [ "${ANDROID_LS:0:1}" == "-" ]; then
|
|
|
|
adb_pull_if_needed "${SYSTEM_LIBRARY_PATH}/${library_file}" $GDB_TMP_DIR
|
|
|
|
fi
|
2014-04-29 19:04:21 +00:00
|
|
|
done
|
|
|
|
|
2014-07-17 15:18:23 +00:00
|
|
|
if [[ $ANDROID_ARCH == *64* ]]; then
|
|
|
|
adb_pull_if_needed /system/bin/linker64 $GDB_TMP_DIR
|
|
|
|
else
|
|
|
|
adb_pull_if_needed /system/bin/linker $GDB_TMP_DIR
|
|
|
|
fi
|
2013-06-27 13:43:04 +00:00
|
|
|
|
2013-08-12 12:30:04 +00:00
|
|
|
echo "Pushing app..."
|
2014-04-24 18:36:36 +00:00
|
|
|
for file in \
|
|
|
|
"${BUILD_DIR}/skia_launcher" \
|
|
|
|
"${BUILD_DIR}/lib/libskia_android.so" \
|
|
|
|
"${BUILD_DIR}/lib/lib${APP_NAME}.so" \
|
|
|
|
; do
|
|
|
|
cp "$file" $GDB_TMP_DIR
|
|
|
|
adb_push_if_needed "$file" /data/local/tmp
|
|
|
|
done
|
2013-06-27 13:43:04 +00:00
|
|
|
|
|
|
|
echo "Pushing gdbserver..."
|
2014-07-08 19:29:54 +00:00
|
|
|
adb_push_if_needed $ANDROID_TOOLCHAIN/../gdbserver /data/local/tmp
|
2013-06-27 13:43:04 +00:00
|
|
|
|
|
|
|
echo "Setting up port forward"
|
|
|
|
$ADB forward "tcp:5039" "tcp:5039"
|
|
|
|
|
2013-08-12 12:30:04 +00:00
|
|
|
# Kill all previous instances of gdbserver and the app to rid all port overriding errors.
|
2013-06-27 13:43:04 +00:00
|
|
|
echo "Killing any running Skia processes."
|
|
|
|
$ADB shell ps | grep gdbserver | awk '{print $2}' | xargs $ADB shell kill
|
2013-08-12 12:30:04 +00:00
|
|
|
$ADB shell ps | grep ${APP_NAME} | awk '{print $2}' | xargs $ADB shell kill
|
2013-06-27 13:43:04 +00:00
|
|
|
|
|
|
|
# Starting up gdbserver in android shell
|
2014-04-24 18:36:36 +00:00
|
|
|
echo "Starting gdbserver with command: ${APP_ARGS[@]}"
|
2014-07-16 20:21:15 +00:00
|
|
|
$ADB shell LD_LIBRARY_PATH=/data/local/tmp:\$LD_LIBRARY_PATH /data/local/tmp/gdbserver :5039 /data/local/tmp/skia_launcher ${APP_ARGS[@]} &
|