new-ui-echo.exp revision 1.1.1.1 1 1.1 christos # Copyright 2016 Free Software Foundation, Inc.
2 1.1 christos
3 1.1 christos # This program is free software; you can redistribute it and/or modify
4 1.1 christos # it under the terms of the GNU General Public License as published by
5 1.1 christos # the Free Software Foundation; either version 3 of the License, or
6 1.1 christos # (at your option) any later version.
7 1.1 christos #
8 1.1 christos # This program is distributed in the hope that it will be useful,
9 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 1.1 christos # GNU General Public License for more details.
12 1.1 christos #
13 1.1 christos # You should have received a copy of the GNU General Public License
14 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 1.1 christos
16 1.1 christos # Regression test for PR 20494 (User input stops being echoed in CLI).
17 1.1 christos # Before that bug was fixed, starting an inferior in a non-main UI
18 1.1 christos # would result in GDB saving readline's prepped terminal state as
19 1.1 christos # gdb's "own" terminal state (i.e., target_terminal_ours state),
20 1.1 christos # resulting in subsequent synchronous execution commands in the main
21 1.1 christos # UI disabling input echo.
22 1.1 christos
23 1.1 christos standard_testfile
24 1.1 christos
25 1.1 christos set compile_options "debug"
26 1.1 christos if {[build_executable $testfile.exp $testfile ${srcfile} ${compile_options}] == -1} {
27 1.1 christos untested "failed to compile $testfile"
28 1.1 christos return -1
29 1.1 christos }
30 1.1 christos
31 1.1 christos # Start gdb and create an extra console UI. Start the inferior in the
32 1.1 christos # DRIVER console (either "main" or "extra"), and then enter a
33 1.1 christos # synchronous execution command in the extra console. Before PR 20494
34 1.1 christos # was fixed, if DRIVER was a secondary UI, GDB would lose input echo
35 1.1 christos # on the main UI after the synchronous execution command. We test
36 1.1 christos # with both main and extra UIs as driver consoles for completeness.
37 1.1 christos
38 1.1 christos proc echo_test {driver} {
39 1.1 christos global srcfile testfile
40 1.1 christos global gdb_prompt
41 1.1 christos global gdb_spawn_id
42 1.1 christos global gdb_main_spawn_id extra_spawn_id
43 1.1 christos global decimal
44 1.1 christos
45 1.1 christos clean_restart $testfile
46 1.1 christos
47 1.1 christos # Save the main UI's spawn ID.
48 1.1 christos set gdb_main_spawn_id $gdb_spawn_id
49 1.1 christos
50 1.1 christos # Create the new PTY for the secondary console UI.
51 1.1 christos spawn -pty
52 1.1 christos set extra_spawn_id $spawn_id
53 1.1 christos set extra_tty_name $spawn_out(slave,name)
54 1.1 christos gdb_test_multiple "new-ui console $extra_tty_name" "new-ui" {
55 1.1 christos -re "New UI allocated\r\n$gdb_prompt $" {
56 1.1 christos }
57 1.1 christos }
58 1.1 christos
59 1.1 christos with_spawn_id $extra_spawn_id {
60 1.1 christos set test "initial prompt on extra console"
61 1.1 christos gdb_test_multiple "" $test {
62 1.1 christos -re "$gdb_prompt $" {
63 1.1 christos pass $test
64 1.1 christos }
65 1.1 christos }
66 1.1 christos }
67 1.1 christos
68 1.1 christos set main_console [list $gdb_main_spawn_id "main console"]
69 1.1 christos set extra_console [list $extra_spawn_id "extra console"]
70 1.1 christos
71 1.1 christos if {$driver == "main"} {
72 1.1 christos set con1 $main_console
73 1.1 christos set con2 $extra_console
74 1.1 christos } else {
75 1.1 christos set con1 $extra_console
76 1.1 christos set con2 $main_console
77 1.1 christos }
78 1.1 christos
79 1.1 christos set con1_spawn_id [lindex $con1 0]
80 1.1 christos set con2_spawn_id [lindex $con2 0]
81 1.1 christos set con1_name [lindex $con1 1]
82 1.1 christos set con2_name [lindex $con2 1]
83 1.1 christos
84 1.1 christos set bp_lineno [gdb_get_line_number "set break $con1_name here"]
85 1.1 christos
86 1.1 christos with_spawn_id $con1_spawn_id {
87 1.1 christos gdb_test "break $srcfile:$bp_lineno" \
88 1.1 christos "Breakpoint $decimal .*$srcfile, line $bp_lineno\\." \
89 1.1 christos "set breakpoint using $con1_name"
90 1.1 christos gdb_run_cmd
91 1.1 christos gdb_test "" "set break $con1_name here .*" "run to breakpoint on $con1_name"
92 1.1 christos }
93 1.1 christos
94 1.1 christos with_spawn_id $con2_spawn_id {
95 1.1 christos set test "breakpoint hit reported on $con2_name too"
96 1.1 christos gdb_test_multiple "" $test {
97 1.1 christos -re "Breakpoint $decimal, .* set break $con1_name here " {
98 1.1 christos pass $test
99 1.1 christos }
100 1.1 christos }
101 1.1 christos gdb_test "next" "global = 1;" "next on $con2_name"
102 1.1 christos }
103 1.1 christos
104 1.1 christos # Ensure echo remains enabled in both consoles.
105 1.1 christos with_spawn_id $con1_spawn_id {
106 1.1 christos gdb_test "print 1" "^print 1\r\n\\\$1 = 1" "print on $con1_name echoes"
107 1.1 christos }
108 1.1 christos with_spawn_id $con2_spawn_id {
109 1.1 christos gdb_test "print 2" "^print 2\r\n\\\$2 = 2" "print on $con2_name echoes"
110 1.1 christos }
111 1.1 christos }
112 1.1 christos
113 1.1 christos # The test driver.
114 1.1 christos
115 1.1 christos proc test_driver {} {
116 1.1 christos
117 1.1 christos with_test_prefix "extra console as driver" {
118 1.1 christos echo_test "extra"
119 1.1 christos }
120 1.1 christos
121 1.1 christos with_test_prefix "main console as driver" {
122 1.1 christos echo_test "main"
123 1.1 christos }
124 1.1 christos
125 1.1 christos }
126 1.1 christos
127 1.1 christos test_driver
128