From 121b3fe6a05cff6a8354ae8b4ba4da1c8edd62c3 Mon Sep 17 00:00:00 2001 From: "djsollen@google.com" Date: Thu, 27 Jun 2013 13:43:04 +0000 Subject: 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 --- platform_tools/android/bin/android_gdb_exe | 62 ++++++--------------------- platform_tools/android/bin/android_gdbserver | 58 +++++++++++++++++++++++++ platform_tools/android/bin/android_setup.sh | 48 +++++++++++++++------ platform_tools/android/bin/utils/setup_adb.sh | 2 +- 4 files changed, 105 insertions(+), 65 deletions(-) create mode 100755 platform_tools/android/bin/android_gdbserver diff --git a/platform_tools/android/bin/android_gdb_exe b/platform_tools/android/bin/android_gdb_exe index 47864ed7a4..5811fba2c9 100755 --- a/platform_tools/android/bin/android_gdb_exe +++ b/platform_tools/android/bin/android_gdb_exe @@ -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; -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; +# quit if gdbserver setup failed +if [[ "$?" != "0" ]]; then + echo "ERROR: gdbserver failed to setup properly." + 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" diff --git a/platform_tools/android/bin/android_gdbserver b/platform_tools/android/bin/android_gdbserver new file mode 100755 index 0000000000..e04710eff4 --- /dev/null +++ b/platform_tools/android/bin/android_gdbserver @@ -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 & \ No newline at end of file diff --git a/platform_tools/android/bin/android_setup.sh b/platform_tools/android/bin/android_setup.sh index e5cea6e863..efd39d1c2d 100755 --- a/platform_tools/android/bin/android_setup.sh +++ b/platform_tools/android/bin/android_setup.sh @@ -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 + + # read input params + ANDROID_SRC="$1" + HOST_DST="$2" -# 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 $* -#} + 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 +} diff --git a/platform_tools/android/bin/utils/setup_adb.sh b/platform_tools/android/bin/utils/setup_adb.sh index 2f4e52956d..40fd65f841 100644 --- a/platform_tools/android/bin/utils/setup_adb.sh +++ b/platform_tools/android/bin/utils/setup_adb.sh @@ -14,4 +14,4 @@ else exit 1; fi -echo "ADB is: $ADB" +#echo "ADB is: $ADB" -- cgit v1.2.3