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 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 echo "$GDBSERVER_PID" > $GDBSERVER_PIDFILE | 957 echo "$GDBSERVER_PID" > $GDBSERVER_PIDFILE |
958 log "background job pid: $GDBSERVER_PID" | 958 log "background job pid: $GDBSERVER_PID" |
959 | 959 |
960 # Check that it is still running after a few seconds. If not, this means we | 960 # Check that it is still running after a few seconds. If not, this means we |
961 # could not properly attach to it | 961 # could not properly attach to it |
962 sleep 2 | 962 sleep 2 |
963 log "Job control: $(jobs -l)" | 963 log "Job control: $(jobs -l)" |
964 STATE=$(jobs -l | awk '$2 == "'$GDBSERVER_PID'" { print $3; }') | 964 STATE=$(jobs -l | awk '$2 == "'$GDBSERVER_PID'" { print $3; }') |
965 if [ "$STATE" != "Running" ]; then | 965 if [ "$STATE" != "Running" ]; then |
966 echo "ERROR: GDBServer could not attach to PID $PID!" | 966 echo "ERROR: GDBServer could not attach to PID $PID!" |
967 echo "Failure log (use --verbose for more information):" | 967 if [ $(adb_shell su -c getenforce) != "Permissive" ]; then |
968 cat $GDBSERVER_LOG | 968 echo "Device mode is Enforcing. Changing Device mode to Permissive " |
969 exit 1 | 969 $(adb_shell su -c setenforce 0) |
| 970 if [ $(adb_shell su -c getenforce) != "Permissive" ]; then |
| 971 echo "ERROR: Failed to Change Device mode to Permissive" |
| 972 echo "Failure log (use --verbose for more information):" |
| 973 cat $GDBSERVER_LOG |
| 974 exit 1 |
| 975 fi |
| 976 else |
| 977 echo "Failure log (use --verbose for more information):" |
| 978 cat $GDBSERVER_LOG |
| 979 exit 1 |
| 980 fi |
970 fi | 981 fi |
971 | 982 |
972 # Generate a file containing useful GDB initialization commands | 983 # Generate a file containing useful GDB initialization commands |
973 readonly COMMANDS=$TMPDIR/gdb.init | 984 readonly COMMANDS=$TMPDIR/gdb.init |
974 log "Generating GDB initialization commands file: $COMMANDS" | 985 log "Generating GDB initialization commands file: $COMMANDS" |
975 echo -n "" > $COMMANDS | 986 echo -n "" > $COMMANDS |
976 echo "file $TMPDIR/$GDBEXEC" >> $COMMANDS | 987 echo "file $TMPDIR/$GDBEXEC" >> $COMMANDS |
977 echo "directory $CHROMIUM_SRC" >> $COMMANDS | 988 echo "directory $CHROMIUM_SRC" >> $COMMANDS |
978 echo "set solib-absolute-prefix $PULL_LIBS_DIR" >> $COMMANDS | 989 echo "set solib-absolute-prefix $PULL_LIBS_DIR" >> $COMMANDS |
979 echo "set solib-search-path $SOLIB_DIRS:$PULL_LIBS_DIR:$SYMBOL_DIR" \ | 990 echo "set solib-search-path $SOLIB_DIRS:$PULL_LIBS_DIR:$SYMBOL_DIR" \ |
980 >> $COMMANDS | 991 >> $COMMANDS |
981 echo "echo Attaching and reading symbols, this may take a while.." \ | 992 echo "echo Attaching and reading symbols, this may take a while.." \ |
982 >> $COMMANDS | 993 >> $COMMANDS |
983 echo "target remote :$HOST_PORT" >> $COMMANDS | 994 echo "target remote :$HOST_PORT" >> $COMMANDS |
984 | 995 |
985 if [ "$GDBINIT" ]; then | 996 if [ "$GDBINIT" ]; then |
986 cat "$GDBINIT" >> $COMMANDS | 997 cat "$GDBINIT" >> $COMMANDS |
987 fi | 998 fi |
988 | 999 |
989 if [ "$VERBOSE" -gt 0 ]; then | 1000 if [ "$VERBOSE" -gt 0 ]; then |
990 echo "### START $COMMANDS" | 1001 echo "### START $COMMANDS" |
991 cat $COMMANDS | 1002 cat $COMMANDS |
992 echo "### END $COMMANDS" | 1003 echo "### END $COMMANDS" |
993 fi | 1004 fi |
994 | 1005 |
995 log "Launching gdb client: $GDB $GDB_ARGS -x $COMMANDS" | 1006 log "Launching gdb client: $GDB $GDB_ARGS -x $COMMANDS" |
996 $GDB $GDB_ARGS -x $COMMANDS && | 1007 $GDB $GDB_ARGS -x $COMMANDS && |
997 rm -f "$GDBSERVER_PIDFILE" | 1008 rm -f "$GDBSERVER_PIDFILE" |
OLD | NEW |