aboutsummaryrefslogtreecommitdiffhomepage
path: root/platform_tools/android/bin/android_gdbserver
blob: 5c45b56acd4cb724c0db899f7786eb9e1e900acc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
#
# android_gdbserver: Pushes gdbserver. Starts 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

# We need the debug symbols from these files
GDB_TMP_DIR=$(pwd)/android_gdb_tmp
mkdir $GDB_TMP_DIR
echo "Copying symbol files"
adb_pull_if_needed /system/bin/skia_launcher $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/lib$APP_NAME.so $GDB_TMP_DIR

echo "Checking for skia_launcher app..."
if [ ! -f $GDB_TMP_DIR/skia_launcher ]
then
    echo "Unable for find the skia_launcher on the device"
    rm -rf $GDB_TMP_DIR
    exit 1;
fi

echo "Checking for $APP_NAME library..."
if [ ! -f $GDB_TMP_DIR/lib$APP_NAME.so ]
then
    echo "Unable for find the app's shared library on the device"
    rm -rf $GDB_TMP_DIR
    exit 1;
fi

echo "Pushing gdbserver..."
$ADB remount
$ADB push $ANDROID_TOOLCHAIN/../gdbserver /system/bin/gdbserver

echo "Setting up port forward"
$ADB forward "tcp:5039" "tcp:5039"

# Kill all previous instances of gdbserver and skia_launcher to rid all port overriding errors.
echo "Killing any running Skia processes."
$ADB shell ps | grep gdbserver | awk '{print $2}' | xargs $ADB shell kill
$ADB shell ps | grep skia_launcher | awk '{print $2}' | xargs $ADB shell kill

# Starting up gdbserver in android shell
echo "Starting gdbserver with command: skia_launcher $APP_ARGS"
$ADB shell gdbserver :5039 /system/bin/skia_launcher $APP_ARGS &