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

Side by Side Diff: build/android/adb_gdb

Issue 15028013: Use $ANDROID_TOOLCHAIN set by envsetup.sh in adb_gdb and gdb_apk (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased on https://codereview.chromium.org/14858018/ (r199234) Created 7 years, 7 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 | build/android/gdb_apk » ('j') | 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, or adb_gdb_drt 10 # wrapper scripts like adb_gdb_content_shell, or adb_gdb_drt
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 else 351 else
352 # Nit: accept Chromium's 'ia32' as a valid target architecture. This 352 # Nit: accept Chromium's 'ia32' as a valid target architecture. This
353 # script prefers the NDK 'x86' name instead because it uses it to find 353 # script prefers the NDK 'x86' name instead because it uses it to find
354 # NDK-specific files (host gdb) with it. 354 # NDK-specific files (host gdb) with it.
355 if [ "$TARGET_ARCH" = "ia32" ]; then 355 if [ "$TARGET_ARCH" = "ia32" ]; then
356 TARGET_ARCH=x86 356 TARGET_ARCH=x86
357 log "Auto-config: --arch=$TARGET_ARCH (equivalent to ia32)" 357 log "Auto-config: --arch=$TARGET_ARCH (equivalent to ia32)"
358 fi 358 fi
359 fi 359 fi
360 360
361 # Detect the NDK system tag, i.e. the name used to identify the host.
362 # out: NDK system tag (e.g. 'linux-x86_64').
363 get_ndk_host_tag () {
364 if [ -z "$NDK_HOST_TAG" ]; then
365 case $(uname -s) in
366 Linux) NDK_HOST_TAG=linux-x86_64;;
367 Darwin) NDK_HOST_TAG=darwin-x86;;
368 *) panic "You can't run this script on this system: $uname -a";;
369 esac
370 fi
371 echo "$NDK_HOST_TAG"
372 }
373
374 # Convert an NDK architecture name into a GNU configure triplet. 361 # Convert an NDK architecture name into a GNU configure triplet.
375 # $1: NDK architecture name (e.g. 'arm') 362 # $1: NDK architecture name (e.g. 'arm')
376 # Out: Android GNU configure triplet (e.g. 'arm-linux-androideabi') 363 # Out: Android GNU configure triplet (e.g. 'arm-linux-androideabi')
377 get_arch_gnu_config () { 364 get_arch_gnu_config () {
378 case $1 in 365 case $1 in
379 arm) 366 arm)
380 echo "arm-linux-androideabi" 367 echo "arm-linux-androideabi"
381 ;; 368 ;;
382 x86) 369 x86)
383 echo "i686-linux-android" 370 echo "i686-linux-android"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 FILE=$NDK_DIR/toolchains/$NAME-4.6/prebuilt/$SUBPATH 406 FILE=$NDK_DIR/toolchains/$NAME-4.6/prebuilt/$SUBPATH
420 if [ ! -f "$FILE" ]; then 407 if [ ! -f "$FILE" ]; then
421 FILE=$NDK_DIR/toolchains/$NAME-4.4.3/prebuilt/$SUBPATH 408 FILE=$NDK_DIR/toolchains/$NAME-4.4.3/prebuilt/$SUBPATH
422 if [ ! -f "$FILE" ]; then 409 if [ ! -f "$FILE" ]; then
423 FILE= 410 FILE=
424 fi 411 fi
425 fi 412 fi
426 echo "$FILE" 413 echo "$FILE"
427 } 414 }
428 415
429 # Find the path to an NDK's toolchain full prefix for a given architecture
430 # $1: NDK install path
431 # $2: NDK architecture name
432 # Out: install path + binary prefix (e.g.
433 # ".../path/to/bin/arm-linux-androideabi-")
434 get_ndk_toolchain_fullprefix () {
435 local NDK_DIR="$1"
436 local ARCH="$2"
437 local TARGET NAME HOST GCC CONFIG
438
439 # NOTE: This will need to be updated if the NDK changes the names or moves
440 # the location of its prebuilt toolchains.
441 #
442 GCC=
443 HOST=$(get_ndk_host_tag)
444 CONFIG=$(get_arch_gnu_config $ARCH)
445 GCC=$(get_ndk_toolchain_prebuilt \
446 "$NDK_DIR" "$ARCH" "$HOST/bin/$CONFIG-gcc")
447 if [ ! -f "$GCC" -a "$ARCH" = "x86" ]; then
448 # Special case, the x86 toolchain used to be incorrectly
449 # named i686-android-linux-gcc!
450 GCC=$(get_ndk_toolchain_prebuilt \
451 "$NDK_DIR" "$ARCH" "$HOST/bin/i686-android-linux-gcc")
452 fi
453 if [ -z "$GCC" ]; then
454 panic "Cannot find Android NDK toolchain for '$ARCH' architecture. \
455 Please verify your NDK installation!"
456 fi
457 echo "${GCC%%gcc}"
458 }
459
460 # $1: NDK install path 416 # $1: NDK install path
461 # $2: target architecture. 417 # $2: target architecture.
462 get_ndk_gdbserver () { 418 get_ndk_gdbserver () {
463 local NDK_DIR="$1" 419 local NDK_DIR="$1"
464 local ARCH=$2 420 local ARCH=$2
465 local HOST=$(get_ndk_host_tag)
466 local BINARY 421 local BINARY
467 422
468 # The location has moved after NDK r8 423 # The location has moved after NDK r8
469 BINARY=$NDK_DIR/prebuilt/android-$ARCH/gdbserver/gdbserver 424 BINARY=$NDK_DIR/prebuilt/android-$ARCH/gdbserver/gdbserver
470 if [ ! -f "$BINARY" ]; then 425 if [ ! -f "$BINARY" ]; then
471 BINARY=$(get_ndk_toolchain_prebuilt "$NDK_DIR" "$ARCH" gdbserver) 426 BINARY=$(get_ndk_toolchain_prebuilt "$NDK_DIR" "$ARCH" gdbserver)
472 fi 427 fi
473 echo "$BINARY" 428 echo "$BINARY"
474 } 429 }
475 430
476 # Check/probe the path to the Android toolchain installation. Always 431 # Check/probe the path to the Android toolchain installation. Always
477 # use the NDK versions of gdb and gdbserver. They must match to avoid 432 # use the NDK versions of gdb and gdbserver. They must match to avoid
478 # issues when both binaries do not speak the same wire protocol. 433 # issues when both binaries do not speak the same wire protocol.
479 # 434 #
480 if [ -z "$TOOLCHAIN" ]; then 435 if [ -z "$TOOLCHAIN" ]; then
481 ANDROID_TOOLCHAIN=$(get_ndk_toolchain_fullprefix \
482 "$ANDROID_NDK_ROOT" "$TARGET_ARCH")
483 ANDROID_TOOLCHAIN=$(dirname "$ANDROID_TOOLCHAIN")
484 log "Auto-config: --toolchain=$ANDROID_TOOLCHAIN" 436 log "Auto-config: --toolchain=$ANDROID_TOOLCHAIN"
485 else 437 else
486 # Be flexible, allow one to specify either the install path or the bin 438 # Be flexible, allow one to specify either the install path or the bin
487 # sub-directory in --toolchain: 439 # sub-directory in --toolchain:
488 # 440 #
489 if [ -d "$TOOLCHAIN/bin" ]; then 441 if [ -d "$TOOLCHAIN/bin" ]; then
490 TOOLCHAIN=$TOOLCHAIN/bin 442 TOOLCHAIN=$TOOLCHAIN/bin
491 fi 443 fi
492 ANDROID_TOOLCHAIN=$TOOLCHAIN 444 ANDROID_TOOLCHAIN=$TOOLCHAIN
493 fi 445 fi
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 echo "### START $COMMANDS" 838 echo "### START $COMMANDS"
887 cat $COMMANDS 839 cat $COMMANDS
888 echo "### END $COMMANDS" 840 echo "### END $COMMANDS"
889 fi 841 fi
890 842
891 log "Launching gdb client: $GDB $GDBARGS -x $COMMANDS" 843 log "Launching gdb client: $GDB $GDBARGS -x $COMMANDS"
892 $GDB $GDBARGS -x $COMMANDS && 844 $GDB $GDBARGS -x $COMMANDS &&
893 rm -f "$GDBSERVER_PIDFILE" 845 rm -f "$GDBSERVER_PIDFILE"
894 846
895 clean_exit $? 847 clean_exit $?
OLDNEW
« no previous file with comments | « no previous file | build/android/gdb_apk » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698