| 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 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 # Start gdbserver in the background | 976 # Start gdbserver in the background |
| 977 # Note that using run-as requires the package to be debuggable. | 977 # Note that using run-as requires the package to be debuggable. |
| 978 # | 978 # |
| 979 # If not, this will fail horribly. The alternative is to run the | 979 # If not, this will fail horribly. The alternative is to run the |
| 980 # program as root, which requires of course root privileges. | 980 # program as root, which requires of course root privileges. |
| 981 # Maybe we should add a --root option to enable this? | 981 # Maybe we should add a --root option to enable this? |
| 982 # | 982 # |
| 983 log "Starting gdbserver in the background:" | 983 log "Starting gdbserver in the background:" |
| 984 GDBSERVER_LOG=$TMPDIR/gdbserver-$TMP_ID.log | 984 GDBSERVER_LOG=$TMPDIR/gdbserver-$TMP_ID.log |
| 985 log "adb shell $COMMAND_PREFIX $TARGET_GDBSERVER :$TARGET_PORT \ | 985 log "adb shell $COMMAND_PREFIX $TARGET_GDBSERVER :$TARGET_PORT \ |
| 986 --attach $PID $COMMAND_SUFFIX" | 986 --attach $PID $COMMAND_SUFFIX" |
| 987 ("$ADB" shell $COMMAND_PREFIX $TARGET_GDBSERVER :$TARGET_PORT \ | 987 "$ADB" shell $COMMAND_PREFIX $TARGET_GDBSERVER :$TARGET_PORT \ |
| 988 --attach $PID $COMMAND_SUFFIX > $GDBSERVER_LOG 2>&1) & | 988 --attach $PID $COMMAND_SUFFIX > $GDBSERVER_LOG 2>&1 & |
| 989 GDBSERVER_PID=$! | 989 GDBSERVER_PID=$! |
| 990 echo "$GDBSERVER_PID" > $GDBSERVER_PIDFILE | 990 echo "$GDBSERVER_PID" > $GDBSERVER_PIDFILE |
| 991 log "background job pid: $GDBSERVER_PID" | 991 log "background job pid: $GDBSERVER_PID" |
| 992 | 992 |
| 993 # Check that it is still running after a few seconds. If not, this means we | 993 # Check that it is still running after a few seconds. If not, this means we |
| 994 # could not properly attach to it | 994 # could not properly attach to it |
| 995 sleep 2 | 995 sleep 2 |
| 996 log "Job control: $(jobs -l)" | 996 log "Job control: $(jobs -l)" |
| 997 STATE=$(jobs -l | awk '$2 == "'$GDBSERVER_PID'" { print $3; }') | 997 STATE=$(jobs -l | awk '$2 == "'$GDBSERVER_PID'" { print $3; }') |
| 998 if [ "$STATE" != "Running" ]; then | 998 if [ "$STATE" != "Running" ]; then |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 | 1041 |
| 1042 if [ "$VERBOSE" -gt 0 ]; then | 1042 if [ "$VERBOSE" -gt 0 ]; then |
| 1043 echo "### START $COMMANDS" | 1043 echo "### START $COMMANDS" |
| 1044 cat $COMMANDS | 1044 cat $COMMANDS |
| 1045 echo "### END $COMMANDS" | 1045 echo "### END $COMMANDS" |
| 1046 fi | 1046 fi |
| 1047 | 1047 |
| 1048 log "Launching gdb client: $GDB $GDB_ARGS -x $COMMANDS" | 1048 log "Launching gdb client: $GDB $GDB_ARGS -x $COMMANDS" |
| 1049 $GDB $GDB_ARGS -x $COMMANDS && | 1049 $GDB $GDB_ARGS -x $COMMANDS && |
| 1050 rm -f "$GDBSERVER_PIDFILE" | 1050 rm -f "$GDBSERVER_PIDFILE" |
| OLD | NEW |