1#!/bin/bash 2# 3# android_gdbserver: Pushes gdbserver. Starts debugging environment. 4 5SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 6source $SCRIPT_DIR/android_setup.sh 7source $SCRIPT_DIR/utils/setup_adb.sh 8 9APP_NAME=${APP_ARGS[0]} 10PORT=5039 11 12BUILD_DIR="${SKIA_OUT}/${BUILDTYPE}" 13TARGET_LIBRARY="${BUILD_DIR}/lib/lib${APP_NAME}.so" 14if [ ! -f "$TARGET_LIBRARY" ] 15then 16 echo "Unable to find the ${APP_NAME} library at ${TARGET_LIBRARY}." 17 exit 1 18fi 19 20# We need the debug symbols from these files 21GDB_TMP_DIR=$(pwd)/android_gdb_tmp 22mkdir -p $GDB_TMP_DIR 23 24echo "Copying symbol files" 25SYSTEM_LIBRARY_PATH=/system/lib 26for library_file in \ 27 libc.so \ 28 libstdc++.so \ 29 libm.so \ 30 liblog.so \ 31 libz.so \ 32 libgccdemangle.so \ 33 libcorkscrew.so \ 34 libutils.so \ 35 libstlport.so \ 36 libGLES_trace.so \ 37 libEGL.so \ 38 libGLESv2.so \ 39 ; do 40 adb_pull_if_needed "${SYSTEM_LIBRARY_PATH}/${library_file}" $GDB_TMP_DIR 41done 42 43adb_pull_if_needed /system/bin/linker $GDB_TMP_DIR 44 45echo "Pushing app..." 46for file in \ 47 "${BUILD_DIR}/skia_launcher" \ 48 "${BUILD_DIR}/lib/libskia_android.so" \ 49 "${BUILD_DIR}/lib/lib${APP_NAME}.so" \ 50 ; do 51 cp "$file" $GDB_TMP_DIR 52 adb_push_if_needed "$file" /data/local/tmp 53done 54 55echo "Pushing gdbserver..." 56adb_push_if_needed $ANDROID_TOOLCHAIN/../gdbserver data/local/tmp 57 58echo "Setting up port forward" 59$ADB forward "tcp:5039" "tcp:5039" 60 61# Kill all previous instances of gdbserver and the app to rid all port overriding errors. 62echo "Killing any running Skia processes." 63$ADB shell ps | grep gdbserver | awk '{print $2}' | xargs $ADB shell kill 64$ADB shell ps | grep ${APP_NAME} | awk '{print $2}' | xargs $ADB shell kill 65 66# Starting up gdbserver in android shell 67echo "Starting gdbserver with command: ${APP_ARGS[@]}" 68$ADB shell /data/local/tmp/gdbserver :5039 /data/local/tmp/skia_launcher ${APP_ARGS[@]} & 69