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

Side by Side Diff: build/android/adb_gdb

Issue 1811363002: adb_gdb: Detect TARGET_ARCH from symbols_dir rather than device (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: allow --symbol-dir without --output-dir 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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 --libs-dir=<path> Specify system libraries extraction directory. 333 --libs-dir=<path> Specify system libraries extraction directory.
334 334
335 EOF 335 EOF
336 exit 0 336 exit 0
337 fi 337 fi
338 338
339 if [ -z "$PACKAGE_NAME" ]; then 339 if [ -z "$PACKAGE_NAME" ]; then
340 panic "Please specify a package name on the command line. See --help." 340 panic "Please specify a package name on the command line. See --help."
341 fi 341 fi
342 342
343 if [[ -z "$CHROMIUM_OUTPUT_DIR" ]]; then 343 if [[ -z "$SYMBOL_DIR" && -z "$CHROMIUM_OUTPUT_DIR" ]]; then
344 if [[ -e "build.ninja" ]]; then 344 if [[ -e "build.ninja" ]]; then
345 CHROMIUM_OUTPUT_DIR=$PWD 345 CHROMIUM_OUTPUT_DIR=$PWD
346 else 346 else
347 panic "Please specify an output directory by using one of: 347 panic "Please specify an output directory by using one of:
348 --output-directory=out/Debug 348 --output-directory=out/Debug
349 CHROMIUM_OUTPUT_DIR=out/Debug 349 CHROMIUM_OUTPUT_DIR=out/Debug
350 Setting working directory to an output directory. 350 Setting working directory to an output directory.
351 See --help." 351 See --help."
352 fi 352 fi
353 fi 353 fi
354 354
355 # Detect the build type and symbol directory. This is done by finding
356 # the most recent sub-directory containing debug shared libraries under
357 # $CHROMIUM_OUTPUT_DIR.
358 #
359 # Out: nothing, but this sets SYMBOL_DIR
360 #
361 detect_symbol_dir () {
362 # GYP places unstripped libraries under out/lib
363 # GN places them under out/lib.unstripped
364 local PARENT_DIR="$CHROMIUM_OUTPUT_DIR"
365 if [[ ! -e "$PARENT_DIR" ]]; then
366 PARENT_DIR="$CHROMIUM_SRC/$PARENT_DIR"
367 fi
368 SYMBOL_DIR="$PARENT_DIR/lib.unstripped"
369 if [[ -z "$(ls "$SYMBOL_DIR"/lib*.so 2>/dev/null)" ]]; then
370 SYMBOL_DIR="$PARENT_DIR/lib"
371 if [[ -z "$(ls "$SYMBOL_DIR"/lib*.so 2>/dev/null)" ]]; then
372 panic "Could not find any symbols under \
373 $PARENT_DIR/lib{.unstripped}. Please build the program first!"
374 fi
375 fi
376 log "Auto-config: --symbol-dir=$SYMBOL_DIR"
377 }
378
379 if [ -z "$SYMBOL_DIR" ]; then
380 detect_symbol_dir
381 elif [[ -z "$(ls "$SYMBOL_DIR"/lib*.so 2>/dev/null)" ]]; then
382 panic "Could not find any symbols under $SYMBOL_DIR"
383 fi
384
355 if [ -z "$NDK_DIR" ]; then 385 if [ -z "$NDK_DIR" ]; then
356 ANDROID_NDK_ROOT=$(PYTHONPATH=$CHROMIUM_SRC/build/android python -c \ 386 ANDROID_NDK_ROOT=$(PYTHONPATH=$CHROMIUM_SRC/build/android python -c \
357 'from pylib.constants import ANDROID_NDK_ROOT; print ANDROID_NDK_ROOT,') 387 'from pylib.constants import ANDROID_NDK_ROOT; print ANDROID_NDK_ROOT,')
358 else 388 else
359 if [ ! -d "$NDK_DIR" ]; then 389 if [ ! -d "$NDK_DIR" ]; then
360 panic "Invalid directory: $NDK_DIR" 390 panic "Invalid directory: $NDK_DIR"
361 fi 391 fi
362 if [ ! -f "$NDK_DIR/ndk-build" ]; then 392 if [ ! -f "$NDK_DIR/ndk-build" ]; then
363 panic "Not a valid NDK directory: $NDK_DIR" 393 panic "Not a valid NDK directory: $NDK_DIR"
364 fi 394 fi
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 LASTLINE=$(echo "$LASTLINE" | \ 455 LASTLINE=$(echo "$LASTLINE" | \
426 awk '{ if (match($0, "%%[0-9]+$")) { print substr($0,1,RSTART-1); } }') 456 awk '{ if (match($0, "%%[0-9]+$")) { print substr($0,1,RSTART-1); } }')
427 # The output itself: all lines except the status code. 457 # The output itself: all lines except the status code.
428 sed -e '$d' $TMPOUT && printf "%s" "$LASTLINE" 458 sed -e '$d' $TMPOUT && printf "%s" "$LASTLINE"
429 # Remove temp file. 459 # Remove temp file.
430 rm -f $TMPOUT 460 rm -f $TMPOUT
431 # Exit with the appropriate status. 461 # Exit with the appropriate status.
432 return $RET 462 return $RET
433 } 463 }
434 464
435 # Find the target architecture from the target device. 465 # Find the target architecture from a local shared library.
436 # This returns an NDK-compatible architecture name. 466 # This returns an NDK-compatible architecture name.
437 # out: NDK Architecture name, or empty string. 467 # out: NDK Architecture name, or empty string.
438 get_gyp_target_arch () { 468 get_gyp_target_arch () {
439 local ARCH=$(adb_shell getprop ro.product.cpu.abi) 469 local RANDOM_LIB=$(ls "$SYMBOL_DIR"/lib*.so | head -n1)
470 local SO_DESC=$(file $RANDOM_LIB)
440 case $ARCH in 471 case $ARCH in
441 mips|x86|x86_64) echo "$ARCH";; 472 *32-bit*ARM,*) echo "arm";;
442 arm64*) echo "arm64";; 473 *64-bit*ARM,*) echo "arm64";;
443 arm*) echo "arm";; 474 *32-bit*Intel,*) echo "x86";;
475 *x86-64,*) echo "x86_64";;
476 *32-bit*MIPS,*) echo "mips";;
444 *) echo ""; 477 *) echo "";
445 esac 478 esac
446 } 479 }
447 480
448 if [ -z "$TARGET_ARCH" ]; then 481 if [ -z "$TARGET_ARCH" ]; then
449 TARGET_ARCH=$(get_gyp_target_arch) 482 TARGET_ARCH=$(get_gyp_target_arch)
450 if [ -z "$TARGET_ARCH" ]; then 483 if [ -z "$TARGET_ARCH" ]; then
451 TARGET_ARCH=arm 484 TARGET_ARCH=arm
452 fi 485 fi
453 else 486 else
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 package is installed?" 721 package is installed?"
689 fi 722 fi
690 723
691 # Return the timestamp of a given file, as number of seconds since epoch. 724 # Return the timestamp of a given file, as number of seconds since epoch.
692 # $1: file path 725 # $1: file path
693 # Out: file timestamp 726 # Out: file timestamp
694 get_file_timestamp () { 727 get_file_timestamp () {
695 stat -c %Y "$1" 2>/dev/null 728 stat -c %Y "$1" 2>/dev/null
696 } 729 }
697 730
698 # Detect the build type and symbol directory. This is done by finding
699 # the most recent sub-directory containing debug shared libraries under
700 # $CHROMIUM_OUTPUT_DIR.
701 #
702 # Out: nothing, but this sets SYMBOL_DIR
703 #
704 detect_symbol_dir () {
705 # GYP places unstripped libraries under out/lib
706 # GN places them under out/lib.unstripped
707 local PARENT_DIR="$CHROMIUM_OUTPUT_DIR"
708 if [[ ! -e "$PARENT_DIR" ]]; then
709 PARENT_DIR="$CHROMIUM_SRC/$PARENT_DIR"
710 fi
711 SYMBOL_DIR="$PARENT_DIR/lib.unstripped"
712 if [[ -z "$(ls "$SYMBOL_DIR"/lib*.so 2>/dev/null)" ]]; then
713 SYMBOL_DIR="$PARENT_DIR/lib"
714 if [[ -z "$(ls "$SYMBOL_DIR"/lib*.so 2>/dev/null)" ]]; then
715 panic "Could not find any symbols under \
716 $PARENT_DIR/lib{.unstripped}. Please build the program first!"
717 fi
718 fi
719 log "Auto-config: --symbol-dir=$SYMBOL_DIR"
720 }
721
722 if [ -z "$SYMBOL_DIR" ]; then
723 detect_symbol_dir
724 fi
725
726 # Allow several concurrent debugging sessions 731 # Allow several concurrent debugging sessions
727 TARGET_GDBSERVER=/data/data/$PACKAGE_NAME/gdbserver-adb-gdb-$TMP_ID 732 TARGET_GDBSERVER=/data/data/$PACKAGE_NAME/gdbserver-adb-gdb-$TMP_ID
728 TMP_TARGET_GDBSERVER=/data/local/tmp/gdbserver-adb-gdb-$TMP_ID 733 TMP_TARGET_GDBSERVER=/data/local/tmp/gdbserver-adb-gdb-$TMP_ID
729 734
730 # Return the build fingerprint contained in a build.prop file. 735 # Return the build fingerprint contained in a build.prop file.
731 # $1: path to build.prop file 736 # $1: path to build.prop file
732 get_build_fingerprint_from () { 737 get_build_fingerprint_from () {
733 cat "$1" | grep -e '^ro.build.fingerprint=' | cut -d= -f2 738 cat "$1" | grep -e '^ro.build.fingerprint=' | cut -d= -f2
734 } 739 }
735 740
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 1023
1019 if [ "$VERBOSE" -gt 0 ]; then 1024 if [ "$VERBOSE" -gt 0 ]; then
1020 echo "### START $COMMANDS" 1025 echo "### START $COMMANDS"
1021 cat $COMMANDS 1026 cat $COMMANDS
1022 echo "### END $COMMANDS" 1027 echo "### END $COMMANDS"
1023 fi 1028 fi
1024 1029
1025 log "Launching gdb client: $GDB $GDB_ARGS -x $COMMANDS" 1030 log "Launching gdb client: $GDB $GDB_ARGS -x $COMMANDS"
1026 $GDB $GDB_ARGS -x $COMMANDS && 1031 $GDB $GDB_ARGS -x $COMMANDS &&
1027 rm -f "$GDBSERVER_PIDFILE" 1032 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