mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-14 12:53:34 +08:00
9753a2f6d7
Commit d7e747318f
("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.
65 lines
2.0 KiB
C
65 lines
2.0 KiB
C
/* UI_FILE - a generic STDIO like output stream.
|
|
Copyright (C) 1999-2017 Free Software Foundation, Inc.
|
|
|
|
This file is part of GDB.
|
|
|
|
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/>. */
|
|
|
|
#include "defs.h"
|
|
#include "tui/tui-file.h"
|
|
#include "tui/tui-io.h"
|
|
#include "tui/tui-command.h"
|
|
#include "tui.h"
|
|
|
|
tui_file::tui_file (FILE *stream)
|
|
: stdio_file (stream)
|
|
{}
|
|
|
|
/* All TUI I/O sent to the *_filtered and *_unfiltered functions
|
|
eventually ends up here. The fputs_unfiltered_hook is primarily
|
|
used by GUIs to collect all output and send it to the GUI, instead
|
|
of the controlling terminal. Only output to gdb_stdout and
|
|
gdb_stderr are sent to the hook. Everything else is sent on to
|
|
fputs to allow file I/O to be handled appropriately. */
|
|
|
|
void
|
|
tui_file::puts (const char *linebuffer)
|
|
{
|
|
tui_puts (linebuffer);
|
|
/* gdb_stdout is buffered, and the caller must gdb_flush it at
|
|
appropriate times. Other streams are not so buffered. */
|
|
if (this != gdb_stdout)
|
|
tui_refresh_cmd_win ();
|
|
}
|
|
|
|
void
|
|
tui_file::write (const char *buf, long length_buf)
|
|
{
|
|
tui_write (buf, length_buf);
|
|
/* gdb_stdout is buffered, and the caller must gdb_flush it at
|
|
appropriate times. Other streams are not so buffered. */
|
|
if (this != gdb_stdout)
|
|
tui_refresh_cmd_win ();
|
|
}
|
|
|
|
void
|
|
tui_file::flush ()
|
|
{
|
|
/* gdb_stdout is buffered. Other files are always flushed on
|
|
every write. */
|
|
if (this == gdb_stdout)
|
|
tui_refresh_cmd_win ();
|
|
stdio_file::flush ();
|
|
}
|