]>
Commit | Line | Data |
---|---|---|
2d717e4f DJ |
1 | # This testcase is part of GDB, the GNU debugger. |
2 | ||
8acc9f48 | 3 | # Copyright 2007-2013 Free Software Foundation, Inc. |
2d717e4f DJ |
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 | ||
20 | load_lib gdbserver-support.exp | |
21 | ||
b0963d73 | 22 | standard_testfile |
2d717e4f DJ |
23 | |
24 | if { [skip_gdbserver_tests] } { | |
25 | return 0 | |
26 | } | |
27 | ||
2d717e4f DJ |
28 | # We need to use TCL's exec to get the pid. |
29 | if [is_remote target] then { | |
30 | return 0 | |
31 | } | |
32 | ||
b0963d73 | 33 | if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} { |
2d717e4f DJ |
34 | return -1 |
35 | } | |
36 | ||
a1999d40 PA |
37 | # Make sure we're disconnected, in case we're testing with an |
38 | # extended-remote board, therefore already connected. | |
39 | gdb_test "disconnect" ".*" | |
40 | ||
6496a609 | 41 | set target_exec [gdbserver_download_current_prog] |
2d717e4f DJ |
42 | gdbserver_start_extended |
43 | ||
89493308 | 44 | gdb_test_no_output "set remote exec-file $target_exec" "set remote exec-file" |
2d717e4f DJ |
45 | |
46 | # Start the program running and then wait for a bit, to be sure | |
47 | # that it can be attached to. | |
48 | set testpid [eval exec $binfile &] | |
49 | exec sleep 2 | |
50 | if { [istarget "*-*-cygwin*"] } { | |
51 | # testpid is the Cygwin PID, GDB uses the Windows PID, which might be | |
52 | # different due to the way fork/exec works. | |
53 | set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ] | |
54 | } | |
55 | ||
7cee1e54 PA |
56 | gdb_test "attach $testpid" \ |
57 | "Attaching to program: .*, process $testpid.*(in|at).*" \ | |
2d717e4f DJ |
58 | "attach to remote program 1" |
59 | gdb_test "backtrace" ".*main.*" "backtrace 1" | |
60 | ||
7cee1e54 | 61 | gdb_test "detach" "Detaching from program.*process.*" |
2d717e4f DJ |
62 | gdb_test "backtrace" "No stack\\." "backtrace with no program" |
63 | ||
7cee1e54 PA |
64 | gdb_test "attach $testpid" \ |
65 | "Attaching to program: .*, process $testpid.*(in|at).*" \ | |
2d717e4f DJ |
66 | "attach to remote program 2" |
67 | gdb_test "backtrace" ".*main.*" "backtrace 2" | |
68 | ||
69 | gdb_test "kill" "" "kill" "Kill the program being debugged.*" "y" | |
f6978de9 | 70 | gdb_test_no_output "monitor exit" |