OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 # | 2 # |
3 # android_gdb: Pushes parameter binary and gdbserver. Connects | 3 # android_gdb: Pushes parameter binary and gdbserver. Connects |
4 # and enters debugging environment. | 4 # and enters debugging environment. |
5 | 5 |
6 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | 6 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
7 source $SCRIPT_DIR/android_setup.sh | 7 source $SCRIPT_DIR/android_setup.sh |
8 | 8 |
9 APP_NAME=${APP_ARGS[0]} | 9 APP_NAME=${APP_ARGS[0]} |
10 PORT=5039 | 10 PORT=5039 |
11 | 11 |
12 source $SCRIPT_DIR/utils/setup_adb.sh | 12 source $SCRIPT_DIR/utils/setup_adb.sh |
13 | 13 |
14 echo "Installing Skia Android app" | 14 echo "Installing Skia Android app" |
15 $SCRIPT_DIR/android_install_skia -f | 15 $SCRIPT_DIR/android_install_skia_apk -f |
16 | 16 |
17 # Forward local to remote socket connection. | 17 # Forward local to remote socket connection. |
18 $ADB forward "tcp:$PORT" "tcp:$PORT" | 18 $ADB forward "tcp:$PORT" "tcp:$PORT" |
19 | 19 |
20 # We kill all previous instances of gdbserver to rid all port overriding errors. | 20 # We kill all previous instances of gdbserver to rid all port overriding errors. |
21 $ADB shell ps | grep gdbserver | awk '{print $2}' | xargs -r $ADB shell kill | 21 $ADB shell ps | grep gdbserver | awk '{print $2}' | xargs -r $ADB shell kill |
22 | 22 |
23 # We need the debug symbols from these files | 23 # We need the debug symbols from these files |
24 GDB_TMP_DIR=$(pwd)/android_gdb_tmp | 24 GDB_TMP_DIR=$(pwd)/android_gdb_tmp |
25 mkdir -p $GDB_TMP_DIR | 25 mkdir -p $GDB_TMP_DIR |
26 echo "Copying symbol files" | 26 echo "Copying symbol files" |
27 $ADB pull /system/bin/app_process $GDB_TMP_DIR | 27 adb_pull_if_needed /system/bin/app_process $GDB_TMP_DIR |
28 $ADB pull /system/lib/libc.so $GDB_TMP_DIR | 28 adb_pull_if_needed /system/lib/libc.so $GDB_TMP_DIR |
29 $ADB pull /data/data/com.skia/lib/lib$APP_NAME.so $GDB_TMP_DIR | 29 adb_pull_if_needed /data/data/com.skia/lib/libskia_android.so $GDB_TMP_DIR |
| 30 adb_pull_if_needed /data/data/com.skia/lib/libSampleApp.so $GDB_TMP_DIR |
30 | 31 |
31 # Launch the app | 32 # Launch the app |
32 SK_COMMAND="$APP_ARGS" | 33 SK_COMMAND="$APP_ARGS" |
33 echo "Running command $SK_COMMAND" | 34 echo "Running command $SK_COMMAND" |
34 $ADB shell am broadcast -a com.skia.intent.action.LAUNCH_SKIA -n com.skia/.SkiaR
eceiver -e args "$SK_COMMAND" | 35 adb shell am start -n com.skia/com.skia.SkiaSampleActivity |
35 | 36 |
36 # Attach gdbserver to the app process | 37 # Attach gdbserver to the app process |
37 PID=$($ADB shell ps | grep skia_native | awk '{print $2}') | 38 PID=$($ADB shell ps | grep com.skia | awk '{print $2}') |
38 echo "Attaching to pid: $PID" | 39 echo "Attaching to pid: $PID" |
39 $ADB shell /data/data/com.skia/lib/gdbserver :$PORT --attach $PID & | 40 $ADB shell /data/data/com.skia/lib/gdbserver :$PORT --attach $PID & |
40 | 41 |
41 # Wait for gdbserver | 42 # Wait for gdbserver |
42 sleep 2 | 43 sleep 2 |
43 | 44 |
44 # Set up gdb commands | 45 # Set up gdb commands |
45 GDBSETUP=$GDB_TMP_DIR/gdb.setup | 46 GDBSETUP=$GDB_TMP_DIR/gdb.setup |
46 echo "file $GDB_TMP_DIR/app_process" >> $GDBSETUP | 47 echo "file $GDB_TMP_DIR/app_process" >> $GDBSETUP |
47 echo "target remote :$PORT" >> $GDBSETUP | 48 echo "target remote :$PORT" >> $GDBSETUP |
48 echo "set solib-absolute-prefix $GDB_TMP_DIR" >> $GDBSETUP | 49 echo "set solib-absolute-prefix $GDB_TMP_DIR" >> $GDBSETUP |
49 echo "set solib-search-path $GDB_TMP_DIR" >> $GDBSETUP | 50 echo "set solib-search-path $GDB_TMP_DIR" >> $GDBSETUP |
50 | 51 |
51 # Launch gdb client | 52 # Launch gdb client |
52 echo "Entering gdb client shell" | 53 echo "Entering gdb client shell" |
53 if [ "$ANDROID_ARCH" == "x86" ] | 54 if [ "$ANDROID_ARCH" == "x86" ] |
54 then | 55 then |
55 $ANDROID_TOOLCHAIN/i686-linux-android-gdb -x $GDBSETUP | 56 $ANDROID_TOOLCHAIN/i686-linux-android-gdb -x $GDBSETUP |
56 else | 57 else |
57 $ANDROID_TOOLCHAIN/arm-linux-androideabi-gdb -x $GDBSETUP | 58 $ANDROID_TOOLCHAIN/arm-linux-androideabi-gdb -x $GDBSETUP |
58 fi | 59 fi |
59 | 60 |
60 # Clean up | 61 # Clean up |
61 rm -rf $GDB_TMP_DIR | 62 rm -rf $GDB_TMP_DIR |
62 | 63 |
OLD | NEW |