Speed up GDB's TUI output

In the TUI mode, we call wrefresh after outputting every single
character.  This results in the I/O becoming very slow.  Fix this by
delaying refreshing the console window until an explicit flush of
gdb_stdout is requested, or a write to any other (unbuffered) file is
done.

2015-02-04  Doug Evans  <dje@google.com>
	    Pedro Alves  <palves@redhat.com>
	    Eli Zaretskii  <eliz@gnu.org>

	PR tui/17810
	* tui/tui-command.c (tui_refresh_cmd_win): New function.
	* tui/tui-command.c (tui_refresh_cmd_win): Declare.
	* tui/tui-file.c: #include tui/tui-command.h.
	(tui_file_fputs): Refresh command window if stream is not gdb_stdout.
	(tui_file_flush): Refresh command window if stream is gdb_stdout.
	* tui/tui-io.c (tui_puts): Remove calls to wrefresh, fflush.
This commit is contained in:
Doug Evans 2015-02-04 12:27:28 +01:00 committed by Pedro Alves
parent f3853b3444
commit 518be979d9
5 changed files with 43 additions and 6 deletions

View File

@ -1,3 +1,15 @@
2015-02-04 Doug Evans <dje@google.com>
Pedro Alves <palves@redhat.com>
Eli Zaretskii <eliz@gnu.org>
PR tui/17810
* tui/tui-command.c (tui_refresh_cmd_win): New function.
* tui/tui-command.c (tui_refresh_cmd_win): Declare.
* tui/tui-file.c: #include tui/tui-command.h.
(tui_file_fputs): Refresh command window if stream is not gdb_stdout.
(tui_file_flush): Refresh command window if stream is gdb_stdout.
* tui/tui-io.c (tui_puts): Remove calls to wrefresh, fflush.
2015-02-04 Pedro Alves <palves@redhat.com>
Fix build breakage.

View File

@ -129,3 +129,18 @@ tui_dispatch_ctrl_char (unsigned int ch)
return c;
}
}
/* See tui-command.h. */
void
tui_refresh_cmd_win (void)
{
WINDOW *w = TUI_CMD_WIN->generic.handle;
wrefresh (w);
/* FIXME: It's not clear why this is here.
It was present in the original tui_puts code and is kept in order to
not introduce some subtle breakage. */
fflush (stdout);
}

View File

@ -24,4 +24,7 @@
extern unsigned int tui_dispatch_ctrl_char (unsigned int);
/* Refresh the command window. */
extern void tui_refresh_cmd_win (void);
#endif

View File

@ -20,7 +20,7 @@
#include "ui-file.h"
#include "tui/tui-file.h"
#include "tui/tui-io.h"
#include "tui/tui-command.h"
#include "tui.h"
/* A ``struct ui_file'' that is compatible with all the legacy
@ -179,6 +179,10 @@ tui_file_fputs (const char *linebuffer, struct ui_file *file)
else
{
tui_puts (linebuffer);
/* gdb_stdout is buffered, and the caller must gdb_flush it at
appropriate times. Other streams are not so buffered. */
if (file != gdb_stdout)
tui_refresh_cmd_win ();
}
}
@ -239,6 +243,10 @@ tui_file_flush (struct ui_file *file)
case astring:
break;
case afile:
/* gdb_stdout is buffered. Other files are always flushed on
every write. */
if (file == gdb_stdout)
tui_refresh_cmd_win ();
fflush (stream->ts_filestream);
break;
}

View File

@ -159,7 +159,10 @@ tui_putc (char c)
tui_puts (buf);
}
/* Print the string in the curses command window. */
/* Print the string in the curses command window.
The output is buffered. It is up to the caller to refresh the screen
if necessary. */
void
tui_puts (const char *string)
{
@ -201,10 +204,6 @@ tui_puts (const char *string)
TUI_CMD_WIN->detail.command_info.curch);
TUI_CMD_WIN->detail.command_info.start_line
= TUI_CMD_WIN->detail.command_info.cur_line;
/* We could defer the following. */
wrefresh (w);
fflush (stdout);
}
/* Readline callback.