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

Side by Side Diff: build/android/adb_gdb

Issue 1818433002: 🚕 adb_gdb: Add --device flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 TARGET_ARCH= 108 TARGET_ARCH=
109 TOOLCHAIN= 109 TOOLCHAIN=
110 VERBOSE=0 110 VERBOSE=0
111 111
112 for opt; do 112 for opt; do
113 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 113 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
114 case $opt in 114 case $opt in
115 --adb=*) 115 --adb=*)
116 ADB=$optarg 116 ADB=$optarg
117 ;; 117 ;;
118 --device=*)
119 export ANDROID_SERIAL=$optarg
120 ;;
118 --activity=*) 121 --activity=*)
119 ACTIVITY=$optarg 122 ACTIVITY=$optarg
120 ;; 123 ;;
121 --annotate=3) 124 --annotate=3)
122 ANNOTATE=$optarg 125 ANNOTATE=$optarg
123 ;; 126 ;;
124 --force) 127 --force)
125 FORCE=true 128 FORCE=true
126 ;; 129 ;;
127 --gdbserver=*) 130 --gdbserver=*)
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 its value. 270 its value.
268 271
269 Otherwise, the script will complain, but you can use the --gdbserver, 272 Otherwise, the script will complain, but you can use the --gdbserver,
270 --gdb and --symbol-lib options to specify everything manually. 273 --gdb and --symbol-lib options to specify everything manually.
271 274
272 An alternative to --gdb=<file> is to use --toollchain=<path> to specify 275 An alternative to --gdb=<file> is to use --toollchain=<path> to specify
273 the path to the host target-specific cross-toolchain. 276 the path to the host target-specific cross-toolchain.
274 277
275 You will also need the 'adb' tool in your path. Otherwise, use the --adb 278 You will also need the 'adb' tool in your path. Otherwise, use the --adb
276 option. The script will complain if there is more than one device connected 279 option. The script will complain if there is more than one device connected
277 and ANDROID_SERIAL is not defined. 280 and a device is not specified with either --device or ANDROID_SERIAL).
278 281
279 The first time you use it on a device, the script will pull many system 282 The first time you use it on a device, the script will pull many system
280 libraries required by the process into a temporary directory. This 283 libraries required by the process into a temporary directory. This
281 is done to strongly improve the debugging experience, like allowing 284 is done to strongly improve the debugging experience, like allowing
282 readable thread stacks and more. The libraries are copied to the following 285 readable thread stacks and more. The libraries are copied to the following
283 directory by default: 286 directory by default:
284 287
285 $DEFAULT_PULL_LIBS_DIR/ 288 $DEFAULT_PULL_LIBS_DIR/
286 289
287 But you can use the --pull-libs-dir=<path> option to specify an 290 But you can use the --pull-libs-dir=<path> option to specify an
(...skipping 26 matching lines...) Expand all
314 <num> may be a float if your sleep(1) supports it. 317 <num> may be a float if your sleep(1) supports it.
315 --ui Use gdbtui instead of gdb 318 --ui Use gdbtui instead of gdb
316 --activity=<name> Activity name for --start [$DEFAULT_ACTIVITY]. 319 --activity=<name> Activity name for --start [$DEFAULT_ACTIVITY].
317 --annotate=<num> Enable gdb annotation. 320 --annotate=<num> Enable gdb annotation.
318 --script=<file> Specify extra GDB init script. 321 --script=<file> Specify extra GDB init script.
319 322
320 --gdbserver=<file> Specify target gdbserver binary. 323 --gdbserver=<file> Specify target gdbserver binary.
321 --gdb=<file> Specify host gdb client binary. 324 --gdb=<file> Specify host gdb client binary.
322 --target-arch=<name> Specify NDK target arch. 325 --target-arch=<name> Specify NDK target arch.
323 --adb=<file> Specify host ADB binary. 326 --adb=<file> Specify host ADB binary.
327 --device=<file> ADB device serial to use (-s flag).
324 --port=<port> Specify the tcp port to use. 328 --port=<port> Specify the tcp port to use.
325 329
326 --su-prefix=<prefix> Prepend <prefix> to 'adb shell' commands that are 330 --su-prefix=<prefix> Prepend <prefix> to 'adb shell' commands that are
327 run by this script. This can be useful to use 331 run by this script. This can be useful to use
328 the 'su' program on rooted production devices. 332 the 'su' program on rooted production devices.
329 e.g. --su-prefix="su -c" 333 e.g. --su-prefix="su -c"
330 334
331 --pull-libs Force system libraries extraction. 335 --pull-libs Force system libraries extraction.
332 --no-pull-libs Do not extract any system library. 336 --no-pull-libs Do not extract any system library.
333 --libs-dir=<path> Specify system libraries extraction directory. 337 --libs-dir=<path> Specify system libraries extraction directory.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 ADB_VERSION=$($ADB version 2>/dev/null) 387 ADB_VERSION=$($ADB version 2>/dev/null)
384 echo "$ADB_VERSION" | fgrep -q -e "Android Debug Bridge" 388 echo "$ADB_VERSION" | fgrep -q -e "Android Debug Bridge"
385 if [ $? != 0 ]; then 389 if [ $? != 0 ]; then
386 panic "Your 'adb' tool seems invalid, use --adb=<file> to specify a \ 390 panic "Your 'adb' tool seems invalid, use --adb=<file> to specify a \
387 different one: $ADB" 391 different one: $ADB"
388 fi 392 fi
389 393
390 # If there are more than one device connected, and ANDROID_SERIAL is not 394 # If there are more than one device connected, and ANDROID_SERIAL is not
391 # defined, print an error message. 395 # defined, print an error message.
392 NUM_DEVICES_PLUS2=$($ADB devices 2>/dev/null | wc -l) 396 NUM_DEVICES_PLUS2=$($ADB devices 2>/dev/null | wc -l)
393 if [ "$NUM_DEVICES_PLUS2" -lt 3 -a -z "$ANDROID_SERIAL" ]; then 397 if [ "$NUM_DEVICES_PLUS2" -gt 3 -a -z "$ANDROID_SERIAL" ]; then
394 echo "ERROR: There is more than one Android device connected to ADB." 398 echo "ERROR: There is more than one Android device connected to ADB."
395 echo "Please define ANDROID_SERIAL to specify which one to use." 399 echo "Please define ANDROID_SERIAL to specify which one to use."
396 exit 1 400 exit 1
397 fi 401 fi
398 402
399 # Run a command through adb shell, strip the extra \r from the output 403 # Run a command through adb shell, strip the extra \r from the output
400 # and return the correct status code to detect failures. This assumes 404 # and return the correct status code to detect failures. This assumes
401 # that the adb shell command prints a final \n to stdout. 405 # that the adb shell command prints a final \n to stdout.
402 # $1+: command to run 406 # $1+: command to run
403 # Out: command's stdout 407 # Out: command's stdout
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 1022
1019 if [ "$VERBOSE" -gt 0 ]; then 1023 if [ "$VERBOSE" -gt 0 ]; then
1020 echo "### START $COMMANDS" 1024 echo "### START $COMMANDS"
1021 cat $COMMANDS 1025 cat $COMMANDS
1022 echo "### END $COMMANDS" 1026 echo "### END $COMMANDS"
1023 fi 1027 fi
1024 1028
1025 log "Launching gdb client: $GDB $GDB_ARGS -x $COMMANDS" 1029 log "Launching gdb client: $GDB $GDB_ARGS -x $COMMANDS"
1026 $GDB $GDB_ARGS -x $COMMANDS && 1030 $GDB $GDB_ARGS -x $COMMANDS &&
1027 rm -f "$GDBSERVER_PIDFILE" 1031 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