]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Speed up GDB's TUI output
authorDoug Evans <dje@google.com>
Wed, 4 Feb 2015 12:04:30 +0000 (13:04 +0100)
committerPedro Alves <palves@redhat.com>
Wed, 4 Feb 2015 12:04:30 +0000 (13:04 +0100)
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, 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.
(tui_readline_output): Call tui_refresh_cmd_win.
(print_filename): Likewise.
(tui_rl_display_match_list): Likewise.

gdb/ChangeLog
gdb/tui/tui-command.c
gdb/tui/tui-command.h
gdb/tui/tui-file.c
gdb/tui/tui-io.c

index 5cca93ef98277d24c6876f6c645a13c529046f02..1f23daee0bbeac26049d90a8cc652d2e6b231ea4 100644 (file)
@@ -1,3 +1,18 @@
+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.
+       (tui_readline_output): Call tui_refresh_cmd_win.
+       (print_filename): Likewise.
+       (tui_rl_display_match_list): Likewise.
+
 2015-02-03  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        Filter out inferior gcc option -fpreprocessed.
index d1a5ddb67fd166c4e0d81d110f988f75303c013e..355106383b8d355d47db982e318011581fd5a7e4 100644 (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);
+}
index 8cc5be4f79d9f81d3c41379868dbc461390912e1..ede2ecc93434750260050e4064246f218759b4a1 100644 (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
index b32cfa604d193fe868c568d77b77bbb2b60ecb0d..4b4b92c43428d7f8772da69fb0094b53682b7cd3 100644 (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;
     }
index 19e9485ea3884e108e45ee57f9a3712dd91d16c5..13cc5fac4e9c58a2ceafaea5cffa70a27b78c034 100644 (file)
@@ -158,7 +158,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)
 {
@@ -200,10 +203,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.
@@ -342,6 +341,7 @@ tui_readline_output (int error, gdb_client_data data)
     {
       buf[size] = 0;
       tui_puts (buf);
+      tui_refresh_cmd_win ();
     }
 }
 #endif
@@ -393,6 +393,7 @@ print_filename (const char *to_print, const char *full_pathname)
     {
       PUTX (*s);
     }
+  tui_refresh_cmd_win ();
   return printed_len;
 }
 
@@ -448,9 +449,11 @@ tui_rl_display_match_list (char **matches, int len, int max)
       xsnprintf (msg, sizeof (msg),
                 "\nDisplay all %d possibilities? (y or n)", len);
       tui_puts (msg);
+      tui_refresh_cmd_win ();
       if (get_y_or_n () == 0)
        {
          tui_puts ("\n");
+         tui_refresh_cmd_win ();
          return;
        }
     }
@@ -522,6 +525,7 @@ tui_rl_display_match_list (char **matches, int len, int max)
        }
       tui_putc ('\n');
     }
+  tui_refresh_cmd_win ();
 }
 
 /* Setup the IO for curses or non-curses mode.