Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.server / multi-ui-errors.exp
CommitLineData
f3364a6d
AB
1# This testcase is part of GDB, the GNU debugger.
2#
88b9d363 3# Copyright 2019-2022 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
23load_lib gdbserver-support.exp
24
25standard_testfile
26
27if {[skip_gdbserver_tests]} {
28 return 0
29}
30
8dc558a0
SM
31save_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.
45gdb_test "disconnect" ".*"
46
47# Start gdbserver.
48set res [gdbserver_spawn "${binfile}"]
49set gdbserver_protocol [lindex $res 0]
50set gdbserver_gdbport [lindex $res 1]
51set gdbserver_pid [exp_pid -i $server_spawn_id]
52
53# Save the main UI's spawn ID.
54set 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.
58spawn -pty
59set extra_spawn_id $spawn_id
60set extra_tty_name $spawn_out(slave,name)
61gdb_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}
66with_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.
75with_spawn_id $extra_spawn_id {
b0999b9b
AB
76 gdb_test "target $gdbserver_protocol $gdbserver_gdbport" ".*" \
77 "connect to gdbserver"
f3364a6d
AB
78 send_gdb "continue\n"
79}
80
81# We're going to kill the gdbserver, but before we do, lets make sure
82# that the inferior has started executing.
83with_spawn_id $server_spawn_id {
84 gdb_test_multiple "" "ensure inferior is running" {
85 -re "@@XX@@ Inferior Starting @@XX@@" {
86 pass $gdb_test_name
87 }
88 timeout {
89 fail $gdb_test_name
90 }
91 }
92}
93
94# Interact with the main UI.
95with_spawn_id $gdb_main_spawn_id {
96 gdb_test "echo hello\\n" "hello" "interact with GDB's main UI"
97}
98
99# Now kill the gdbserver.
100remote_exec target "kill -9 $gdbserver_pid"
101
102# We expect to land back at a GDB prompt in both UIs, however there is
103# currently an issue that in the original UI GDB doesn't reprint its
104# prompt. That said, getting a prompt isn't the point of this test.
105# The point is that we should be able to interact with GDB from either
106# interpreter now.
107
108with_spawn_id $gdb_main_spawn_id {
109 gdb_test "echo" "" \
110 "main UI, prompt after gdbserver dies"
111}
112
113with_spawn_id $extra_spawn_id {
114 gdb_test "echo" "" \
115 "extra UI, prompt after gdbserver dies"
116}
This page took 0.259126 seconds and 4 git commands to generate.