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 | 8 |
8 APP_NAME=${APP_ARGS[0]} | 9 configuration="Debug" |
| 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]} |
9 PORT=5039 | 24 PORT=5039 |
10 | 25 |
11 source $SCRIPT_DIR/utils/setup_adb.sh | 26 if [ ! -f "${SKIA_OUT}/${configuration}/lib.target/lib${gdbVars[0]}.so" ]; |
| 27 then |
| 28 echo "Unable to find the ${gdbVars[0]} library" |
| 29 exit 1 |
| 30 fi |
12 | 31 |
13 # We need the debug symbols from these files | 32 # We need the debug symbols from these files |
14 GDB_TMP_DIR=$(pwd)/android_gdb_tmp | 33 GDB_TMP_DIR=$(pwd)/android_gdb_tmp |
15 mkdir $GDB_TMP_DIR | 34 mkdir $GDB_TMP_DIR |
| 35 |
16 echo "Copying symbol files" | 36 echo "Copying symbol files" |
17 adb_pull_if_needed /system/bin/skia_launcher $GDB_TMP_DIR | |
18 adb_pull_if_needed /system/lib/libc.so $GDB_TMP_DIR | 37 adb_pull_if_needed /system/lib/libc.so $GDB_TMP_DIR |
19 adb_pull_if_needed /data/data/com.skia/lib/libskia_android.so $GDB_TMP_DIR | 38 cp "${SKIA_OUT}/${configuration}/skia_launcher" $GDB_TMP_DIR |
20 adb_pull_if_needed /data/data/com.skia/lib/lib$APP_NAME.so $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 |
21 | 41 |
22 echo "Checking for skia_launcher app..." | 42 echo "Pushing app..." |
23 if [ ! -f $GDB_TMP_DIR/skia_launcher ] | 43 adb_push_if_needed "${SKIA_OUT}/${configuration}/skia_launcher" /data/local/tmp |
24 then | 44 adb_push_if_needed "${SKIA_OUT}/${configuration}/lib.target/libskia_android.so"
/data/local/tmp |
25 echo "Unable for find the skia_launcher on the device" | 45 adb_push_if_needed "${SKIA_OUT}/${configuration}/lib.target/lib${APP_NAME}.so" /
data/local/tmp |
26 rm -rf $GDB_TMP_DIR | |
27 exit 1; | |
28 fi | |
29 | |
30 echo "Checking for $APP_NAME library..." | |
31 if [ ! -f $GDB_TMP_DIR/lib$APP_NAME.so ] | |
32 then | |
33 echo "Unable for find the app's shared library on the device" | |
34 rm -rf $GDB_TMP_DIR | |
35 exit 1; | |
36 fi | |
37 | 46 |
38 echo "Pushing gdbserver..." | 47 echo "Pushing gdbserver..." |
39 $ADB remount | 48 adb_push_if_needed $ANDROID_TOOLCHAIN/../gdbserver data/local/tmp |
40 $ADB push $ANDROID_TOOLCHAIN/../gdbserver /system/bin/gdbserver | |
41 | 49 |
42 echo "Setting up port forward" | 50 echo "Setting up port forward" |
43 $ADB forward "tcp:5039" "tcp:5039" | 51 $ADB forward "tcp:5039" "tcp:5039" |
44 | 52 |
45 # Kill all previous instances of gdbserver and skia_launcher to rid all port ove
rriding errors. | 53 # Kill all previous instances of gdbserver and the app to rid all port overridin
g errors. |
46 echo "Killing any running Skia processes." | 54 echo "Killing any running Skia processes." |
47 $ADB shell ps | grep gdbserver | awk '{print $2}' | xargs $ADB shell kill | 55 $ADB shell ps | grep gdbserver | awk '{print $2}' | xargs $ADB shell kill |
48 $ADB shell ps | grep skia_launcher | awk '{print $2}' | xargs $ADB shell kill | 56 $ADB shell ps | grep ${APP_NAME} | awk '{print $2}' | xargs $ADB shell kill |
49 | 57 |
50 # Starting up gdbserver in android shell | 58 # Starting up gdbserver in android shell |
51 echo "Starting gdbserver with command: skia_launcher $APP_ARGS" | 59 echo "Starting gdbserver with command: ${gdbVars[@]}" |
52 $ADB shell gdbserver :5039 /system/bin/skia_launcher $APP_ARGS & | 60 $ADB shell /data/local/tmp/gdbserver :5039 /data/local/tmp/skia_launcher ${gdbVa
rs[@]} & |
OLD | NEW |