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

Side by Side Diff: build/android/adb_gdb

Issue 1659413003: Simplify adb_gdb to accept only --output-directory / CHROMIUM_OUTPUT_DIR (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@adb_gdb-explicit
Patch Set: Created 4 years, 10 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 # 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 7
8 # A generic script used to attach to a running Chromium process and 8 # A generic script used to attach to a running Chromium process and
9 # debug it. Most users should not use this directly, but one of the 9 # debug it. Most users should not use this directly, but one of the
10 # wrapper scripts like adb_gdb_content_shell 10 # wrapper scripts like adb_gdb_content_shell
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 # in the --help output. 77 # in the --help output.
78 # 78 #
79 DEFAULT_ACTIVITY=${ADB_GDB_ACTIVITY:-".Main"} 79 DEFAULT_ACTIVITY=${ADB_GDB_ACTIVITY:-".Main"}
80 80
81 # Allow wrapper scripts to set the program name through ADB_GDB_PROGNAME 81 # Allow wrapper scripts to set the program name through ADB_GDB_PROGNAME
82 PROGNAME=${ADB_GDB_PROGNAME:-$(basename "$0")} 82 PROGNAME=${ADB_GDB_PROGNAME:-$(basename "$0")}
83 83
84 ACTIVITY=$DEFAULT_ACTIVITY 84 ACTIVITY=$DEFAULT_ACTIVITY
85 ADB= 85 ADB=
86 ANNOTATE= 86 ANNOTATE=
87 # Note: Ignore BUILDTYPE variable, because the Ninja build doesn't use it.
88 BUILDTYPE=
89 FORCE= 87 FORCE=
90 GDBEXEPOSTFIX=gdb 88 GDBEXEPOSTFIX=gdb
91 GDBINIT= 89 GDBINIT=
92 GDBSERVER= 90 GDBSERVER=
93 HELP= 91 HELP=
94 NDK_DIR= 92 NDK_DIR=
95 NO_PULL_LIBS= 93 NO_PULL_LIBS=
96 PACKAGE_NAME= 94 PACKAGE_NAME=
97 PID= 95 PID=
98 PORT= 96 PORT=
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 ;; 182 ;;
185 --su-prefix=*) 183 --su-prefix=*)
186 SU_PREFIX=$optarg 184 SU_PREFIX=$optarg
187 ;; 185 ;;
188 --symbol-dir=*) 186 --symbol-dir=*)
189 SYMBOL_DIR=$optarg 187 SYMBOL_DIR=$optarg
190 ;; 188 ;;
191 --output-directory=*) 189 --output-directory=*)
192 CHROMIUM_OUTPUT_DIR=$optarg 190 CHROMIUM_OUTPUT_DIR=$optarg
193 ;; 191 ;;
194 --out-dir=*)
195 CHROMIUM_OUT_DIR=$optarg
196 ;;
197 --target-arch=*) 192 --target-arch=*)
198 TARGET_ARCH=$optarg 193 TARGET_ARCH=$optarg
199 ;; 194 ;;
200 --toolchain=*) 195 --toolchain=*)
201 TOOLCHAIN=$optarg 196 TOOLCHAIN=$optarg
202 ;; 197 ;;
203 --ui) 198 --ui)
204 GDBEXEPOSTFIX=gdbtui 199 GDBEXEPOSTFIX=gdbtui
205 ;; 200 ;;
206 --verbose) 201 --verbose)
207 VERBOSE=$(( $VERBOSE + 1 )) 202 VERBOSE=$(( $VERBOSE + 1 ))
208 ;; 203 ;;
209 --debug)
210 BUILDTYPE=Debug
211 ;;
212 --release)
213 BUILDTYPE=Release
214 ;;
215 -*) 204 -*)
216 panic "Unknown option $opt, see --help." >&2 205 panic "Unknown option $opt, see --help." >&2
217 ;; 206 ;;
218 *) 207 *)
219 if [ "$PACKAGE_NAME" ]; then 208 if [ "$PACKAGE_NAME" ]; then
220 panic "You can only provide a single package name as argument!\ 209 panic "You can only provide a single package name as argument!\
221 See --help." 210 See --help."
222 fi 211 fi
223 PACKAGE_NAME=$opt 212 PACKAGE_NAME=$opt
224 ;; 213 ;;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 251
263 You can also use --ndk-dir=<path> to specify an alternative NDK installation 252 You can also use --ndk-dir=<path> to specify an alternative NDK installation
264 directory. 253 directory.
265 254
266 The script tries to find the most recent version of the debug version of 255 The script tries to find the most recent version of the debug version of
267 shared libraries under one of the following directories: 256 shared libraries under one of the following directories:
268 257
269 \$CHROMIUM_SRC/<out>/lib/ (used by GYP builds) 258 \$CHROMIUM_SRC/<out>/lib/ (used by GYP builds)
270 \$CHROMIUM_SRC/<out>/lib.unstripped/ (used by GN builds) 259 \$CHROMIUM_SRC/<out>/lib.unstripped/ (used by GN builds)
271 260
272 Where <out> is 'out' is determined by CHROMIUM_OUT_DIR, CHROMIUM_OUTPUT_DIR, or 261 Where <out> is determined by CHROMIUM_OUTPUT_DIR, or --output-directory.
273 the --out-dir, --output-directory flags.
274 262
275 You can restrict this search by using --release or --debug to specify the 263 You can set the path manually via --symbol-dir.
276 build type, or simply use --symbol-dir=<path> to specify the file manually.
277 264
278 The script tries to extract the target architecture from your target device, 265 The script tries to extract the target architecture from your target device,
279 but if this fails, will default to 'arm'. Use --target-arch=<name> to force 266 but if this fails, will default to 'arm'. Use --target-arch=<name> to force
280 its value. 267 its value.
281 268
282 Otherwise, the script will complain, but you can use the --gdbserver, 269 Otherwise, the script will complain, but you can use the --gdbserver,
283 --gdb and --symbol-lib options to specify everything manually. 270 --gdb and --symbol-lib options to specify everything manually.
284 271
285 An alternative to --gdb=<file> is to use --toollchain=<path> to specify 272 An alternative to --gdb=<file> is to use --toollchain=<path> to specify
286 the path to the host target-specific cross-toolchain. 273 the path to the host target-specific cross-toolchain.
(...skipping 20 matching lines...) Expand all
307 will be passed to gdb after the remote connection and library symbol 294 will be passed to gdb after the remote connection and library symbol
308 loading have completed. 295 loading have completed.
309 296
310 Valid options: 297 Valid options:
311 --help|-h|-? Print this message. 298 --help|-h|-? Print this message.
312 --verbose Increase verbosity. 299 --verbose Increase verbosity.
313 300
314 --sandboxed Debug first sandboxed process we find. 301 --sandboxed Debug first sandboxed process we find.
315 --sandboxed=<num> Debug specific sandboxed process. 302 --sandboxed=<num> Debug specific sandboxed process.
316 --symbol-dir=<path> Specify directory with symbol shared libraries. 303 --symbol-dir=<path> Specify directory with symbol shared libraries.
317 --out-dir=<path> Specify the out directory (e.g. "out").
318 --output-directory=<path> Specify the output directory (e.g. "out/Debug"). 304 --output-directory=<path> Specify the output directory (e.g. "out/Debug").
319 --package-name=<name> Specify package name (alternative to 1st argument). 305 --package-name=<name> Specify package name (alternative to 1st argument).
320 --privileged Debug first privileged process we find. 306 --privileged Debug first privileged process we find.
321 --privileged=<num> Debug specific privileged process. 307 --privileged=<num> Debug specific privileged process.
322 --program-name=<name> Specify program name (cosmetic only). 308 --program-name=<name> Specify program name (cosmetic only).
323 --pid=<pid> Specify application process pid. 309 --pid=<pid> Specify application process pid.
324 --force Kill any previous debugging session, if any. 310 --force Kill any previous debugging session, if any.
325 --start Start package's activity on device. 311 --start Start package's activity on device.
326 --attach-delay=<num> Seconds to wait for gdbserver to attach to the 312 --attach-delay=<num> Seconds to wait for gdbserver to attach to the
327 remote process before starting gdb. Default 1. 313 remote process before starting gdb. Default 1.
(...skipping 11 matching lines...) Expand all
339 325
340 --su-prefix=<prefix> Prepend <prefix> to 'adb shell' commands that are 326 --su-prefix=<prefix> Prepend <prefix> to 'adb shell' commands that are
341 run by this script. This can be useful to use 327 run by this script. This can be useful to use
342 the 'su' program on rooted production devices. 328 the 'su' program on rooted production devices.
343 e.g. --su-prefix="su -c" 329 e.g. --su-prefix="su -c"
344 330
345 --pull-libs Force system libraries extraction. 331 --pull-libs Force system libraries extraction.
346 --no-pull-libs Do not extract any system library. 332 --no-pull-libs Do not extract any system library.
347 --libs-dir=<path> Specify system libraries extraction directory. 333 --libs-dir=<path> Specify system libraries extraction directory.
348 334
349 --debug Use libraries under out/Debug.
350 --release Use libraries under out/Release.
351
352 EOF 335 EOF
353 exit 0 336 exit 0
354 fi 337 fi
355 338
356 if [ -z "$PACKAGE_NAME" ]; then 339 if [ -z "$PACKAGE_NAME" ]; then
357 panic "Please specify a package name on the command line. See --help." 340 panic "Please specify a package name on the command line. See --help."
358 fi 341 fi
359 342
360 if [[ -z "$CHROMIUM_OUTPUT_DIR" && -z "$CHROMIUM_OUT_DIR" ]]; then 343 if [[ -z "$CHROMIUM_OUTPUT_DIR" ]]; then
watk 2016/02/09 01:04:06 Could you change this to require either --symbol-d
361 if [[ -e "build.ninja" ]]; then 344 if [[ -e "build.ninja" ]]; then
362 CHROMIUM_OUTPUT_DIR=$(pwd) 345 CHROMIUM_OUTPUT_DIR=$(pwd)
363 else 346 else
364 panic "Please specify an output directory using one of: 347 panic "Please specify an output directory using one of:
365 --output-directory=out/Debug 348 --output-directory=out/Debug
366 --out-dir=out/
367 CHROMIUM_OUTPUT_DIR=out/Debug 349 CHROMIUM_OUTPUT_DIR=out/Debug
368 CHROMIUM_OUT_DIR=out
369 Setting working directory to an output directory. 350 Setting working directory to an output directory.
370 See --help." 351 See --help."
371 fi 352 fi
372 fi 353 fi
373 354
374 if [ -z "$NDK_DIR" ]; then 355 if [ -z "$NDK_DIR" ]; then
375 ANDROID_NDK_ROOT=$(PYTHONPATH=$CHROMIUM_SRC/build/android python -c \ 356 ANDROID_NDK_ROOT=$(PYTHONPATH=$CHROMIUM_SRC/build/android python -c \
376 'from pylib.constants import ANDROID_NDK_ROOT; print ANDROID_NDK_ROOT,') 357 'from pylib.constants import ANDROID_NDK_ROOT; print ANDROID_NDK_ROOT,')
377 else 358 else
378 if [ ! -d "$NDK_DIR" ]; then 359 if [ ! -d "$NDK_DIR" ]; then
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 690
710 # Return the timestamp of a given file, as number of seconds since epoch. 691 # Return the timestamp of a given file, as number of seconds since epoch.
711 # $1: file path 692 # $1: file path
712 # Out: file timestamp 693 # Out: file timestamp
713 get_file_timestamp () { 694 get_file_timestamp () {
714 stat -c %Y "$1" 2>/dev/null 695 stat -c %Y "$1" 2>/dev/null
715 } 696 }
716 697
717 # Detect the build type and symbol directory. This is done by finding 698 # Detect the build type and symbol directory. This is done by finding
718 # the most recent sub-directory containing debug shared libraries under 699 # the most recent sub-directory containing debug shared libraries under
719 # (in order of priority): 700 # $CHROMIUM_OUTPUT_DIR.
720 # 1. $CHROMIUM_OUTPUT_DIR
721 # 2. $CHROMIUM_SRC/$CHROMIUM_OUT_DIR/$BUILDTYPE (if $BUILDTYPE is set)
722 # 3. $CHROMIUM_SRC/$CHROMIUM_OUT_DIR/{Debug,Release}
723 # 701 #
724 # Out: nothing, but this sets SYMBOL_DIR 702 # Out: nothing, but this sets SYMBOL_DIR
725 # 703 #
726 detect_symbol_dir () { 704 detect_symbol_dir () {
727 local PARENT_DIR SUBDIRS SUBDIR LIST DIR DIR_LIBS TSTAMP 705 # GYP places unstripped libraries under out/lib
728 # GYP places unstripped libraries under out/$BUILDTYPE/lib 706 # GN places them under out/lib.unstripped
729 # GN places them under out/$BUILDTYPE/lib.unstripped 707 local PARENT_DIR="$CHROMIUM_OUTPUT_DIR"
730 if [[ -n "$CHROMIUM_OUTPUT_DIR" ]]; then
731 PARENT_DIR="$CHROMIUM_OUTPUT_DIR"
732 SUBDIRS="lib.unstripped lib"
733 else
734 PARENT_DIR="$CHROMIUM_OUT_DIR"
735 if [[ -n "$BUILDTYPE" ]]; then
736 PARENT_DIR="$PARENT_DIR/$BUILDTYPE"
737 SUBDIRS="lib.unstripped lib"
738 else
739 SUBDIRS="Release/lib.unstripped Debug/lib.unstripped "
740 SUBDIRS+="Release/lib Debug/lib"
741 fi
742 fi
743 if [[ ! -e "$PARENT_DIR" ]]; then 708 if [[ ! -e "$PARENT_DIR" ]]; then
744 PARENT_DIR="$CHROMIUM_SRC/$PARENT_DIR" 709 PARENT_DIR="$CHROMIUM_SRC/$PARENT_DIR"
745 fi 710 fi
746 LIST=$TMPDIR/scan-subdirs-$$.txt 711 SYMBOL_DIR="$PARENT_DIR/lib.unstripped"
747 printf "" > "$LIST" 712 if [[ -z "$(ls "$SYMBOL_DIR"/lib*.so 2>/dev/null)" ]]; then
748 for SUBDIR in $SUBDIRS; do 713 SYMBOL_DIR="$PARENT_DIR/lib"
749 DIR="$PARENT_DIR/$SUBDIR" 714 if [[ -z "$(ls "$SYMBOL_DIR"/lib*.so 2>/dev/null)" ]]; then
750 if [ -d "$DIR" ]; then 715 panic "Could not find any symbols under \
751 # Ignore build directories that don't contain symbol versions 716 $PARENT_DIR/lib{.unstripped}. Please build the program first!"
752 # of the shared libraries.
753 DIR_LIBS=$(ls "$DIR"/lib*.so 2>/dev/null)
754 if [ -z "$DIR_LIBS" ]; then
755 echo "No shared libs: $DIR"
756 continue
757 fi
758 TSTAMP=$(get_file_timestamp "$DIR")
759 printf "%s %s\n" "$TSTAMP" "$SUBDIR" >> "$LIST"
760 fi 717 fi
761 done
762 SUBDIR=$(cat $LIST | sort -r | head -1 | cut -d" " -f2)
763 rm -f "$LIST"
764
765 if [[ -z "$SUBDIR" ]]; then
766 panic "Could not find any build directory under \
767 $PARENT_DIR/{${SUBDIRS// /,}}. Please build the program first!"
768 fi 718 fi
769
770 SYMBOL_DIR=$PARENT_DIR/$SUBDIR
771 log "Auto-config: --symbol-dir=$SYMBOL_DIR" 719 log "Auto-config: --symbol-dir=$SYMBOL_DIR"
772 } 720 }
773 721
774 if [ -z "$SYMBOL_DIR" ]; then 722 if [ -z "$SYMBOL_DIR" ]; then
775 detect_symbol_dir 723 detect_symbol_dir
776 fi 724 fi
777 725
778 # Allow several concurrent debugging sessions 726 # Allow several concurrent debugging sessions
779 TARGET_GDBSERVER=/data/data/$PACKAGE_NAME/gdbserver-adb-gdb-$TMP_ID 727 TARGET_GDBSERVER=/data/data/$PACKAGE_NAME/gdbserver-adb-gdb-$TMP_ID
780 TMP_TARGET_GDBSERVER=/data/local/tmp/gdbserver-adb-gdb-$TMP_ID 728 TMP_TARGET_GDBSERVER=/data/local/tmp/gdbserver-adb-gdb-$TMP_ID
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 1018
1071 if [ "$VERBOSE" -gt 0 ]; then 1019 if [ "$VERBOSE" -gt 0 ]; then
1072 echo "### START $COMMANDS" 1020 echo "### START $COMMANDS"
1073 cat $COMMANDS 1021 cat $COMMANDS
1074 echo "### END $COMMANDS" 1022 echo "### END $COMMANDS"
1075 fi 1023 fi
1076 1024
1077 log "Launching gdb client: $GDB $GDB_ARGS -x $COMMANDS" 1025 log "Launching gdb client: $GDB $GDB_ARGS -x $COMMANDS"
1078 $GDB $GDB_ARGS -x $COMMANDS && 1026 $GDB $GDB_ARGS -x $COMMANDS &&
1079 rm -f "$GDBSERVER_PIDFILE" 1027 rm -f "$GDBSERVER_PIDFILE"
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