OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 # | 2 # |
3 # android_gdb: Pushes gdbserver. Connects and enters 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 APP_NAME=$(basename $1) | 6 APP_NAME=$(basename $1) |
7 PORT=5039 | 7 PORT=5039 |
8 | 8 |
9 # Collect extra arguments to be passed to the Skia binary | 9 # Collect extra arguments to be passed to the Skia binary |
10 shift | 10 shift |
11 while (( "$#" )); do | 11 while (( "$#" )); do |
12 APP_ARGS="$APP_ARGS $1" | 12 APP_ARGS="$APP_ARGS $1" |
13 shift | 13 shift |
14 done | 14 done |
15 | 15 |
16 source $SCRIPT_DIR/android_setup.sh | 16 source $SCRIPT_DIR/android_setup.sh |
17 source $SCRIPT_DIR/utils/setup_adb.sh | 17 source $SCRIPT_DIR/utils/setup_adb.sh |
18 | 18 |
19 # We need the debug symbols from these files | 19 # We need the debug symbols from these files |
20 GDB_TMP_DIR=$(pwd)/android_gdb_tmp | 20 GDB_TMP_DIR=$(pwd)/android_gdb_tmp |
21 mkdir $GDB_TMP_DIR | 21 mkdir $GDB_TMP_DIR |
22 echo "Copying symbol files" | 22 echo "Copying symbol files" |
23 $ADB pull /system/bin/skia_launcher $GDB_TMP_DIR | 23 adb_pull_if_needed /system/bin/skia_launcher $GDB_TMP_DIR |
24 $ADB pull /system/lib/libc.so $GDB_TMP_DIR | 24 adb_pull_if_needed /system/lib/libc.so $GDB_TMP_DIR |
25 $ADB pull /data/data/com.skia/lib/libskia_android.so $GDB_TMP_DIR | 25 adb_pull_if_needed /data/data/com.skia/lib/libskia_android.so $GDB_TMP_DIR |
26 $ADB pull /data/data/com.skia/lib/lib$APP_NAME.so $GDB_TMP_DIR | 26 adb_pull_if_needed /data/data/com.skia/lib/lib$APP_NAME.so $GDB_TMP_DIR |
27 | 27 |
28 echo "Checking for skia_launcher app..." | 28 echo "Checking for skia_launcher app..." |
29 if [ ! -f $GDB_TMP_DIR/skia_launcher ] | 29 if [ ! -f $GDB_TMP_DIR/skia_launcher ] |
30 then | 30 then |
31 echo "Unable for find the skia_launcher on the device" | 31 echo "Unable for find the skia_launcher on the device" |
32 rm -rf $GDB_TMP_DIR | 32 rm -rf $GDB_TMP_DIR |
33 exit 1; | 33 exit 1; |
34 fi | 34 fi |
35 | 35 |
36 echo "Checking for $APP_NAME library..." | 36 echo "Checking for $APP_NAME library..." |
(...skipping 11 matching lines...) Expand all Loading... |
48 echo "Setting up port forward" | 48 echo "Setting up port forward" |
49 $ADB forward "tcp:5039" "tcp:5039" | 49 $ADB forward "tcp:5039" "tcp:5039" |
50 | 50 |
51 # Kill all previous instances of gdbserver and skia_launcher to rid all port ove
rriding errors. | 51 # Kill all previous instances of gdbserver and skia_launcher to rid all port ove
rriding errors. |
52 echo "Killing any running Skia processes." | 52 echo "Killing any running Skia processes." |
53 $ADB shell ps | grep gdbserver | awk '{print $2}' | xargs $ADB shell kill | 53 $ADB shell ps | grep gdbserver | awk '{print $2}' | xargs $ADB shell kill |
54 $ADB shell ps | grep skia_launcher | awk '{print $2}' | xargs $ADB shell kill | 54 $ADB shell ps | grep skia_launcher | awk '{print $2}' | xargs $ADB shell kill |
55 | 55 |
56 # Starting up gdbserver in android shell | 56 # Starting up gdbserver in android shell |
57 echo "Starting gdbserver with command: skia_launcher $APP_NAME$APP_ARGS" | 57 echo "Starting gdbserver with command: skia_launcher $APP_NAME$APP_ARGS" |
58 $ADB shell gdbserver :5039 /system/bin/skia_launcher $APP_NAME$APP_ARGS & | 58 $ADB shell gdbserver :5039 /system/bin/skia_launcher $APP_NAME$APP_ARGS & |
59 | |
60 # Wait for gdbserver | |
61 sleep 2 | |
62 | |
63 # Set up gdb commands | |
64 GDBSETUP=$GDB_TMP_DIR/gdb.setup | |
65 echo "file $GDB_TMP_DIR/skia_launcher" >> $GDBSETUP | |
66 echo "target remote :$PORT" >> $GDBSETUP | |
67 echo "set solib-absolute-prefix $GDB_TMP_DIR" >> $GDBSETUP | |
68 echo "set solib-search-path $GDB_TMP_DIR" >> $GDBSETUP | |
69 | |
70 # The apps shared library symbols are not loaded by default so we load them here | |
71 echo "break skia_launcher.cpp:launch_app" >> $GDBSETUP | |
72 echo "continue" >> $GDBSETUP | |
73 echo "sharedLibrary $APP_NAME" >> $GDBSETUP | |
74 | |
75 | |
76 # Launch gdb client | |
77 echo "Entering gdb client shell" | |
78 $ANDROID_TOOLCHAIN/arm-linux-androideabi-gdb -x $GDBSETUP | |
79 | |
80 # Clean up | |
81 rm -rf $GDB_TMP_DIR | |
OLD | NEW |