]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2010-2024 Free Software Foundation, Inc. |
221e1a37 PA |
2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation; either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
15 | ||
16 | # Check that when GDB connects to a stopped target in either non-stop | |
17 | # or all-stop modes, "target remote" does not return with the remote | |
18 | # thread marked running. | |
19 | ||
20 | load_lib gdbserver-support.exp | |
21 | load_lib prelink-support.exp | |
22 | ||
cadfc59b | 23 | require allow_gdbserver_tests |
221e1a37 PA |
24 | |
25 | standard_testfile | |
26 | set executable ${testfile} | |
27 | ||
98bf5c02 | 28 | if {[build_executable "failed to prepare" $testfile $srcfile debug]} { |
221e1a37 PA |
29 | return -1 |
30 | } | |
31 | ||
32 | proc do_test {nonstop} { | |
33 | global binfile | |
34 | global gdb_prompt | |
35 | global hex | |
36 | ||
37 | clean_restart $binfile | |
38 | ||
39 | # Make sure we're disconnected, in case we're testing with an | |
40 | # extended-remote board, therefore already connected. | |
41 | gdb_test "disconnect" ".*" | |
42 | ||
43 | gdb_test "set non-stop $nonstop" | |
44 | ||
e9d9abd7 | 45 | set res [gdbserver_spawn ""] |
221e1a37 PA |
46 | set gdbserver_protocol [lindex $res 0] |
47 | set gdbserver_gdbport [lindex $res 1] | |
48 | ||
49 | gdb_test_multiple "define connect" "define user command: connect" { | |
50 | -re "Type commands for definition of \"connect\".\r\nEnd with a line saying just \"end\".\r\n>$" { | |
51 | gdb_test [join [list \ | |
52 | "target $gdbserver_protocol $gdbserver_gdbport" \ | |
53 | "info threads" \ | |
54 | "p /x \$pc" \ | |
55 | "end" \ | |
56 | ] "\n"] \ | |
57 | "" \ | |
58 | "define user command: connect" | |
59 | } | |
60 | } | |
61 | ||
62 | # In non-stop mode, "target remote" used to return before the | |
63 | # already-stopped thread was marked stopped. Because of that, a | |
64 | # script (or fast user) could see the target as running right | |
65 | # after connection: | |
66 | # | |
67 | # (gdb) connect | |
68 | # Id Target Id Frame | |
69 | # * 1 Thread 31179 (running) | |
70 | # Target is executing. | |
71 | # (gdb) | |
72 | gdb_test "connect" " = $hex" "connect and print pc" | |
73 | gdb_test "print /x \$pc" " = $hex" "print pc again" | |
74 | } | |
75 | ||
76 | foreach nonstop { "off" "on" } { | |
77 | with_test_prefix "non-stop=$nonstop" { | |
78 | do_test $nonstop | |
79 | } | |
80 | } |