]>
Commit | Line | Data |
---|---|---|
f3364a6d AB |
1 | # This testcase is part of GDB, the GNU debugger. |
2 | # | |
213516ef | 3 | # Copyright 2019-2023 Free Software Foundation, Inc. |
f3364a6d AB |
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 what happens if we have multiple UIs in use, and an error | |
19 | # occurs while running a GDB command. Specifically, do both UIs | |
20 | # return to an interactive state, or does one (or both) of them get | |
21 | # stuck in a non-interactive state. | |
22 | ||
23 | load_lib gdbserver-support.exp | |
24 | ||
25 | standard_testfile | |
26 | ||
27 | if {[skip_gdbserver_tests]} { | |
28 | return 0 | |
29 | } | |
30 | ||
8dc558a0 SM |
31 | save_vars { GDBFLAGS } { |
32 | # If GDB and GDBserver are both running locally, set the sysroot to avoid | |
33 | # reading files via the remote protocol. | |
34 | if { ![is_remote host] && ![is_remote target] } { | |
35 | set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\"" | |
36 | } | |
37 | ||
38 | if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} { | |
39 | return -1 | |
40 | } | |
f3364a6d AB |
41 | } |
42 | ||
43 | # Make sure we're disconnected, in case we're testing with an | |
44 | # extended-remote board, therefore already connected. | |
45 | gdb_test "disconnect" ".*" | |
46 | ||
47 | # Start gdbserver. | |
48 | set res [gdbserver_spawn "${binfile}"] | |
49 | set gdbserver_protocol [lindex $res 0] | |
50 | set gdbserver_gdbport [lindex $res 1] | |
51 | set gdbserver_pid [exp_pid -i $server_spawn_id] | |
52 | ||
53 | # Save the main UI's spawn ID. | |
54 | set gdb_main_spawn_id $gdb_spawn_id | |
55 | ||
56 | # Create the new PTY for the secondary console UI, issue the 'new-ui' | |
57 | # command, and wait for a prompt on the second UI. | |
58 | spawn -pty | |
59 | set extra_spawn_id $spawn_id | |
60 | set extra_tty_name $spawn_out(slave,name) | |
61 | gdb_test_multiple "new-ui console $extra_tty_name" "new-ui" { | |
62 | -re "New UI allocated\r\n$gdb_prompt $" { | |
63 | pass $gdb_test_name | |
64 | } | |
65 | } | |
66 | with_spawn_id $extra_spawn_id { | |
67 | gdb_test_multiple "" "initial prompt on extra console" { | |
68 | -re "$gdb_prompt $" { | |
69 | pass $gdb_test_name | |
70 | } | |
71 | } | |
72 | } | |
73 | ||
74 | # Connect to the remote and continue its execution from the other UI. | |
75 | with_spawn_id $extra_spawn_id { | |
b0999b9b AB |
76 | gdb_test "target $gdbserver_protocol $gdbserver_gdbport" ".*" \ |
77 | "connect to gdbserver" | |
64ba0c58 TV |
78 | |
79 | # Issue a continue and consume the response. Don't expect a prompt. | |
80 | gdb_test_multiple "continue" "continue - extra UI" { | |
81 | -re "\r\nContinuing\.\r\n" { | |
82 | pass $gdb_test_name | |
83 | } | |
84 | } | |
f3364a6d AB |
85 | } |
86 | ||
87 | # We're going to kill the gdbserver, but before we do, lets make sure | |
88 | # that the inferior has started executing. | |
89 | with_spawn_id $server_spawn_id { | |
90 | gdb_test_multiple "" "ensure inferior is running" { | |
91 | -re "@@XX@@ Inferior Starting @@XX@@" { | |
92 | pass $gdb_test_name | |
93 | } | |
94 | timeout { | |
95 | fail $gdb_test_name | |
96 | } | |
97 | } | |
98 | } | |
99 | ||
100 | # Interact with the main UI. | |
101 | with_spawn_id $gdb_main_spawn_id { | |
102 | gdb_test "echo hello\\n" "hello" "interact with GDB's main UI" | |
103 | } | |
104 | ||
105 | # Now kill the gdbserver. | |
106 | remote_exec target "kill -9 $gdbserver_pid" | |
107 | ||
108 | # We expect to land back at a GDB prompt in both UIs, however there is | |
109 | # currently an issue that in the original UI GDB doesn't reprint its | |
110 | # prompt. That said, getting a prompt isn't the point of this test. | |
111 | # The point is that we should be able to interact with GDB from either | |
112 | # interpreter now. | |
113 | ||
8db6f1bd TV |
114 | with_spawn_id $gdb_main_spawn_id { |
115 | gdb_test_multiple "" "remote connection closed - main UI" { | |
116 | -re -wrap "Remote connection closed" { | |
117 | pass $gdb_test_name | |
118 | } | |
119 | } | |
120 | } | |
121 | ||
f3364a6d AB |
122 | with_spawn_id $gdb_main_spawn_id { |
123 | gdb_test "echo" "" \ | |
124 | "main UI, prompt after gdbserver dies" | |
125 | } | |
126 | ||
127 | with_spawn_id $extra_spawn_id { | |
128 | gdb_test "echo" "" \ | |
129 | "extra UI, prompt after gdbserver dies" | |
130 | } |