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