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 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 "$NDK_DIR" "$ARCH" "$HOST_OS-x86/bin/i686-android-linux-gcc") | 633 "$NDK_DIR" "$ARCH" "$HOST_OS-x86/bin/i686-android-linux-gcc") |
634 fi | 634 fi |
635 if [ -z "$GCC" ]; then | 635 if [ -z "$GCC" ]; then |
636 panic "Cannot find Android NDK toolchain for '$ARCH' architecture. \ | 636 panic "Cannot find Android NDK toolchain for '$ARCH' architecture. \ |
637 Please verify your NDK installation!" | 637 Please verify your NDK installation!" |
638 fi | 638 fi |
639 echo "${GCC%%gcc}" | 639 echo "${GCC%%gcc}" |
640 } | 640 } |
641 | 641 |
642 # $1: NDK install path | 642 # $1: NDK install path |
| 643 get_ndk_host_gdb_client() { |
| 644 local NDK_DIR="$1" |
| 645 local HOST_OS HOST_ARCH |
| 646 |
| 647 HOST_OS=$(get_ndk_host_system) |
| 648 HOST_ARCH=$(get_ndk_host_arch) |
| 649 echo "$NDK_DIR/prebuilt/$HOST_OS-$HOST_ARCH/bin/gdb" |
| 650 } |
| 651 |
| 652 # $1: NDK install path |
643 # $2: target architecture. | 653 # $2: target architecture. |
644 get_ndk_gdbserver () { | 654 get_ndk_gdbserver () { |
645 local NDK_DIR="$1" | 655 local NDK_DIR="$1" |
646 local ARCH=$2 | 656 local ARCH=$2 |
647 local BINARY | 657 local BINARY |
648 | 658 |
649 # The location has moved after NDK r8 | 659 # The location has moved after NDK r8 |
650 BINARY=$NDK_DIR/prebuilt/android-$ARCH/gdbserver/gdbserver | 660 BINARY=$NDK_DIR/prebuilt/android-$ARCH/gdbserver/gdbserver |
651 if [ ! -f "$BINARY" ]; then | 661 if [ ! -f "$BINARY" ]; then |
652 BINARY=$(get_ndk_toolchain_prebuilt "$NDK_DIR" "$ARCH" gdbserver) | 662 BINARY=$(get_ndk_toolchain_prebuilt "$NDK_DIR" "$ARCH" gdbserver) |
(...skipping 18 matching lines...) Expand all Loading... |
671 TOOLCHAIN=$TOOLCHAIN/bin | 681 TOOLCHAIN=$TOOLCHAIN/bin |
672 fi | 682 fi |
673 ANDROID_TOOLCHAIN=$TOOLCHAIN | 683 ANDROID_TOOLCHAIN=$TOOLCHAIN |
674 fi | 684 fi |
675 | 685 |
676 # Cosmetic: Remove trailing directory separator. | 686 # Cosmetic: Remove trailing directory separator. |
677 ANDROID_TOOLCHAIN=${ANDROID_TOOLCHAIN%/} | 687 ANDROID_TOOLCHAIN=${ANDROID_TOOLCHAIN%/} |
678 | 688 |
679 # Find host GDB client binary | 689 # Find host GDB client binary |
680 if [ -z "$GDB" ]; then | 690 if [ -z "$GDB" ]; then |
681 GDB=$(which $ANDROID_TOOLCHAIN/*-$GDBEXEPOSTFIX 2>/dev/null | head -1) | 691 GDB=$(get_ndk_host_gdb_client "$ANDROID_NDK_ROOT") |
682 if [ -z "$GDB" ]; then | 692 if [ -z "$GDB" ]; then |
683 panic "Can't find Android gdb client in your path, check your \ | 693 panic "Can't find Android gdb client in your path, check your \ |
684 --toolchain or --gdb path." | 694 --toolchain or --gdb path." |
685 fi | 695 fi |
686 log "Host gdb client: $GDB" | 696 log "Host gdb client: $GDB" |
687 fi | 697 fi |
688 | 698 |
689 # Find gdbserver binary, we will later push it to /data/local/tmp | 699 # Find gdbserver binary, we will later push it to /data/local/tmp |
690 # This ensures that both gdbserver and $GDB talk the same binary protocol, | 700 # This ensures that both gdbserver and $GDB talk the same binary protocol, |
691 # otherwise weird problems will appear. | 701 # otherwise weird problems will appear. |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 | 1042 |
1033 if [ "$VERBOSE" -gt 0 ]; then | 1043 if [ "$VERBOSE" -gt 0 ]; then |
1034 echo "### START $COMMANDS" | 1044 echo "### START $COMMANDS" |
1035 cat $COMMANDS | 1045 cat $COMMANDS |
1036 echo "### END $COMMANDS" | 1046 echo "### END $COMMANDS" |
1037 fi | 1047 fi |
1038 | 1048 |
1039 log "Launching gdb client: $GDB $GDB_ARGS -x $COMMANDS" | 1049 log "Launching gdb client: $GDB $GDB_ARGS -x $COMMANDS" |
1040 $GDB $GDB_ARGS -x $COMMANDS && | 1050 $GDB $GDB_ARGS -x $COMMANDS && |
1041 rm -f "$GDBSERVER_PIDFILE" | 1051 rm -f "$GDBSERVER_PIDFILE" |
OLD | NEW |