1 # Copyright
2016-2019 Free Software Foundation
, Inc.
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.
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.
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
/>.
16 # Test
'gdb "-ex new-ui TTY" -ex "start"' (or
any other synchronous
17 # execution command
), when TTY already has input pending. GDB used to
18 # internal error in this situation.
22 set compile_options
"debug"
23 if {[build_executable $testfile.exp $testfile $
{srcfile
} $
{compile_options
}] == -1} {
24 untested
"failed to compile"
30 proc test_command_line_new_ui_pending_input
{} {
34 # This test requires running a synchronous execution command from
36 if {[use_gdb_stub
] ||
[target_info gdb_protocol
] == "extended-remote" } {
37 unsupported
"can't run from the command line"
42 set extra_spawn_id $spawn_id
43 set extra_tty_name $spawn_out
(slave
,name)
45 # An arbitrary number of prints.
48 # Queue a few commands before GDB is started.
49 with_spawn_id $extra_spawn_id
{
50 for {set i
1} {$i
<= $nprints
} {incr i
} {
54 pass
"commands pending"
56 # Now spawn GDB
, creating a new
-ui and at the same time running a
57 # synchronous command.
60 set bpline
[gdb_get_line_number
"set breakpoint here"]
63 append options
" -iex \"set height 0\""
64 append options
" -iex \"set width 0\""
65 append options
" -iex \"new-ui console $extra_tty_name\""
66 append options
" -ex \"b $bpline\""
67 append options
" -ex \"run\""
69 if {[gdb_spawn_with_cmdline_opts
"$options $binfile"] != 0} {
76 # Consume the initial prompt
on the extra console.
77 with_spawn_id $extra_spawn_id
{
78 set test
"initial prompt on extra console"
79 gdb_test_multiple
"" $test {
86 # Check that we see the result of the print commands in the extra
88 with_spawn_id $extra_spawn_id
{
89 for {set i
1} {$i
<= $nprints
} {incr i
} {
90 set test
"print $i on extra console"
91 gdb_test_multiple
"" $test {
92 -re
" = $i\r\n$gdb_prompt " {
99 # Now check that we reach the breakpoint successfully.
100 set test
"run to breakpoint on main console"
101 gdb_test_multiple
"" $test {
102 -re
"Breakpoint .* main .*set breakpoint here.*$gdb_prompt $" {
107 # And likewise
on the extra console. No prompt is expected.
108 with_spawn_id $extra_spawn_id
{
109 set test
"run to breakpoint on extra console"
110 gdb_test_multiple
"" $test {
111 -re
"Breakpoint .* main .*set breakpoint here" {
118 # The driver. Calls all tests.
119 proc testcase_driver
{} {
120 test_command_line_new_ui_pending_input