OLD | NEW |
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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 ;; | 181 ;; |
182 --attach-delay=*) | 182 --attach-delay=*) |
183 ATTACH_DELAY=$optarg | 183 ATTACH_DELAY=$optarg |
184 ;; | 184 ;; |
185 --su-prefix=*) | 185 --su-prefix=*) |
186 SU_PREFIX=$optarg | 186 SU_PREFIX=$optarg |
187 ;; | 187 ;; |
188 --symbol-dir=*) | 188 --symbol-dir=*) |
189 SYMBOL_DIR=$optarg | 189 SYMBOL_DIR=$optarg |
190 ;; | 190 ;; |
191 --output-dir=*) | 191 --output-directory=*) |
192 CHROMIUM_OUTPUT_DIR=$optarg | 192 CHROMIUM_OUTPUT_DIR=$optarg |
193 ;; | 193 ;; |
194 --out-dir=*) | 194 --out-dir=*) |
195 CHROMIUM_OUT_DIR=$optarg | 195 CHROMIUM_OUT_DIR=$optarg |
196 ;; | 196 ;; |
197 --target-arch=*) | 197 --target-arch=*) |
198 TARGET_ARCH=$optarg | 198 TARGET_ARCH=$optarg |
199 ;; | 199 ;; |
200 --toolchain=*) | 200 --toolchain=*) |
201 TOOLCHAIN=$optarg | 201 TOOLCHAIN=$optarg |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 You can also use --ndk-dir=<path> to specify an alternative NDK installation | 263 You can also use --ndk-dir=<path> to specify an alternative NDK installation |
264 directory. | 264 directory. |
265 | 265 |
266 The script tries to find the most recent version of the debug version of | 266 The script tries to find the most recent version of the debug version of |
267 shared libraries under one of the following directories: | 267 shared libraries under one of the following directories: |
268 | 268 |
269 \$CHROMIUM_SRC/<out>/lib/ (used by GYP builds) | 269 \$CHROMIUM_SRC/<out>/lib/ (used by GYP builds) |
270 \$CHROMIUM_SRC/<out>/lib.unstripped/ (used by GN builds) | 270 \$CHROMIUM_SRC/<out>/lib.unstripped/ (used by GN builds) |
271 | 271 |
272 Where <out> is 'out' is determined by CHROMIUM_OUT_DIR, CHROMIUM_OUTPUT_DIR, or | 272 Where <out> is 'out' is determined by CHROMIUM_OUT_DIR, CHROMIUM_OUTPUT_DIR, or |
273 the --out-dir, --output-dir flags. | 273 the --out-dir, --output-directory flags. |
274 | 274 |
275 You can restrict this search by using --release or --debug to specify the | 275 You can restrict this search by using --release or --debug to specify the |
276 build type, or simply use --symbol-dir=<path> to specify the file manually. | 276 build type, or simply use --symbol-dir=<path> to specify the file manually. |
277 | 277 |
278 The script tries to extract the target architecture from your target device, | 278 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 | 279 but if this fails, will default to 'arm'. Use --target-arch=<name> to force |
280 its value. | 280 its value. |
281 | 281 |
282 Otherwise, the script will complain, but you can use the --gdbserver, | 282 Otherwise, the script will complain, but you can use the --gdbserver, |
283 --gdb and --symbol-lib options to specify everything manually. | 283 --gdb and --symbol-lib options to specify everything manually. |
(...skipping 24 matching lines...) Expand all Loading... |
308 loading have completed. | 308 loading have completed. |
309 | 309 |
310 Valid options: | 310 Valid options: |
311 --help|-h|-? Print this message. | 311 --help|-h|-? Print this message. |
312 --verbose Increase verbosity. | 312 --verbose Increase verbosity. |
313 | 313 |
314 --sandboxed Debug first sandboxed process we find. | 314 --sandboxed Debug first sandboxed process we find. |
315 --sandboxed=<num> Debug specific sandboxed process. | 315 --sandboxed=<num> Debug specific sandboxed process. |
316 --symbol-dir=<path> Specify directory with symbol shared libraries. | 316 --symbol-dir=<path> Specify directory with symbol shared libraries. |
317 --out-dir=<path> Specify the out directory (e.g. "out"). | 317 --out-dir=<path> Specify the out directory (e.g. "out"). |
318 --output-dir=<path> Specify the output directory (e.g. "out/Debug"). | 318 --output-directory=<path> Specify the output directory (e.g. "out/Debug"). |
319 --package-name=<name> Specify package name (alternative to 1st argument). | 319 --package-name=<name> Specify package name (alternative to 1st argument). |
320 --privileged Debug first privileged process we find. | 320 --privileged Debug first privileged process we find. |
321 --privileged=<num> Debug specific privileged process. | 321 --privileged=<num> Debug specific privileged process. |
322 --program-name=<name> Specify program name (cosmetic only). | 322 --program-name=<name> Specify program name (cosmetic only). |
323 --pid=<pid> Specify application process pid. | 323 --pid=<pid> Specify application process pid. |
324 --force Kill any previous debugging session, if any. | 324 --force Kill any previous debugging session, if any. |
325 --start Start package's activity on device. | 325 --start Start package's activity on device. |
326 --attach-delay=<num> Seconds to wait for gdbserver to attach to the | 326 --attach-delay=<num> Seconds to wait for gdbserver to attach to the |
327 remote process before starting gdb. Default 1. | 327 remote process before starting gdb. Default 1. |
328 <num> may be a float if your sleep(1) supports it. | 328 <num> may be a float if your sleep(1) supports it. |
(...skipping 21 matching lines...) Expand all Loading... |
350 --release Use libraries under out/Release. | 350 --release Use libraries under out/Release. |
351 | 351 |
352 EOF | 352 EOF |
353 exit 0 | 353 exit 0 |
354 fi | 354 fi |
355 | 355 |
356 if [ -z "$PACKAGE_NAME" ]; then | 356 if [ -z "$PACKAGE_NAME" ]; then |
357 panic "Please specify a package name on the command line. See --help." | 357 panic "Please specify a package name on the command line. See --help." |
358 fi | 358 fi |
359 | 359 |
| 360 if [[ -z "$CHROMIUM_OUTPUT_DIR" && -z "$CHROMIUM_OUT_DIR" ]]; then |
| 361 if [[ -e "build.ninja" ]]; then |
| 362 CHROMIUM_OUTPUT_DIR=$PWD |
| 363 else |
| 364 panic "Please specify an output directory by using one of: |
| 365 --output-directory=out/Debug |
| 366 --out-dir=out/ |
| 367 CHROMIUM_OUTPUT_DIR=out/Debug |
| 368 CHROMIUM_OUT_DIR=out |
| 369 Setting working directory to an output directory. |
| 370 See --help." |
| 371 fi |
| 372 fi |
| 373 |
360 if [ -z "$NDK_DIR" ]; then | 374 if [ -z "$NDK_DIR" ]; then |
361 ANDROID_NDK_ROOT=$(PYTHONPATH=$CHROMIUM_SRC/build/android python -c \ | 375 ANDROID_NDK_ROOT=$(PYTHONPATH=$CHROMIUM_SRC/build/android python -c \ |
362 'from pylib.constants import ANDROID_NDK_ROOT; print ANDROID_NDK_ROOT,') | 376 'from pylib.constants import ANDROID_NDK_ROOT; print ANDROID_NDK_ROOT,') |
363 else | 377 else |
364 if [ ! -d "$NDK_DIR" ]; then | 378 if [ ! -d "$NDK_DIR" ]; then |
365 panic "Invalid directory: $NDK_DIR" | 379 panic "Invalid directory: $NDK_DIR" |
366 fi | 380 fi |
367 if [ ! -f "$NDK_DIR/ndk-build" ]; then | 381 if [ ! -f "$NDK_DIR/ndk-build" ]; then |
368 panic "Not a valid NDK directory: $NDK_DIR" | 382 panic "Not a valid NDK directory: $NDK_DIR" |
369 fi | 383 fi |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 | 1070 |
1057 if [ "$VERBOSE" -gt 0 ]; then | 1071 if [ "$VERBOSE" -gt 0 ]; then |
1058 echo "### START $COMMANDS" | 1072 echo "### START $COMMANDS" |
1059 cat $COMMANDS | 1073 cat $COMMANDS |
1060 echo "### END $COMMANDS" | 1074 echo "### END $COMMANDS" |
1061 fi | 1075 fi |
1062 | 1076 |
1063 log "Launching gdb client: $GDB $GDB_ARGS -x $COMMANDS" | 1077 log "Launching gdb client: $GDB $GDB_ARGS -x $COMMANDS" |
1064 $GDB $GDB_ARGS -x $COMMANDS && | 1078 $GDB $GDB_ARGS -x $COMMANDS && |
1065 rm -f "$GDBSERVER_PIDFILE" | 1079 rm -f "$GDBSERVER_PIDFILE" |
OLD | NEW |