| 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, or adb_gdb_drt | 10 # wrapper scripts like adb_gdb_content_shell, or adb_gdb_drt |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 # Allow wrapper scripts to set the program name through ADB_GDB_PROGNAME | 75 # Allow wrapper scripts to set the program name through ADB_GDB_PROGNAME |
| 76 PROGNAME=${ADB_GDB_PROGNAME:-$(basename "$0")} | 76 PROGNAME=${ADB_GDB_PROGNAME:-$(basename "$0")} |
| 77 | 77 |
| 78 ACTIVITY=$DEFAULT_ACTIVITY | 78 ACTIVITY=$DEFAULT_ACTIVITY |
| 79 ADB= | 79 ADB= |
| 80 ANNOTATE= | 80 ANNOTATE= |
| 81 # Note: Ignore BUILDTYPE variable, because the Ninja build doesn't use it. | 81 # Note: Ignore BUILDTYPE variable, because the Ninja build doesn't use it. |
| 82 BUILDTYPE= | 82 BUILDTYPE= |
| 83 FORCE= | 83 FORCE= |
| 84 GDBEXEPOSTFIX=gdb |
| 84 GDBINIT= | 85 GDBINIT= |
| 85 GDBSERVER= | 86 GDBSERVER= |
| 86 HELP= | 87 HELP= |
| 87 NDK_DIR= | 88 NDK_DIR= |
| 88 NO_PULL_LIBS= | 89 NO_PULL_LIBS= |
| 89 PACKAGE_NAME= | 90 PACKAGE_NAME= |
| 90 PID= | 91 PID= |
| 91 PROGRAM_NAME="activity" | 92 PROGRAM_NAME="activity" |
| 92 PULL_LIBS= | 93 PULL_LIBS= |
| 93 PULL_LIBS_DIR= | 94 PULL_LIBS_DIR= |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 ;; | 157 ;; |
| 157 --symbol-dir=*) | 158 --symbol-dir=*) |
| 158 SYMBOL_DIR=$optarg | 159 SYMBOL_DIR=$optarg |
| 159 ;; | 160 ;; |
| 160 --target-arch=*) | 161 --target-arch=*) |
| 161 TARGET_ARCH=$optarg | 162 TARGET_ARCH=$optarg |
| 162 ;; | 163 ;; |
| 163 --toolchain=*) | 164 --toolchain=*) |
| 164 TOOLCHAIN=$optarg | 165 TOOLCHAIN=$optarg |
| 165 ;; | 166 ;; |
| 167 --ui) |
| 168 GDBEXEPOSTFIX=gdbtui |
| 169 ;; |
| 166 --verbose) | 170 --verbose) |
| 167 VERBOSE=$(( $VERBOSE + 1 )) | 171 VERBOSE=$(( $VERBOSE + 1 )) |
| 168 ;; | 172 ;; |
| 169 --debug) | 173 --debug) |
| 170 BUILDTYPE=Debug | 174 BUILDTYPE=Debug |
| 171 ;; | 175 ;; |
| 172 --release) | 176 --release) |
| 173 BUILDTYPE=Release | 177 BUILDTYPE=Release |
| 174 ;; | 178 ;; |
| 175 -*) | 179 -*) |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 --verbose Increase verbosity. | 284 --verbose Increase verbosity. |
| 281 | 285 |
| 282 --sandboxed Debug first sandboxed process we find. | 286 --sandboxed Debug first sandboxed process we find. |
| 283 --sandboxed=<num> Debug specific sandboxed process. | 287 --sandboxed=<num> Debug specific sandboxed process. |
| 284 --symbol-dir=<path> Specify directory with symbol shared libraries. | 288 --symbol-dir=<path> Specify directory with symbol shared libraries. |
| 285 --package-name=<name> Specify package name (alternative to 1st argument). | 289 --package-name=<name> Specify package name (alternative to 1st argument). |
| 286 --program-name=<name> Specify program name (cosmetic only). | 290 --program-name=<name> Specify program name (cosmetic only). |
| 287 --pid=<pid> Specify application process pid. | 291 --pid=<pid> Specify application process pid. |
| 288 --force Kill any previous debugging session, if any. | 292 --force Kill any previous debugging session, if any. |
| 289 --start Start package's activity on device. | 293 --start Start package's activity on device. |
| 294 --ui Use gdbtui instead of gdb |
| 290 --activity=<name> Activity name for --start [$DEFAULT_ACTIVITY]. | 295 --activity=<name> Activity name for --start [$DEFAULT_ACTIVITY]. |
| 291 --annotate=<num> Enable gdb annotation. | 296 --annotate=<num> Enable gdb annotation. |
| 292 --script=<file> Specify extra GDB init script. | 297 --script=<file> Specify extra GDB init script. |
| 293 | 298 |
| 294 --gdbserver=<file> Specify targer gdbserver binary. | 299 --gdbserver=<file> Specify targer gdbserver binary. |
| 295 --gdb=<program> Specify host gdb client binary. | 300 --gdb=<program> Specify host gdb client binary. |
| 296 --target-arch=<name> Specify NDK target arch. | 301 --target-arch=<name> Specify NDK target arch. |
| 297 --adb=<program> Specify host ADB binary. | 302 --adb=<program> Specify host ADB binary. |
| 298 | 303 |
| 299 --pull-libs Force system libraries extraction. | 304 --pull-libs Force system libraries extraction. |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 if [ -d "$TOOLCHAIN/bin" ]; then | 525 if [ -d "$TOOLCHAIN/bin" ]; then |
| 521 TOOLCHAIN=$TOOLCHAIN/bin | 526 TOOLCHAIN=$TOOLCHAIN/bin |
| 522 fi | 527 fi |
| 523 ANDROID_TOOLCHAIN=$TOOLCHAIN | 528 ANDROID_TOOLCHAIN=$TOOLCHAIN |
| 524 fi | 529 fi |
| 525 | 530 |
| 526 # Cosmetic: Remove trailing directory separator. | 531 # Cosmetic: Remove trailing directory separator. |
| 527 ANDROID_TOOLCHAIN=${ANDROID_TOOLCHAIN%/} | 532 ANDROID_TOOLCHAIN=${ANDROID_TOOLCHAIN%/} |
| 528 | 533 |
| 529 # Find host GDB client binary | 534 # Find host GDB client binary |
| 530 GDB=$(which $ANDROID_TOOLCHAIN/*-gdb 2>/dev/null | head -1) | 535 GDB=$(which $ANDROID_TOOLCHAIN/*-$GDBEXEPOSTFIX 2>/dev/null | head -1) |
| 531 if [ -z "$GDB" ]; then | 536 if [ -z "$GDB" ]; then |
| 532 panic "Can't find Android gdb client in your path, check your \ | 537 panic "Can't find Android gdb client in your path, check your \ |
| 533 --toolchain path." | 538 --toolchain path." |
| 534 fi | 539 fi |
| 535 log "Host gdb client: $GDB" | 540 log "Host gdb client: $GDB" |
| 536 | 541 |
| 537 # Find gdbserver binary, we will later push it to /data/local/tmp | 542 # Find gdbserver binary, we will later push it to /data/local/tmp |
| 538 # This ensures that both gdbserver and $GDB talk the same binary protocol, | 543 # This ensures that both gdbserver and $GDB talk the same binary protocol, |
| 539 # otherwise weird problems will appear. | 544 # otherwise weird problems will appear. |
| 540 # | 545 # |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 echo "### START $COMMANDS" | 922 echo "### START $COMMANDS" |
| 918 cat $COMMANDS | 923 cat $COMMANDS |
| 919 echo "### END $COMMANDS" | 924 echo "### END $COMMANDS" |
| 920 fi | 925 fi |
| 921 | 926 |
| 922 log "Launching gdb client: $GDB $GDBARGS -x $COMMANDS" | 927 log "Launching gdb client: $GDB $GDBARGS -x $COMMANDS" |
| 923 $GDB $GDBARGS -x $COMMANDS && | 928 $GDB $GDBARGS -x $COMMANDS && |
| 924 rm -f "$GDBSERVER_PIDFILE" | 929 rm -f "$GDBSERVER_PIDFILE" |
| 925 | 930 |
| 926 clean_exit $? | 931 clean_exit $? |
| OLD | NEW |