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