diff options
author | Pedro Alves <palves@redhat.com> | 2017-03-08 00:14:59 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2017-03-08 00:14:59 +0000 |
commit | 9753a2f6d74dc92d2ad94993a5479ee0edbc6887 (patch) | |
tree | 8249537542c50a6d702920e67170e7c0f51bd770 /gdb/testsuite | |
parent | 1a4dd9ddae4ce51724b4e08c6304e7c64f8f916f (diff) | |
download | gdb-9753a2f6d74dc92d2ad94993a5479ee0edbc6887.zip gdb-9753a2f6d74dc92d2ad94993a5479ee0edbc6887.tar.gz gdb-9753a2f6d74dc92d2ad94993a5479ee0edbc6887.tar.bz2 |
Fix PR tui/21216: TUI line breaks regression
Commit d7e747318f4d04 ("Eliminate make_cleanup_ui_file_delete / make
ui_file a class hierarchy") regressed the TUI's command window.
Newlines miss doing a "carriage return", resulting in output like:
~~~~~~~~~~~~~~~~~~
(gdb) helpList of classes of commands:
aliases -- Aliases of other commands
breakpoints -- Making program stop at certain points
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Before the commit mentioned above, the default ui_file->to_write
implementation had a hack that would defer into the ui_file->to_fputs
method. The TUI's ui_file did not implement the to_write method, so
all writes would end up going to the ncurses window via tui_file_fputs
-> tui_puts.
After the commit above, the hack is gone, but the TUI's ui_file still
does not implement the ui_file::write method. Since tui_file inherits
from stdio_file, writing to a tui_file ends up doing fwrite on the
FILE stream the TUI is "associated" with, via stdio_file::write,
instead of writing to the ncurses window.
The fix is to have tui_file override the "write" method.
New test included.
gdb/ChangeLog:
2017-03-08 Pedro Alves <palves@redhat.com>
PR tui/21216
* tui/tui-file.c (tui_file::write): New.
* tui/tui-file.h (tui_file): Override "write".
* tui/tui-io.c (do_tui_putc, update_start_line): New functions,
factored out from ...
(tui_puts): ... here.
(tui_putc): Use them.
(tui_write): New function.
* tui/tui-io.h (tui_write): Declare.
gdb/testsuite/ChangeLog:
2017-03-08 Pedro Alves <palves@redhat.com>
PR tui/21216
* gdb.tui/tui-nl-filtered-output.exp: New file.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.tui/tui-nl-filtered-output.exp | 57 |
2 files changed, 62 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index f986520..0654bef 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2017-03-08 Pedro Alves <palves@redhat.com> + PR tui/21216 + * gdb.tui/tui-nl-filtered-output.exp: New file. + +2017-03-08 Pedro Alves <palves@redhat.com> + * gdb.base/completion.exp: Move TUI completion tests to ... * gdb.tui/completion.exp: ... this new file. diff --git a/gdb/testsuite/gdb.tui/tui-nl-filtered-output.exp b/gdb/testsuite/gdb.tui/tui-nl-filtered-output.exp new file mode 100644 index 0000000..d1f56f2 --- /dev/null +++ b/gdb/testsuite/gdb.tui/tui-nl-filtered-output.exp @@ -0,0 +1,57 @@ +# Copyright 2017 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Regression test for PR tui/21216 - TUI line breaks regression. +# +# Tests that newlines in filtered output force a "carriage return" in +# the TUI command window. With a broken gdb, instead of: +# +# (gdb) printf "hello\nworld\n" +# hello +# world +# (gdb) +# +# we'd get: +# +# (gdb) printf "hello\nworld\n"hello +# world +# +# (gdb) + +gdb_exit +gdb_start + +if {[skip_tui_tests]} { + return +} + +# Enable the TUI. + +set test "tui enable" +gdb_test_multiple "tui enable" $test { + -re "$gdb_prompt $" { + pass $test + } +} + +# Make sure filtering/pagination is enabled, but make the window high +# enough that we don't paginate in practice. +gdb_test_no_output "set pagination on" +gdb_test_no_output "set height 2000" + +gdb_test \ + {printf "hello\nworld\n"} \ + "hello\r\nworld" \ + "correct line breaks" |