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 APP_NAME=$(basename $1) | 7 source $SCRIPT_DIR/android_setup.sh |
| 8 |
| 9 APP_NAME=${APP_ARGS[0]} |
8 PORT=5039 | 10 PORT=5039 |
9 | 11 |
10 # Collect extra arguments to be passed to the Skia binary | |
11 shift | |
12 deviceID="" | |
13 while (( "$#" )); do | |
14 | |
15 if [[ $(echo "$1" | grep "^-d$") != "" ]]; | |
16 then | |
17 deviceID=$2 | |
18 shift | |
19 else | |
20 APP_ARGS="$APP_ARGS $1" | |
21 fi | |
22 | |
23 shift | |
24 done | |
25 | |
26 # hack for x86 support in android_setup.sh | |
27 if [ "$deviceID" == "x86" ] || [ "$deviceID" == "razr_i" ] | |
28 then | |
29 ANDROID_ARCH=x86 | |
30 fi | |
31 | |
32 source $SCRIPT_DIR/android_setup.sh | |
33 source $SCRIPT_DIR/utils/setup_adb.sh | 12 source $SCRIPT_DIR/utils/setup_adb.sh |
34 | 13 |
35 echo "Installing Skia Android app" | 14 echo "Installing Skia Android app" |
36 $SCRIPT_DIR/android_install_skia -f | 15 $SCRIPT_DIR/android_install_skia -f |
37 | 16 |
38 # Forward local to remote socket connection. | 17 # Forward local to remote socket connection. |
39 $ADB forward "tcp:$PORT" "tcp:$PORT" | 18 $ADB forward "tcp:$PORT" "tcp:$PORT" |
40 | 19 |
41 # 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. |
42 $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 |
43 | 22 |
44 # We need the debug symbols from these files | 23 # We need the debug symbols from these files |
45 GDB_TMP_DIR=$(pwd)/android_gdb_tmp | 24 GDB_TMP_DIR=$(pwd)/android_gdb_tmp |
46 mkdir $GDB_TMP_DIR | 25 mkdir -p $GDB_TMP_DIR |
47 echo "Copying symbol files" | 26 echo "Copying symbol files" |
48 $ADB pull /system/bin/app_process $GDB_TMP_DIR | 27 $ADB pull /system/bin/app_process $GDB_TMP_DIR |
49 $ADB pull /system/lib/libc.so $GDB_TMP_DIR | 28 $ADB pull /system/lib/libc.so $GDB_TMP_DIR |
50 $ADB pull /data/data/com.skia/lib/lib$APP_NAME.so $GDB_TMP_DIR | 29 $ADB pull /data/data/com.skia/lib/lib$APP_NAME.so $GDB_TMP_DIR |
51 | 30 |
52 # Launch the app | 31 # Launch the app |
53 SK_COMMAND="$APP_NAME$APP_ARGS" | 32 SK_COMMAND="$APP_ARGS" |
54 echo "Running command $SK_COMMAND" | 33 echo "Running command $SK_COMMAND" |
55 $ADB shell am broadcast -a com.skia.intent.action.LAUNCH_SKIA -n com.skia/.SkiaR
eceiver -e args "$SK_COMMAND" | 34 $ADB shell am broadcast -a com.skia.intent.action.LAUNCH_SKIA -n com.skia/.SkiaR
eceiver -e args "$SK_COMMAND" |
56 | 35 |
57 # Attach gdbserver to the app process | 36 # Attach gdbserver to the app process |
58 PID=$($ADB shell ps | grep skia_native | awk '{print $2}') | 37 PID=$($ADB shell ps | grep skia_native | awk '{print $2}') |
59 echo "Attaching to pid: $PID" | 38 echo "Attaching to pid: $PID" |
60 $ADB shell /data/data/com.skia/lib/gdbserver :$PORT --attach $PID & | 39 $ADB shell /data/data/com.skia/lib/gdbserver :$PORT --attach $PID & |
61 | 40 |
62 # Wait for gdbserver | 41 # Wait for gdbserver |
63 sleep 2 | 42 sleep 2 |
(...skipping 10 matching lines...) Expand all Loading... |
74 if [ "$ANDROID_ARCH" == "x86" ] | 53 if [ "$ANDROID_ARCH" == "x86" ] |
75 then | 54 then |
76 $ANDROID_TOOLCHAIN/i686-linux-android-gdb -x $GDBSETUP | 55 $ANDROID_TOOLCHAIN/i686-linux-android-gdb -x $GDBSETUP |
77 else | 56 else |
78 $ANDROID_TOOLCHAIN/arm-linux-androideabi-gdb -x $GDBSETUP | 57 $ANDROID_TOOLCHAIN/arm-linux-androideabi-gdb -x $GDBSETUP |
79 fi | 58 fi |
80 | 59 |
81 # Clean up | 60 # Clean up |
82 rm -rf $GDB_TMP_DIR | 61 rm -rf $GDB_TMP_DIR |
83 | 62 |
OLD | NEW |