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

Side by Side Diff: build/android/gdb_content_shell

Issue 10736027: Enhancement for gdb_content_shell, allow set package_name and shared_lib_dir (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Refine the patch Created 8 years, 5 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 | « build/android/gdb_apk ('k') | 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 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 # 6 #
7 # Attach gdb to a running content shell. Similar to ndk-gdb. 7 # Attach gdb to a running content shell. Redirect to the shell gdb_apk
8 # Run with --annotate=3 if running under emacs (M-x gdb).
9 #
10 # TODO(jrg): allow package_name and shared_lib_dir to be set on the
11 # command line. Share the guts of this script with other Chromium
12 # pieces (like base_unittests_apk) and friends (like WebKit bundles).
13 8
14 adb=$(which adb) 9 ROOT=$(cd "$(dirname $0)"; pwd)
15 if [[ "$adb" = "" ]] ; then 10
16 echo "Need adb in your path" 11 if [ $# -gt 0 ]; then
17 exit 1 12 exec $ROOT/gdb_apk -r -g "$*"
13 else
14 exec $ROOT/gdb_apk -r
18 fi 15 fi
19
20 rooted_phone=0
21
22 root=$(dirname $0)/../..
23 package_name=org.chromium.content_shell
24 data_dir=/data/data/$package_name
25 gdb_server_on_device=$data_dir/lib/gdbserver
26 shared_lib_dir=$root/out/Release/lib.target
27
28 # Kill any running gdbserver
29 pid=$(adb shell ps | awk '/gdbserver/ {print $2}')
30 if [[ "$pid" != "" ]] ; then
31 if [[ $rooted_phone -eq 1 ]] ; then
32 adb shell kill $pid
33 else
34 adb shell run-as $package_name kill $pid
35 fi
36 fi
37
38 pid=$(adb shell ps | awk "/$package_name/ {print \$2}")
39 if [[ "$pid" = "" ]] ; then
40 echo "No $package_name running?"
41 echo "Try this: adb shell am start -a android.intent.action.VIEW " \
42 "-n $package_name/.SomethingActivity (Something might be ContentShell)"
43 exit 2
44 fi
45
46 no_gdb_server=$(adb shell ls $gdb_server_on_device | grep 'No such file')
47 if [[ "$no_gdb_server" != "" ]] ; then
48 echo "No gdb server on device at $gdb_server_on_device"
49 echo "Please install a debug build."
50 exit 3
51 fi
52
53 if [[ $rooted_phone -eq 1 ]] ; then
54 adb shell $gdb_server_on_device :4321 --attach $pid &
55 adb forward tcp:4321 tcp:4321
56 else
57 adb shell run-as $package_name lib/gdbserver +debug-socket --attach $pid &
58 adb forward tcp:4321 localfilesystem:$data_dir/debug-socket
59 fi
60 sleep 2
61
62 # Pull app_process and C libraries from device if needed
63 app_process=${shared_lib_dir}/app_process
64 if [[ ! -f ${app_process} ]] ; then
65 adb pull /system/bin/app_process ${app_process}
66 adb pull /system/lib/libc.so ${shared_lib_dir}
67 fi
68
69 # gdb commands
70 cmdfile=$(mktemp /tmp/gdb_android_XXXXXXXX)
71 cat >$cmdfile<<EOF
72 # set solib-absolute-prefix null
73 set solib-search-path ${shared_lib_dir}
74 file ${app_process}
75 target remote :4321
76 EOF
77
78 gdb=$(echo $ANDROID_TOOLCHAIN/*gdb)
79 if [[ ! -f ${gdb} ]] ; then
80 echo "Wow no gdb in env var ANDROID_TOOLCHAIN which is $ANDROID_TOOLCHAIN"
81 exit 4
82 else
83 echo Using $gdb
84 fi
85
86 # ${gdb} -x $cmdfile $* $app_process
87 ${gdb} -x $cmdfile $*
88 rm $cmdfile
OLDNEW
« no previous file with comments | « build/android/gdb_apk ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698