| Index: build/android/gdb_apk
|
| diff --git a/build/android/gdb_content_shell b/build/android/gdb_apk
|
| similarity index 60%
|
| copy from build/android/gdb_content_shell
|
| copy to build/android/gdb_apk
|
| index 2f0b9830c6fbe4ac3d2bd9653257d4ddb2e17687..bcdcd243a6ddcab5fc06e630e0c167a1147dc682 100755
|
| --- a/build/android/gdb_content_shell
|
| +++ b/build/android/gdb_apk
|
| @@ -4,12 +4,13 @@
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
| #
|
| -# Attach gdb to a running content shell. Similar to ndk-gdb.
|
| +# Attach gdb to a running android application. Similar to ndk-gdb.
|
| # Run with --annotate=3 if running under emacs (M-x gdb).
|
| #
|
| -# TODO(jrg): allow package_name and shared_lib_dir to be set on the
|
| -# command line. Share the guts of this script with other Chromium
|
| -# pieces (like base_unittests_apk) and friends (like WebKit bundles).
|
| +# By default it is used to debug content shell, if it is used to
|
| +# debug other piceces, '-p' and '-l' options are needed.
|
| +# For *unittests_apk (like base_unittests_apk), run with:
|
| +# "gdb_apk -p org.chromium.native_test -l out/Release/lib.target -r"
|
|
|
| adb=$(which adb)
|
| if [[ "$adb" = "" ]] ; then
|
| @@ -17,13 +18,63 @@ if [[ "$adb" = "" ]] ; then
|
| exit 1
|
| fi
|
|
|
| +usage() {
|
| + echo "usage: ${0##*/} [-p package_name] [-l shared_lib_dir] [-g gdb] [-r]"
|
| + echo "-p package_name the android APK package to be debugged"
|
| + echo "-l shared_lib_dir directory containes native shared library"
|
| + echo "-g gdb_args agruments for gdb, eg: -g '-n -write'"
|
| + echo "-r the target device is rooted"
|
| +}
|
| +
|
| +process_options() {
|
| + local OPTNAME OPTIND OPTERR OPTARG
|
| + while getopts ":p:l:g:r" OPTNAME; do
|
| + case "$OPTNAME" in
|
| + p)
|
| + package_name="$OPTARG"
|
| + ;;
|
| + l)
|
| + shared_lib_dir="$OPTARG"
|
| + ;;
|
| + g)
|
| + gdb_args="$OPTARG"
|
| + ;;
|
| + r)
|
| + rooted_phone=1
|
| + ;;
|
| + \:)
|
| + echo "'-$OPTARG' needs an argument."
|
| + usage
|
| + exit 1
|
| + ;;
|
| + *)
|
| + echo "invalid command line option: $OPTARG"
|
| + usage
|
| + exit 1
|
| + ;;
|
| + esac
|
| + done
|
| +
|
| + if [ $# -ge ${OPTIND} ]; then
|
| + eval echo "Unexpected command line argument: \${${OPTIND}}"
|
| + usage
|
| + exit 1
|
| + fi
|
| +}
|
| +
|
| rooted_phone=0
|
|
|
| root=$(dirname $0)/../..
|
| package_name=org.chromium.content_shell
|
| +shared_lib_dir=$root/out/Release/lib.target
|
| +gdb_args=''
|
| +
|
| +#process options
|
| +process_options "$@"
|
| +echo "Debug package $package_name"
|
| +
|
| data_dir=/data/data/$package_name
|
| gdb_server_on_device=$data_dir/lib/gdbserver
|
| -shared_lib_dir=$root/out/Release/lib.target
|
|
|
| # Kill any running gdbserver
|
| pid=$(adb shell ps | awk '/gdbserver/ {print $2}')
|
| @@ -84,5 +135,5 @@ else
|
| fi
|
|
|
| # ${gdb} -x $cmdfile $* $app_process
|
| -${gdb} -x $cmdfile $*
|
| +${gdb} -x $cmdfile $gdb_args
|
| rm $cmdfile
|
|
|