ext-attach.exp revision 1.1
1# This testcase is part of GDB, the GNU debugger. 2 3# Copyright 2007-2014 Free Software Foundation, Inc. 4 5# This program is free software; you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation; either version 3 of the License, or 8# (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18# Test attaching to already-running programs using extended-remote. 19 20load_lib gdbserver-support.exp 21load_lib trace-support.exp 22 23standard_testfile 24 25if { [skip_gdbserver_tests] } { 26 return 0 27} 28 29# We need to use TCL's exec to get the pid. 30if [is_remote target] then { 31 return 0 32} 33 34if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} { 35 return -1 36} 37 38# Make sure we're disconnected, in case we're testing with an 39# extended-remote board, therefore already connected. 40gdb_test "disconnect" ".*" 41 42set target_exec [gdbserver_download_current_prog] 43gdbserver_start_extended 44 45gdb_test_no_output "set remote exec-file $target_exec" "set remote exec-file" 46 47# Start the program running and then wait for a bit, to be sure 48# that it can be attached to. 49set testpid [eval exec $binfile &] 50exec sleep 2 51if { [istarget "*-*-cygwin*"] } { 52 # testpid is the Cygwin PID, GDB uses the Windows PID, which might be 53 # different due to the way fork/exec works. 54 set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ] 55} 56 57gdb_test "attach $testpid" \ 58 "Attaching to program: .*, process $testpid.*(in|at).*" \ 59 "attach to remote program 1" 60 61if { [gdb_target_supports_trace] } then { 62 # Test predefined TSVs are uploaded. 63 gdb_test_sequence "info tvariables" "check uploaded tsv" { 64 "\[\r\n\]+Name\[\t \]+Initial\[\t \]+Current" 65 "\[\r\n\]+\\\$trace_timestamp 0" 66 } 67} 68 69gdb_test "backtrace" ".*main.*" "backtrace 1" 70 71gdb_test "detach" "Detaching from program.*process.*" 72gdb_test "backtrace" "No stack\\." "backtrace with no program" 73 74gdb_test "attach $testpid" \ 75 "Attaching to program: .*, process $testpid.*(in|at).*" \ 76 "attach to remote program 2" 77gdb_test "backtrace" ".*main.*" "backtrace 2" 78 79gdb_test "kill" "" "kill" "Kill the program being debugged.*" "y" 80gdb_test_no_output "monitor exit" 81