Add MD5 support when syncing debug files and option to just start gdbserver

R=borenet@google.com

Review URL: https://codereview.chromium.org/17910006

git-svn-id: http://skia.googlecode.com/svn/trunk@9791 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
djsollen@google.com 2013-06-27 13:43:04 +00:00
parent eee4b65d0b
commit 121b3fe6a0
4 changed files with 105 additions and 65 deletions

View File

@ -3,63 +3,24 @@
# android_gdb: Pushes gdbserver. Connects and enters debugging environment.
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
APP_NAME=$(basename $1)
PORT=5039
# Collect extra arguments to be passed to the Skia binary
shift
while (( "$#" )); do
APP_ARGS="$APP_ARGS $1"
shift
done
# setup the gdbserver
$SCRIPT_DIR/android_gdbserver $@
source $SCRIPT_DIR/android_setup.sh
source $SCRIPT_DIR/utils/setup_adb.sh
# We need the debug symbols from these files
GDB_TMP_DIR=$(pwd)/android_gdb_tmp
mkdir $GDB_TMP_DIR
echo "Copying symbol files"
$ADB pull /system/bin/skia_launcher $GDB_TMP_DIR
$ADB pull /system/lib/libc.so $GDB_TMP_DIR
$ADB pull /data/data/com.skia/lib/libskia_android.so $GDB_TMP_DIR
$ADB pull /data/data/com.skia/lib/lib$APP_NAME.so $GDB_TMP_DIR
echo "Checking for skia_launcher app..."
if [ ! -f $GDB_TMP_DIR/skia_launcher ]
then
echo "Unable for find the skia_launcher on the device"
rm -rf $GDB_TMP_DIR
exit 1;
# quit if gdbserver setup failed
if [[ "$?" != "0" ]]; then
echo "ERROR: gdbserver failed to setup properly."
exit 1
fi
echo "Checking for $APP_NAME library..."
if [ ! -f $GDB_TMP_DIR/lib$APP_NAME.so ]
then
echo "Unable for find the app's shared library on the device"
rm -rf $GDB_TMP_DIR
exit 1;
fi
echo "Pushing gdbserver..."
$ADB remount
$ADB push $ANDROID_TOOLCHAIN/../gdbserver /system/bin/gdbserver
echo "Setting up port forward"
$ADB forward "tcp:5039" "tcp:5039"
# Kill all previous instances of gdbserver and skia_launcher to rid all port overriding errors.
echo "Killing any running Skia processes."
$ADB shell ps | grep gdbserver | awk '{print $2}' | xargs $ADB shell kill
$ADB shell ps | grep skia_launcher | awk '{print $2}' | xargs $ADB shell kill
# Starting up gdbserver in android shell
echo "Starting gdbserver with command: skia_launcher $APP_NAME$APP_ARGS"
$ADB shell gdbserver :5039 /system/bin/skia_launcher $APP_NAME$APP_ARGS &
# Wait for gdbserver
sleep 2
# variables that must match those in gdb_server
GDB_TMP_DIR=$(pwd)/android_gdb_tmp
APP_NAME=$(basename $1)
PORT=5039
# Set up gdb commands
GDBSETUP=$GDB_TMP_DIR/gdb.setup
echo "file $GDB_TMP_DIR/skia_launcher" >> $GDBSETUP
@ -72,6 +33,7 @@ echo "break skia_launcher.cpp:launch_app" >> $GDBSETUP
echo "continue" >> $GDBSETUP
echo "sharedLibrary $APP_NAME" >> $GDBSETUP
source $SCRIPT_DIR/android_setup.sh
# Launch gdb client
echo "Entering gdb client shell"

View File

@ -0,0 +1,58 @@
#!/bin/bash
#
# android_gdbserver: Pushes gdbserver. Starts debugging environment.
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
APP_NAME=$(basename $1)
PORT=5039
# Collect extra arguments to be passed to the Skia binary
shift
while (( "$#" )); do
APP_ARGS="$APP_ARGS $1"
shift
done
source $SCRIPT_DIR/android_setup.sh
source $SCRIPT_DIR/utils/setup_adb.sh
# We need the debug symbols from these files
GDB_TMP_DIR=$(pwd)/android_gdb_tmp
mkdir $GDB_TMP_DIR
echo "Copying symbol files"
adb_pull_if_needed /system/bin/skia_launcher $GDB_TMP_DIR
adb_pull_if_needed /system/lib/libc.so $GDB_TMP_DIR
adb_pull_if_needed /data/data/com.skia/lib/libskia_android.so $GDB_TMP_DIR
adb_pull_if_needed /data/data/com.skia/lib/lib$APP_NAME.so $GDB_TMP_DIR
echo "Checking for skia_launcher app..."
if [ ! -f $GDB_TMP_DIR/skia_launcher ]
then
echo "Unable for find the skia_launcher on the device"
rm -rf $GDB_TMP_DIR
exit 1;
fi
echo "Checking for $APP_NAME library..."
if [ ! -f $GDB_TMP_DIR/lib$APP_NAME.so ]
then
echo "Unable for find the app's shared library on the device"
rm -rf $GDB_TMP_DIR
exit 1;
fi
echo "Pushing gdbserver..."
$ADB remount
$ADB push $ANDROID_TOOLCHAIN/../gdbserver /system/bin/gdbserver
echo "Setting up port forward"
$ADB forward "tcp:5039" "tcp:5039"
# Kill all previous instances of gdbserver and skia_launcher to rid all port overriding errors.
echo "Killing any running Skia processes."
$ADB shell ps | grep gdbserver | awk '{print $2}' | xargs $ADB shell kill
$ADB shell ps | grep skia_launcher | awk '{print $2}' | xargs $ADB shell kill
# Starting up gdbserver in android shell
echo "Starting gdbserver with command: skia_launcher $APP_NAME$APP_ARGS"
$ADB shell gdbserver :5039 /system/bin/skia_launcher $APP_NAME$APP_ARGS &

View File

@ -118,6 +118,9 @@ exportVar RANLIB "$ANDROID_TOOLCHAIN_PREFIX-ranlib"
exportVar OBJCOPY "$ANDROID_TOOLCHAIN_PREFIX-objcopy"
exportVar STRIP "$ANDROID_TOOLCHAIN_PREFIX-strip"
# Use the "android" flavor of the Makefile generator for both Linux and OS X.
exportVar GYP_GENERATORS "make-android"
# Helper function to configure the GYP defines to the appropriate values
# based on the target device.
setup_device() {
@ -184,19 +187,36 @@ setup_device() {
exportVar SKIA_OUT "out/config/android-${TARGET_DEVICE}"
}
# Run the setup device command initially as a convenience for the user
#setup_device
#echo "** The device has been setup for you by default. If you would like to **"
#echo "** use a different device then run the setup_device function with the **"
#echo "** appropriate input. **"
# adb_pull_if_needed(android_src, host_dst)
adb_pull_if_needed() {
# Use the "android" flavor of the Makefile generator for both Linux and OS X.
exportVar GYP_GENERATORS "make-android"
# get adb location
source $SCRIPT_DIR/utils/setup_adb.sh
# Helper function so that when we run "make" to build for clank it exports
# the toolchain variables to make.
#make_android() {
# CC="$CROSS_CC" CXX="$CROSS_CXX" LINK="$CROSS_LINK" \
# AR="$CROSS_AR" RANLIB="$CROSS_RANLIB" \
# command make $*
#}
# read input params
ANDROID_SRC="$1"
HOST_DST="$2"
if [ -d $HOST_DST ];
then
HOST_DST="${HOST_DST}/$(basename ${ANDROID_SRC})"
fi
echo "HOST: $HOST_DST"
if [ -f $HOST_DST ];
then
#get the MD5 for dst and src
ANDROID_MD5=`$ADB shell md5 $ANDROID_SRC`
HOST_MD5=`md5sum $HOST_DST`
if [ "${ANDROID_MD5:0:32}" != "${HOST_MD5:0:32}" ];
then
$ADB pull $ANDROID_SRC $HOST_DST
# else
# echo "md5 match of android [$ANDROID_SRC] and host [$HOST_DST]"
fi
else
$ADB pull $ANDROID_SRC $HOST_DST
fi
}

View File

@ -14,4 +14,4 @@ else
exit 1;
fi
echo "ADB is: $ADB"
#echo "ADB is: $ADB"