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