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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 fi | 354 fi |
355 | 355 |
356 # Find the target architecture from our $GYP_DEFINES | 356 # Find the target architecture from our $GYP_DEFINES |
357 # This returns an NDK-compatible architecture name. | 357 # This returns an NDK-compatible architecture name. |
358 # out: NDK Architecture name, or empty string. | 358 # out: NDK Architecture name, or empty string. |
359 get_gyp_target_arch () { | 359 get_gyp_target_arch () { |
360 local ARCH=$(echo $GYP_DEFINES | tr ' ' '\n' | grep '^target_arch=' |\ | 360 local ARCH=$(echo $GYP_DEFINES | tr ' ' '\n' | grep '^target_arch=' |\ |
361 cut -d= -f2) | 361 cut -d= -f2) |
362 case $ARCH in | 362 case $ARCH in |
363 ia32|i?86|x86) echo "x86";; | 363 ia32|i?86|x86) echo "x86";; |
364 mips|arm) echo "$ARCH";; | 364 mips|arm|arm64|x86_64) echo "$ARCH";; |
365 *) echo ""; | 365 *) echo ""; |
366 esac | 366 esac |
367 } | 367 } |
368 | 368 |
369 if [ -z "$TARGET_ARCH" ]; then | 369 if [ -z "$TARGET_ARCH" ]; then |
370 TARGET_ARCH=$(get_gyp_target_arch) | 370 TARGET_ARCH=$(get_gyp_target_arch) |
371 if [ -z "$TARGET_ARCH" ]; then | 371 if [ -z "$TARGET_ARCH" ]; then |
372 TARGET_ARCH=arm | 372 TARGET_ARCH=arm |
373 fi | 373 fi |
374 else | 374 else |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 } | 422 } |
423 | 423 |
424 # Convert an NDK architecture name into a GNU configure triplet. | 424 # Convert an NDK architecture name into a GNU configure triplet. |
425 # $1: NDK architecture name (e.g. 'arm') | 425 # $1: NDK architecture name (e.g. 'arm') |
426 # Out: Android GNU configure triplet (e.g. 'arm-linux-androideabi') | 426 # Out: Android GNU configure triplet (e.g. 'arm-linux-androideabi') |
427 get_arch_gnu_config () { | 427 get_arch_gnu_config () { |
428 case $1 in | 428 case $1 in |
429 arm) | 429 arm) |
430 echo "arm-linux-androideabi" | 430 echo "arm-linux-androideabi" |
431 ;; | 431 ;; |
| 432 arm64) |
| 433 echo "aarch64-linux-android" |
| 434 ;; |
432 x86) | 435 x86) |
433 echo "i686-linux-android" | 436 echo "i686-linux-android" |
434 ;; | 437 ;; |
| 438 x86_64) |
| 439 echo "x86_64-linux-android" |
| 440 ;; |
435 mips) | 441 mips) |
436 echo "mipsel-linux-android" | 442 echo "mipsel-linux-android" |
437 ;; | 443 ;; |
438 *) | 444 *) |
439 echo "$ARCH-linux-android" | 445 echo "$ARCH-linux-android" |
440 ;; | 446 ;; |
441 esac | 447 esac |
442 } | 448 } |
443 | 449 |
444 # Convert an NDK architecture name into a toolchain name prefix | 450 # Convert an NDK architecture name into a toolchain name prefix |
(...skipping 16 matching lines...) Expand all Loading... |
461 # $3: prebuilt sub-path to look for. | 467 # $3: prebuilt sub-path to look for. |
462 # Out: file path, or empty if none is found. | 468 # Out: file path, or empty if none is found. |
463 get_ndk_toolchain_prebuilt () { | 469 get_ndk_toolchain_prebuilt () { |
464 local NDK_DIR="${1%/}" | 470 local NDK_DIR="${1%/}" |
465 local ARCH="$2" | 471 local ARCH="$2" |
466 local SUBPATH="$3" | 472 local SUBPATH="$3" |
467 local NAME="$(get_arch_toolchain_prefix $ARCH)" | 473 local NAME="$(get_arch_toolchain_prefix $ARCH)" |
468 local FILE TARGET | 474 local FILE TARGET |
469 FILE=$NDK_DIR/toolchains/$NAME-4.6/prebuilt/$SUBPATH | 475 FILE=$NDK_DIR/toolchains/$NAME-4.6/prebuilt/$SUBPATH |
470 if [ ! -f "$FILE" ]; then | 476 if [ ! -f "$FILE" ]; then |
471 FILE=$NDK_DIR/toolchains/$NAME-4.4.3/prebuilt/$SUBPATH | 477 FILE=$NDK_DIR/toolchains/$NAME-4.8/prebuilt/$SUBPATH |
472 if [ ! -f "$FILE" ]; then | 478 if [ ! -f "$FILE" ]; then |
473 FILE= | 479 FILE=$NDK_DIR/toolchains/$NAME-4.4.3/prebuilt/$SUBPATH |
| 480 if [ ! -f "$FILE" ]; then |
| 481 FILE= |
| 482 fi |
474 fi | 483 fi |
475 fi | 484 fi |
476 echo "$FILE" | 485 echo "$FILE" |
477 } | 486 } |
478 | 487 |
479 # Find the path to an NDK's toolchain full prefix for a given architecture | 488 # Find the path to an NDK's toolchain full prefix for a given architecture |
480 # $1: NDK install path | 489 # $1: NDK install path |
481 # $2: NDK target architecture name | 490 # $2: NDK target architecture name |
482 # Out: install path + binary prefix (e.g. | 491 # Out: install path + binary prefix (e.g. |
483 # ".../path/to/bin/arm-linux-androideabi-") | 492 # ".../path/to/bin/arm-linux-androideabi-") |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 | 906 |
898 # Push gdbserver to the device | 907 # Push gdbserver to the device |
899 log "Pushing gdbserver $GDBSERVER to $TARGET_GDBSERVER" | 908 log "Pushing gdbserver $GDBSERVER to $TARGET_GDBSERVER" |
900 adb push $GDBSERVER $TARGET_GDBSERVER &>/dev/null | 909 adb push $GDBSERVER $TARGET_GDBSERVER &>/dev/null |
901 fail_panic "Could not copy gdbserver to the device!" | 910 fail_panic "Could not copy gdbserver to the device!" |
902 | 911 |
903 PORT=5039 | 912 PORT=5039 |
904 HOST_PORT=$PORT | 913 HOST_PORT=$PORT |
905 TARGET_PORT=$PORT | 914 TARGET_PORT=$PORT |
906 | 915 |
| 916 # Select correct app_process for architecture. |
| 917 case $TARGET_ARCH in |
| 918 arm|x86|mips) GDBEXEC=app_process;; |
| 919 arm64|x86_64) GDBEXEC=app_process64;; |
| 920 *) fail_panic "Unknown app_process for architecture!";; |
| 921 esac |
| 922 |
907 # Detect AddressSanitizer setup on the device. In that case app_process is a | 923 # Detect AddressSanitizer setup on the device. In that case app_process is a |
908 # script, and the real executable is app_process.real. | 924 # script, and the real executable is app_process.real. |
909 GDBEXEC=app_process | |
910 GDBEXEC_ASAN=app_process.real | 925 GDBEXEC_ASAN=app_process.real |
911 adb_shell ls /system/bin/$GDBEXEC_ASAN | 926 adb_shell ls /system/bin/$GDBEXEC_ASAN |
912 if [ $? == 0 ]; then | 927 if [ $? == 0 ]; then |
913 GDBEXEC=$GDBEXEC_ASAN | 928 GDBEXEC=$GDBEXEC_ASAN |
914 fi | 929 fi |
915 | 930 |
916 # Pull the app_process binary from the device. | 931 # Pull the app_process binary from the device. |
917 log "Pulling $GDBEXEC from device" | 932 log "Pulling $GDBEXEC from device" |
918 adb pull /system/bin/$GDBEXEC "$TMPDIR"/$GDBEXEC &>/dev/null | 933 adb pull /system/bin/$GDBEXEC "$TMPDIR"/$GDBEXEC &>/dev/null |
919 fail_panic "Could not retrieve $GDBEXEC from the device!" | 934 fail_panic "Could not retrieve $GDBEXEC from the device!" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 | 987 |
973 if [ "$VERBOSE" -gt 0 ]; then | 988 if [ "$VERBOSE" -gt 0 ]; then |
974 echo "### START $COMMANDS" | 989 echo "### START $COMMANDS" |
975 cat $COMMANDS | 990 cat $COMMANDS |
976 echo "### END $COMMANDS" | 991 echo "### END $COMMANDS" |
977 fi | 992 fi |
978 | 993 |
979 log "Launching gdb client: $GDB $GDBARGS -x $COMMANDS" | 994 log "Launching gdb client: $GDB $GDBARGS -x $COMMANDS" |
980 $GDB $GDBARGS -x $COMMANDS && | 995 $GDB $GDBARGS -x $COMMANDS && |
981 rm -f "$GDBSERVER_PIDFILE" | 996 rm -f "$GDBSERVER_PIDFILE" |
OLD | NEW |