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 | |
15 # Forward local to remote socket connection. | |
16 $ADB forward "tcp:$PORT" "tcp:$PORT" | |
17 | |
18 # We kill all previous instances of gdbserver to rid all port overriding errors. | |
19 $ADB shell ps | grep gdbserver | awk '{print $2}' | xargs -r $ADB shell kill | |
20 | |
21 # We need the debug symbols from these files | |
22 GDB_TMP_DIR=$(pwd)/android_gdb_tmp | |
23 mkdir -p $GDB_TMP_DIR | |
24 echo "Copying symbol files" | |
25 adb_pull_if_needed /system/bin/app_process $GDB_TMP_DIR | |
26 adb_pull_if_needed /system/lib/libc.so $GDB_TMP_DIR | |
27 adb_pull_if_needed /data/data/com.skia/lib/libskia_android.so $GDB_TMP_DIR | |
28 adb_pull_if_needed /data/data/com.skia/lib/libSampleApp.so $GDB_TMP_DIR | |
29 | |
30 echo "Pushing gdbserver..." | |
31 adb_push_if_needed $ANDROID_TOOLCHAIN/../gdbserver /data/local/tmp | |
32 | |
33 # Launch the app | |
34 SK_COMMAND="$APP_ARGS" | |
35 echo "Running command $SK_COMMAND" | |
36 adb shell am start -n com.skia/com.skia.SkiaSampleActivity | |
37 | |
38 # Attach gdbserver to the app process | |
39 PID=$($ADB shell ps | grep com.skia | awk '{print $2}') | |
40 echo "Attaching to pid: $PID" | |
41 $ADB shell /data/local/tmp/gdbserver :$PORT --attach $PID & | |
42 | |
43 # Wait for gdbserver | |
44 sleep 2 | |
45 | |
46 # Set up gdb commands | |
47 GDBSETUP=$GDB_TMP_DIR/gdb.setup | |
48 echo "file $GDB_TMP_DIR/app_process" >> $GDBSETUP | |
49 echo "target remote :$PORT" >> $GDBSETUP | |
50 echo "set solib-absolute-prefix $GDB_TMP_DIR" >> $GDBSETUP | |
51 echo "set solib-search-path $GDB_TMP_DIR" >> $GDBSETUP | |
52 | |
53 # Launch gdb client | |
54 echo "Entering gdb client shell" | |
55 GDB_COMMAND=$(command ls "$ANDROID_TOOLCHAIN"/*-gdb | head -n1) | |
56 "$GDB_COMMAND" -x $GDBSETUP | |
57 | |
58 # Clean up | |
59 rm -rf $GDB_TMP_DIR | |
60 | |
OLD | NEW |