1# This testcase is part of GDB, the GNU debugger. 2# 3# Copyright 2019-2020 Free Software Foundation, Inc. 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 31if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} { 32 return -1 33} 34 35# Make sure we're disconnected, in case we're testing with an 36# extended-remote board, therefore already connected. 37gdb_test "disconnect" ".*" 38 39# Start gdbserver. 40set res [gdbserver_spawn "${binfile}"] 41set gdbserver_protocol [lindex $res 0] 42set gdbserver_gdbport [lindex $res 1] 43set gdbserver_pid [exp_pid -i $server_spawn_id] 44 45# Save the main UI's spawn ID. 46set gdb_main_spawn_id $gdb_spawn_id 47 48# Create the new PTY for the secondary console UI, issue the 'new-ui' 49# command, and wait for a prompt on the second UI. 50spawn -pty 51set extra_spawn_id $spawn_id 52set extra_tty_name $spawn_out(slave,name) 53gdb_test_multiple "new-ui console $extra_tty_name" "new-ui" { 54 -re "New UI allocated\r\n$gdb_prompt $" { 55 pass $gdb_test_name 56 } 57} 58with_spawn_id $extra_spawn_id { 59 gdb_test_multiple "" "initial prompt on extra console" { 60 -re "$gdb_prompt $" { 61 pass $gdb_test_name 62 } 63 } 64} 65 66# Connect to the remote and continue its execution from the other UI. 67with_spawn_id $extra_spawn_id { 68 gdb_test "target $gdbserver_protocol $gdbserver_gdbport" ".*" \ 69 "connect to gdbserver" 70 send_gdb "continue\n" 71} 72 73# We're going to kill the gdbserver, but before we do, lets make sure 74# that the inferior has started executing. 75with_spawn_id $server_spawn_id { 76 gdb_test_multiple "" "ensure inferior is running" { 77 -re "@@XX@@ Inferior Starting @@XX@@" { 78 pass $gdb_test_name 79 } 80 timeout { 81 fail $gdb_test_name 82 } 83 } 84} 85 86# Interact with the main UI. 87with_spawn_id $gdb_main_spawn_id { 88 gdb_test "echo hello\\n" "hello" "interact with GDB's main UI" 89} 90 91# Now kill the gdbserver. 92remote_exec target "kill -9 $gdbserver_pid" 93 94# We expect to land back at a GDB prompt in both UIs, however there is 95# currently an issue that in the original UI GDB doesn't reprint its 96# prompt. That said, getting a prompt isn't the point of this test. 97# The point is that we should be able to interact with GDB from either 98# interpreter now. 99 100with_spawn_id $gdb_main_spawn_id { 101 gdb_test "echo" "" \ 102 "main UI, prompt after gdbserver dies" 103} 104 105with_spawn_id $extra_spawn_id { 106 gdb_test "echo" "" \ 107 "extra UI, prompt after gdbserver dies" 108} 109