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