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

Side by Side Diff: build/android/gdb_apk

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 | « no previous file | build/android/gdb_content_shell » ('j') | 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 android application. Similar to ndk-gdb.
8 # Run with --annotate=3 if running under emacs (M-x gdb). 8 # Run with --annotate=3 if running under emacs (M-x gdb).
9 # 9 #
10 # TODO(jrg): allow package_name and shared_lib_dir to be set on the 10 # By default it is used to debug content shell, if it is used to
11 # command line. Share the guts of this script with other Chromium 11 # debug other piceces, '-p' and '-l' options are needed.
12 # pieces (like base_unittests_apk) and friends (like WebKit bundles). 12 # For *unittests_apk (like base_unittests_apk), run with:
13 # "gdb_apk -p org.chromium.native_test -l out/Release/lib.target -r"
13 14
14 adb=$(which adb) 15 adb=$(which adb)
15 if [[ "$adb" = "" ]] ; then 16 if [[ "$adb" = "" ]] ; then
16 echo "Need adb in your path" 17 echo "Need adb in your path"
17 exit 1 18 exit 1
18 fi 19 fi
19 20
21 usage() {
22 echo "usage: ${0##*/} [-p package_name] [-l shared_lib_dir] [-g gdb] [-r]"
23 echo "-p package_name the android APK package to be debugged"
24 echo "-l shared_lib_dir directory containes native shared library"
25 echo "-g gdb_args agruments for gdb, eg: -g '-n -write'"
26 echo "-r the target device is rooted"
27 }
28
29 process_options() {
30 local OPTNAME OPTIND OPTERR OPTARG
31 while getopts ":p:l:g:r" OPTNAME; do
32 case "$OPTNAME" in
33 p)
34 package_name="$OPTARG"
35 ;;
36 l)
37 shared_lib_dir="$OPTARG"
38 ;;
39 g)
40 gdb_args="$OPTARG"
41 ;;
42 r)
43 rooted_phone=1
44 ;;
45 \:)
46 echo "'-$OPTARG' needs an argument."
47 usage
48 exit 1
49 ;;
50 *)
51 echo "invalid command line option: $OPTARG"
52 usage
53 exit 1
54 ;;
55 esac
56 done
57
58 if [ $# -ge ${OPTIND} ]; then
59 eval echo "Unexpected command line argument: \${${OPTIND}}"
60 usage
61 exit 1
62 fi
63 }
64
20 rooted_phone=0 65 rooted_phone=0
21 66
22 root=$(dirname $0)/../.. 67 root=$(dirname $0)/../..
23 package_name=org.chromium.content_shell 68 package_name=org.chromium.content_shell
69 shared_lib_dir=$root/out/Release/lib.target
70 gdb_args=''
71
72 #process options
73 process_options "$@"
74 echo "Debug package $package_name"
75
24 data_dir=/data/data/$package_name 76 data_dir=/data/data/$package_name
25 gdb_server_on_device=$data_dir/lib/gdbserver 77 gdb_server_on_device=$data_dir/lib/gdbserver
26 shared_lib_dir=$root/out/Release/lib.target
27 78
28 # Kill any running gdbserver 79 # Kill any running gdbserver
29 pid=$(adb shell ps | awk '/gdbserver/ {print $2}') 80 pid=$(adb shell ps | awk '/gdbserver/ {print $2}')
30 if [[ "$pid" != "" ]] ; then 81 if [[ "$pid" != "" ]] ; then
31 if [[ $rooted_phone -eq 1 ]] ; then 82 if [[ $rooted_phone -eq 1 ]] ; then
32 adb shell kill $pid 83 adb shell kill $pid
33 else 84 else
34 adb shell run-as $package_name kill $pid 85 adb shell run-as $package_name kill $pid
35 fi 86 fi
36 fi 87 fi
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 128
78 gdb=$(echo $ANDROID_TOOLCHAIN/*gdb) 129 gdb=$(echo $ANDROID_TOOLCHAIN/*gdb)
79 if [[ ! -f ${gdb} ]] ; then 130 if [[ ! -f ${gdb} ]] ; then
80 echo "Wow no gdb in env var ANDROID_TOOLCHAIN which is $ANDROID_TOOLCHAIN" 131 echo "Wow no gdb in env var ANDROID_TOOLCHAIN which is $ANDROID_TOOLCHAIN"
81 exit 4 132 exit 4
82 else 133 else
83 echo Using $gdb 134 echo Using $gdb
84 fi 135 fi
85 136
86 # ${gdb} -x $cmdfile $* $app_process 137 # ${gdb} -x $cmdfile $* $app_process
87 ${gdb} -x $cmdfile $* 138 ${gdb} -x $cmdfile $gdb_args
88 rm $cmdfile 139 rm $cmdfile
OLDNEW
« no previous file with comments | « no previous file | build/android/gdb_content_shell » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698