1 # Copyright 2024 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 # If a user uses 'Ctrl+d' to exit from a secondary prompt, then
17 # readline can get stuck thinking that an EOF has arrived. As a
18 # consequence of this readline will output an extra newline every time
19 # that it exits bracketed-paste-mode (which is done after every line
20 # of input). The result is the user will see some unexpected blank
21 # lines in the output.
25 if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
29 # The fix for this issue relies on GDB being able to adjust the EOF
30 # flag state within readline. Access to this state was added for
31 # readline 8.2, but was also backported to out internal readline. If
32 # this feature is not available then this test might not pass.
33 if { ![readline_supports_eof_flag] } {
34 unsupported "readline is not eof flag aware"
38 # Create a breakpoint then issue the 'commands' commands. When the
39 # secondary prompt is displayed, use Ctrl+d to send EOF to readline
40 # and cancel the input.
42 # Then check that readline is not stuck thinking that an EOF has
43 # arrived. If it is then GDB will start displaying extra blank lines
44 # after each line of input.
46 clean_restart $::binfile
50 # Issue the 'commands' command, and wait for the secondary prompt
52 gdb_test_multiple "commands" "start b/p commands" {
53 -re "Type commands for breakpoint\\(s\\) 1, one per line\\.\r\n" {
56 -re "^End with a line saying just \"end\"\\.\r\n" {
64 # Send Ctrl+d to GDB and wait for the 'quit' message, and then for
65 # the GDB prompt to be displayed.
67 # As this test runs (sometimes) with bracketed-paste-mode on then
68 # we need to accept a control sequence before the prompt. This
69 # control sequence can contain '\r', which is why we only check
70 # for '\n' here, which is different than what we do in the rest of
71 # the testsuite, where we usually check for '\r\n' together.
73 gdb_test_multiple "" "quit b/p commands" {
74 -re "^quit\r\n\[^\n\]*$::gdb_prompt $" {
79 # Now issue any other command. If readline is stuck in EOF mode
80 # (thinking that an EOF has just arrived), then we'll see an extra
81 # blank line after the command, and before any command output.
83 # As described above we scan for '\n' only in some patterns here
84 # as we're allowing for a control sequence that might include
86 gdb_test_multiple "show architecture" "check for excessive blank lines" {
87 -re "^show architecture\r\n" {
90 -re "^\[^\n\]*The target architecture is set to \[^\r\n\]+\\.\r\n\[^\n\]*$::gdb_prompt $" {
93 -re "^\[^\n\]*\nThe target architecture is set to \[^\r\n\]+\\.\r\n\[^\n\]*$::gdb_prompt" {
99 # Run the test in various different terminal modes.
100 with_test_prefix "default" {
104 save_vars { env(TERM) } {
107 with_test_prefix "with non-dump terminal" {
110 save_vars { env(INPUTRC) } {
112 # Create an inputrc file that turns bracketed paste mode
113 # on. This is usually turned off (see lib/gdb.exp), but
114 # for the next test we want to see what happens with this
116 set inputrc [standard_output_file inputrc]
117 set fd [open "$inputrc" w]
118 puts $fd "set enable-bracketed-paste on"
121 setenv INPUTRC "$inputrc"
122 with_test_prefix "with bracketed-paste-mode on" {