diff options
author | 2015-02-03 15:07:30 -0800 | |
---|---|---|
committer | 2015-02-03 15:07:30 -0800 | |
commit | 6429fd1e41129fb960d1ff341a1befe8ac932600 (patch) | |
tree | 0b17cf0a0726f72480b2d6262c9ada89f867c02b /platform_tools/android/bin/android_gdb_app | |
parent | 74a11753604768bf461b80cabb66060e8564d82c (diff) |
Cleanup the android scripts.
Rename a few files to make their function clearer.
Update other files to remove dead code or improve function.
Review URL: https://codereview.chromium.org/865943007
Diffstat (limited to 'platform_tools/android/bin/android_gdb_app')
-rwxr-xr-x | platform_tools/android/bin/android_gdb_app | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/platform_tools/android/bin/android_gdb_app b/platform_tools/android/bin/android_gdb_app new file mode 100755 index 0000000000..000d908005 --- /dev/null +++ b/platform_tools/android/bin/android_gdb_app @@ -0,0 +1,73 @@ +#!/bin/bash +# +# android_gdb_app: Pushes gdbserver, launches sampleApp, and connects +# the debugging environment. + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $SCRIPT_DIR/android_setup.sh + +APP_NAME=${APP_ARGS[0]} +PORT=5039 + +source $SCRIPT_DIR/utils/setup_adb.sh + + +# Forward local to remote socket connection. +$ADB $DEVICE_SERIAL forward "tcp:$PORT" "tcp:$PORT" + +# We kill all previous instances of gdbserver to rid all port overriding errors. +if [ $(uname) == "Linux" ]; then + $ADB $DEVICE_SERIAL shell ps | grep gdbserver | awk '{print $2}' | xargs -r $ADB $DEVICE_SERIAL shell kill +elif [ $(uname) == "Darwin" ]; then + $ADB $DEVICE_SERIAL shell ps | grep gdbserver | awk '{print $2}' | xargs $ADB $DEVICE_SERIAL shell kill +else + echo "Could not automatically determine OS!" + exit 1; +fi + +# We need the debug symbols from these files +GDB_TMP_DIR=$(pwd)/android_gdb_tmp +mkdir -p $GDB_TMP_DIR +echo "Copying symbol files" +adb_pull_if_needed /system/bin/app_process $GDB_TMP_DIR +adb_pull_if_needed /system/lib/libc.so $GDB_TMP_DIR +adb_pull_if_needed /data/data/com.skia/lib/libskia_android.so $GDB_TMP_DIR +adb_pull_if_needed /data/data/com.skia/lib/libSampleApp.so $GDB_TMP_DIR + +echo "Pushing gdbserver..." +adb_push_if_needed $ANDROID_TOOLCHAIN/../gdbserver /data/local/tmp + +# Launch the app +echo "Launching the app..." +$ADB $DEVICE_SERIAL shell am start -n com.skia/com.skia.SkiaSampleActivity + +# Wait for app process to initialize +sleep 2 + +# Attach gdbserver to the app process +PID=$($ADB shell ps | grep com.skia | awk '{print $2}') +echo "Attaching to pid: $PID" +$ADB $DEVICE_SERIAL shell /data/local/tmp/gdbserver :$PORT --attach $PID & + +# Wait for gdbserver +sleep 2 + +# Set up gdb commands +GDBSETUP=$GDB_TMP_DIR/gdb.setup +echo "file $GDB_TMP_DIR/app_process" >> $GDBSETUP +echo "target remote :$PORT" >> $GDBSETUP +echo "set solib-absolute-prefix $GDB_TMP_DIR" >> $GDBSETUP +echo "set solib-search-path $GDB_TMP_DIR" >> $GDBSETUP + +# Launch gdb client +echo "Entering gdb client shell" +GDB_COMMAND=$(command ls "$ANDROID_TOOLCHAIN"/*-gdb | head -n1) +"$GDB_COMMAND" -x $GDBSETUP + +# Clean up: +# We could 'rm -rf $GDB_TMP_DIR', but doing so would cause subsequent debugging +# sessions to take longer than necessary. The tradeoff is to now force the user +# to remove the directory when they are done debugging. +rm $GDBSETUP + + |