Home | History | Annotate | Download | only in bin
      1 #!/bin/bash
      2 #
      3 # android_gdbserver: Pushes gdbserver. Starts debugging environment.
      4 
      5 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
      6 source $SCRIPT_DIR/android_setup.sh
      7 source $SCRIPT_DIR/utils/setup_adb.sh
      8 
      9 APP_NAME=${APP_ARGS[0]}
     10 PORT=5039
     11 
     12 BUILD_DIR="${SKIA_OUT}/${BUILDTYPE}"
     13 TARGET_LIBRARY="${BUILD_DIR}/lib/lib${APP_NAME}.so"
     14 if [ ! -f "$TARGET_LIBRARY" ]
     15 then
     16   echo "Unable to find the ${APP_NAME} library at ${TARGET_LIBRARY}."
     17   exit 1
     18 fi
     19 
     20 # We need the debug symbols from these files
     21 GDB_TMP_DIR=$(pwd)/android_gdb_tmp
     22 mkdir -p $GDB_TMP_DIR
     23 
     24 echo "Copying symbol files"
     25 SYSTEM_LIBRARY_PATH=/system/lib
     26 for 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
     41 done
     42 
     43 adb_pull_if_needed /system/bin/linker $GDB_TMP_DIR
     44 
     45 echo "Pushing app..."
     46 for 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
     53 done
     54 
     55 echo "Pushing gdbserver..."
     56 adb_push_if_needed $ANDROID_TOOLCHAIN/../gdbserver data/local/tmp
     57 
     58 echo "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.
     62 echo "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
     67 echo "Starting gdbserver with command: ${APP_ARGS[@]}"
     68 $ADB shell /data/local/tmp/gdbserver :5039 /data/local/tmp/skia_launcher ${APP_ARGS[@]} &
     69