Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 2016-2020 Free Software Foundation, Inc. |
4295e285 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 | # 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. | |
19 | ||
20 | standard_testfile | |
21 | ||
22 | set compile_options "debug" | |
23 | if {[build_executable $testfile.exp $testfile ${srcfile} ${compile_options}] == -1} { | |
84c93cd5 | 24 | untested "failed to compile" |
4295e285 PA |
25 | return -1 |
26 | } | |
27 | ||
28 | # See intro. | |
29 | ||
30 | proc test_command_line_new_ui_pending_input {} { | |
31 | global gdb_prompt | |
32 | global binfile | |
33 | ||
34 | # This test requires running a synchronous execution command from | |
35 | # the command line. | |
36 | if {[use_gdb_stub] || [target_info gdb_protocol] == "extended-remote" } { | |
37 | unsupported "can't run from the command line" | |
38 | return 0 | |
39 | } | |
40 | ||
41 | spawn -pty | |
42 | set extra_spawn_id $spawn_id | |
43 | set extra_tty_name $spawn_out(slave,name) | |
44 | ||
45 | # An arbitrary number of prints. | |
46 | set nprints 3 | |
47 | ||
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} { | |
51 | send_gdb "print $i\n" | |
52 | } | |
53 | } | |
54 | pass "commands pending" | |
55 | ||
56 | # Now spawn GDB, creating a new-ui and at the same time running a | |
57 | # synchronous command. | |
58 | set test "spawn gdb" | |
59 | ||
60 | set bpline [gdb_get_line_number "set breakpoint here"] | |
61 | ||
62 | set options "" | |
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\"" | |
68 | ||
69 | if {[gdb_spawn_with_cmdline_opts "$options $binfile"] != 0} { | |
70 | fail $test | |
71 | return | |
72 | } else { | |
73 | pass $test | |
74 | } | |
75 | ||
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 { | |
80 | -re "$gdb_prompt $" { | |
81 | pass $test | |
82 | } | |
83 | } | |
84 | } | |
85 | ||
86 | # Check that we see the result of the print commands in the extra | |
87 | # UI. | |
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 " { | |
93 | pass "$test" | |
94 | } | |
95 | } | |
96 | } | |
97 | } | |
98 | ||
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 $" { | |
103 | pass $test | |
104 | } | |
105 | } | |
106 | ||
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" { | |
112 | pass $test | |
113 | } | |
114 | } | |
115 | } | |
116 | } | |
117 | ||
118 | # The driver. Calls all tests. | |
119 | proc testcase_driver {} { | |
120 | test_command_line_new_ui_pending_input | |
121 | } | |
122 | ||
123 | testcase_driver |