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

Side by Side Diff: build/android/adb_gdb

Issue 14910010: Do not use $ANDROID_TOOLCHAIN set by envsetup.sh. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 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 name, i.e. the name used to identify the host.
362 # out: NDK system name (e.g. 'linux' or 'darwin')
363 get_ndk_host_system () {
364 local HOST_OS
365 if [ -z "$NDK_HOST_SYSTEM" ]; then
366 HOST_OS=$(uname -s)
367 case $HOST_OS in
368 Linux) NDK_HOST_SYSTEM=linux;;
369 Darwin) NDK_HOST_SYSTEM=darwin;;
370 *) panic "You can't run this script on this system: $HOST_OS";;
371 esac
372 fi
373 echo "$NDK_HOST_SYSTEM"
374 }
375
376 # Detect the NDK host architecture name.
377 # out: NDK arch name (e.g. 'x86' or 'x86_64')
378 get_ndk_host_arch () {
379 local HOST_ARCH HOST_OS
380 if [ -z "$NDK_HOST_ARCH" ]; then
381 HOST_OS=$(get_ndk_host_system)
382 HOST_ARCH=$(uname -p)
383 case $HOST_ARCH in
384 i?86) NDK_HOST_ARCH=x86;;
385 x86_64|amd64) NDK_HOST_ARCH=x86_64;;
386 *) panic "You can't run this script on this host architecture: $HOST_ARCH" ;;
387 esac
388 # Darwin trick: "uname -p" always returns i386 on 64-bit installations.
389 if [ "$HOST_OS" = darwin -a "$NDK_HOST_ARCH" = "x86" ]; then
390 # Use '/usr/bin/file', not just 'file' to avoid buggy MacPorts
391 # implementations of the tool. See http://b.android.com/53769
392 HOST_64BITS=$(/usr/bin/file -L "$SHELL" | grep -e "x86[_-]64")
393 if [ "$HOST_64BITS" ]; then
394 NDK_HOST_ARCH=x86_64
395 fi
396 fi
397 fi
398 echo "$NDK_HOST_ARCH"
399 }
400
361 # Convert an NDK architecture name into a GNU configure triplet. 401 # Convert an NDK architecture name into a GNU configure triplet.
362 # $1: NDK architecture name (e.g. 'arm') 402 # $1: NDK architecture name (e.g. 'arm')
363 # Out: Android GNU configure triplet (e.g. 'arm-linux-androideabi') 403 # Out: Android GNU configure triplet (e.g. 'arm-linux-androideabi')
364 get_arch_gnu_config () { 404 get_arch_gnu_config () {
365 case $1 in 405 case $1 in
366 arm) 406 arm)
367 echo "arm-linux-androideabi" 407 echo "arm-linux-androideabi"
368 ;; 408 ;;
369 x86) 409 x86)
370 echo "i686-linux-android" 410 echo "i686-linux-android"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 FILE=$NDK_DIR/toolchains/$NAME-4.6/prebuilt/$SUBPATH 446 FILE=$NDK_DIR/toolchains/$NAME-4.6/prebuilt/$SUBPATH
407 if [ ! -f "$FILE" ]; then 447 if [ ! -f "$FILE" ]; then
408 FILE=$NDK_DIR/toolchains/$NAME-4.4.3/prebuilt/$SUBPATH 448 FILE=$NDK_DIR/toolchains/$NAME-4.4.3/prebuilt/$SUBPATH
409 if [ ! -f "$FILE" ]; then 449 if [ ! -f "$FILE" ]; then
410 FILE= 450 FILE=
411 fi 451 fi
412 fi 452 fi
413 echo "$FILE" 453 echo "$FILE"
414 } 454 }
415 455
456 # Find the path to an NDK's toolchain full prefix for a given architecture
457 # $1: NDK install path
458 # $2: NDK target architecture name
459 # Out: install path + binary prefix (e.g.
460 # ".../path/to/bin/arm-linux-androideabi-")
461 get_ndk_toolchain_fullprefix () {
462 local NDK_DIR="$1"
463 local ARCH="$2"
464 local TARGET NAME HOST_OS HOST_ARCH GCC CONFIG
465
466 # NOTE: This will need to be updated if the NDK changes the names or moves
467 # the location of its prebuilt toolchains.
468 #
469 GCC=
470 HOST_OS=$(get_ndk_host_system)
471 HOST_ARCH=$(get_ndk_host_arch)
472 CONFIG=$(get_arch_gnu_config $ARCH)
473 GCC=$(get_ndk_toolchain_prebuilt \
474 "$NDK_DIR" "$ARCH" "$HOST_OS-$HOST_ARCH/bin/$CONFIG-gcc")
475 if [ -z "$GCC" -a "$HOST_ARCH" = "x86_64" ]; then
476 GCC=$(get_ndk_toolchain_prebuilt \
477 "$NDK_DIR" "$ARCH" "$HOST_OS-x86/bin/$CONFIG-gcc")
478 fi
479 if [ ! -f "$GCC" -a "$ARCH" = "x86" ]; then
480 # Special case, the x86 toolchain used to be incorrectly
481 # named i686-android-linux-gcc!
482 GCC=$(get_ndk_toolchain_prebuilt \
483 "$NDK_DIR" "$ARCH" "$HOST_OS-x86/bin/i686-android-linux-gcc")
484 fi
485 if [ -z "$GCC" ]; then
486 panic "Cannot find Android NDK toolchain for '$ARCH' architecture. \
487 Please verify your NDK installation!"
488 fi
489 echo "${GCC%%gcc}"
490 }
491
416 # $1: NDK install path 492 # $1: NDK install path
417 # $2: target architecture. 493 # $2: target architecture.
418 get_ndk_gdbserver () { 494 get_ndk_gdbserver () {
419 local NDK_DIR="$1" 495 local NDK_DIR="$1"
420 local ARCH=$2 496 local ARCH=$2
421 local BINARY 497 local BINARY
422 498
423 # The location has moved after NDK r8 499 # The location has moved after NDK r8
424 BINARY=$NDK_DIR/prebuilt/android-$ARCH/gdbserver/gdbserver 500 BINARY=$NDK_DIR/prebuilt/android-$ARCH/gdbserver/gdbserver
425 if [ ! -f "$BINARY" ]; then 501 if [ ! -f "$BINARY" ]; then
426 BINARY=$(get_ndk_toolchain_prebuilt "$NDK_DIR" "$ARCH" gdbserver) 502 BINARY=$(get_ndk_toolchain_prebuilt "$NDK_DIR" "$ARCH" gdbserver)
427 fi 503 fi
428 echo "$BINARY" 504 echo "$BINARY"
429 } 505 }
430 506
431 # Check/probe the path to the Android toolchain installation. Always 507 # Check/probe the path to the Android toolchain installation. Always
432 # use the NDK versions of gdb and gdbserver. They must match to avoid 508 # use the NDK versions of gdb and gdbserver. They must match to avoid
433 # issues when both binaries do not speak the same wire protocol. 509 # issues when both binaries do not speak the same wire protocol.
434 # 510 #
435 if [ -z "$TOOLCHAIN" ]; then 511 if [ -z "$TOOLCHAIN" ]; then
512 ANDROID_TOOLCHAIN=$(get_ndk_toolchain_fullprefix \
513 "$ANDROID_NDK_ROOT" "$TARGET_ARCH")
514 ANDROID_TOOLCHAIN=$(dirname "$ANDROID_TOOLCHAIN")
436 log "Auto-config: --toolchain=$ANDROID_TOOLCHAIN" 515 log "Auto-config: --toolchain=$ANDROID_TOOLCHAIN"
437 else 516 else
438 # Be flexible, allow one to specify either the install path or the bin 517 # Be flexible, allow one to specify either the install path or the bin
439 # sub-directory in --toolchain: 518 # sub-directory in --toolchain:
440 # 519 #
441 if [ -d "$TOOLCHAIN/bin" ]; then 520 if [ -d "$TOOLCHAIN/bin" ]; then
442 TOOLCHAIN=$TOOLCHAIN/bin 521 TOOLCHAIN=$TOOLCHAIN/bin
443 fi 522 fi
444 ANDROID_TOOLCHAIN=$TOOLCHAIN 523 ANDROID_TOOLCHAIN=$TOOLCHAIN
445 fi 524 fi
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 echo "### START $COMMANDS" 917 echo "### START $COMMANDS"
839 cat $COMMANDS 918 cat $COMMANDS
840 echo "### END $COMMANDS" 919 echo "### END $COMMANDS"
841 fi 920 fi
842 921
843 log "Launching gdb client: $GDB $GDBARGS -x $COMMANDS" 922 log "Launching gdb client: $GDB $GDBARGS -x $COMMANDS"
844 $GDB $GDBARGS -x $COMMANDS && 923 $GDB $GDBARGS -x $COMMANDS &&
845 rm -f "$GDBSERVER_PIDFILE" 924 rm -f "$GDBSERVER_PIDFILE"
846 925
847 clean_exit $? 926 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