Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Side by Side Diff: platform_tools/android/bin/android_gdb_app

Issue 2055453003: Support running Viewer via android_gdb_app (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 # 2 #
3 # android_gdb_app: Pushes gdbserver, launches sampleApp, and connects 3 # android_gdb_app: Pushes gdbserver, launches sampleApp, and connects
4 # the debugging environment. 4 # the debugging environment.
5 5
6 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 6 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
7 source $SCRIPT_DIR/android_setup.sh "$@" 7 source $SCRIPT_DIR/android_setup.sh "$@"
8 source $SCRIPT_DIR/utils/setup_adb.sh
8 9
9 APP_NAME=${APP_ARGS[0]} 10 app=${APP_ARGS[0]}
11 if [[ ${app} == '-'* ]]; then
12 echo "Defaulting to running SampleApp."
13 app="SampleApp"
14 APP_ARGS=( "SampleApp" ${APP_ARGS[*]} )
15 fi
10 PORT=5039 16 PORT=5039
11 17
12 source $SCRIPT_DIR/utils/setup_adb.sh 18 if [[ ${app} == 'SampleApp' ]]; then
13 19 activity="com.skia.sample_app/com.skia.SkiaSampleActivity"
20 activityShort="com.skia.sample_app"
21 elif [[ ${app} == "Viewer" ]] ; then
22 activity="org.skia.viewer/org.skia.viewer.ViewerActivity"
23 activityShort="org.skia.viewer"
24 else
25 echo "ERROR: supports either 'SampleApp' or 'Viewer' as valid apps"
26 exit 1
27 fi
14 28
15 # Forward local to remote socket connection. 29 # Forward local to remote socket connection.
16 $ADB $DEVICE_SERIAL forward "tcp:$PORT" "tcp:$PORT" 30 $ADB $DEVICE_SERIAL forward "tcp:$PORT" "tcp:$PORT"
17 31
18 # We kill all previous instances of gdbserver to rid all port overriding errors. 32 # We kill all previous instances of gdbserver to rid all port overriding errors.
19 if [ $(uname) == "Linux" ]; then 33 if [ $(uname) == "Linux" ]; then
20 $ADB $DEVICE_SERIAL shell ps | grep gdbserver | awk '{print $2}' | xargs -r $ADB $DEVICE_SERIAL shell kill 34 $ADB $DEVICE_SERIAL shell ps | grep gdbserver | awk '{print $2}' | xargs -r $ADB $DEVICE_SERIAL shell kill
21 elif [ $(uname) == "Darwin" ]; then 35 elif [ $(uname) == "Darwin" ]; then
22 $ADB $DEVICE_SERIAL shell ps | grep gdbserver | awk '{print $2}' | xargs $AD B $DEVICE_SERIAL shell kill 36 $ADB $DEVICE_SERIAL shell ps | grep gdbserver | awk '{print $2}' | xargs $AD B $DEVICE_SERIAL shell kill
23 else 37 else
24 echo "Could not automatically determine OS!" 38 echo "Could not automatically determine OS!"
25 exit 1; 39 exit 1;
26 fi 40 fi
27 41
28 # We need the debug symbols from these files 42 # We need the debug symbols from these files
29 GDB_TMP_DIR=$SKIA_OUT/android_gdb_tmp 43 GDB_TMP_DIR=$SKIA_OUT/android_gdb_tmp
30 mkdir -p $GDB_TMP_DIR 44 mkdir -p $GDB_TMP_DIR
31 45
32 echo "Pushing gdbserver..." 46 echo "Pushing gdbserver..."
33 adb_push_if_needed $ANDROID_TOOLCHAIN/gdbserver /data/local/tmp 47 adb_push_if_needed $ANDROID_TOOLCHAIN/gdbserver /data/local/tmp
34 48
35 # Launch the app 49 # Launch the app
36 echo "Launching the app..." 50 echo "Launching the app..."
37 $ADB $DEVICE_SERIAL shell am start -n com.skia.sample_app/com.skia.SkiaSampleAct ivity 51 $ADB $DEVICE_SERIAL shell "am start -n ${activity} --es cmdLineFlags \"${APP_ARG S[*]:1}\""
38 52
39 # Wait for app process to initialize 53 # Wait for app process to initialize
40 sleep 2 54 sleep 2
41 55
42 # Attach gdbserver to the app process 56 # Attach gdbserver to the app process
43 PID=$($ADB shell ps | grep com.skia.sample_app | awk '{print $2}') 57 PID=$($ADB shell ps | grep ${activityShort} | awk '{print $2}')
44 echo "Attaching to pid: $PID" 58 echo "Attaching to pid: $PID"
45 $ADB $DEVICE_SERIAL shell /data/local/tmp/gdbserver :$PORT --attach $PID & 59 $ADB $DEVICE_SERIAL shell /data/local/tmp/gdbserver :$PORT --attach $PID &
46 60
47 # Wait for gdbserver 61 # Wait for gdbserver
48 sleep 2 62 sleep 2
49 63
50 # Set up gdb commands 64 # Set up gdb commands
51 GDBSETUP=$GDB_TMP_DIR/gdb.setup 65 GDBSETUP=$GDB_TMP_DIR/gdb.setup
52 echo "target remote :$PORT" >> $GDBSETUP 66 echo "target remote :$PORT" >> $GDBSETUP
53 67
54 68
55 # Launch gdb client 69 # Launch gdb client
56 echo "Entering gdb client shell" 70 echo "Entering gdb client shell"
57 ${ANDROID_TOOLCHAIN}/host_prebuilt/bin/gdb-orig -x $GDBSETUP 71 ${ANDROID_TOOLCHAIN}/host_prebuilt/bin/gdb-orig -x $GDBSETUP
58 72
59 # Clean up: 73 # Clean up:
60 # We could 'rm -rf $GDB_TMP_DIR', but doing so would cause subsequent debugging 74 # We could 'rm -rf $GDB_TMP_DIR', but doing so would cause subsequent debugging
61 # sessions to take longer than necessary. The tradeoff is to now force the user 75 # sessions to take longer than necessary. The tradeoff is to now force the user
62 # to remove the directory when they are done debugging. 76 # to remove the directory when they are done debugging.
63 rm $GDBSETUP 77 rm $GDBSETUP
64 78
65 79
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698