public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Doug Evans <dje@google.com>
To: Eli Zaretskii <eliz@gnu.org>,
	   gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Speed up "gdb -tui" output
Date: Wed, 07 Jan 2015 21:59:00 -0000	[thread overview]
Message-ID: <21677.44074.982761.250152@ruffy2.mtv.corp.google.com> (raw)
In-Reply-To: <CADPb22QZ8qgfYfsT=wxQg8yKRE3EzPTc8QHcHpk8oXpA6DsA2A@mail.gmail.com>

Doug Evans writes:
 > Seems like the main source of the problem would be gdb_stdout,
 > so let's try to fix that first and go from there.

Here's a prototype.
I left fflush (stdout) in to be conservative.

Does this resolve the performance issues you're seeing well enough?

2015-01-07  Doug Evans  <dje@google.com>

	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 or
	gdb_stderr.
	* tui/tui-io.c (tui_puts): Remove call to wrefresh, fflush.
	(tui_readline_output): Call tui_refresh_cmd_win.
	(print_filename): Ditto.
	(tui_rl_display_match_list): Ditto.

diff --git a/gdb/tui/tui-command.c b/gdb/tui/tui-command.c
index d1a5ddb..6d98db2 100644
--- a/gdb/tui/tui-command.c
+++ b/gdb/tui/tui-command.c
@@ -129,3 +129,18 @@ tui_dispatch_ctrl_char (unsigned int ch)
       return c;
     }
 }
+
+/* Refresh the command window.  */
+
+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);
+}
diff --git a/gdb/tui/tui-command.h b/gdb/tui/tui-command.h
index 8cc5be4..174ba58 100644
--- a/gdb/tui/tui-command.h
+++ b/gdb/tui/tui-command.h
@@ -24,4 +24,6 @@
 
 extern unsigned int tui_dispatch_ctrl_char (unsigned int);
 
+extern void tui_refresh_cmd_win (void);
+
 #endif
diff --git a/gdb/tui/tui-file.c b/gdb/tui/tui-file.c
index b32cfa6..02d9082 100644
--- a/gdb/tui/tui-file.c
+++ b/gdb/tui/tui-file.c
@@ -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,12 @@ tui_file_flush (struct ui_file *file)
     case astring:
       break;
     case afile:
+      /* There is also gdb_stdlog, gdb_stdtarg, gdb_stdtargerr, but
+	 tui_setup_io maps those to gdb_stderr.  OTOH, do we need to make
+	 this conditional?  */
+      if (file == gdb_stdout
+	  || file == gdb_stderr)
+	tui_refresh_cmd_win ();
       fflush (stream->ts_filestream);
       break;
     }
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 233e7a6..c3ab612 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -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)
 {
@@ -187,10 +190,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.
@@ -316,6 +315,7 @@ tui_readline_output (int error, gdb_client_data data)
     {
       buf[size] = 0;
       tui_puts (buf);
+      tui_refresh_cmd_win ();
     }
 }
 #endif
@@ -367,6 +367,7 @@ print_filename (const char *to_print, const char *full_pathname)
     {
       PUTX (*s);
     }
+  tui_refresh_cmd_win ();
   return printed_len;
 }
 
@@ -425,6 +426,7 @@ tui_rl_display_match_list (char **matches, int len, int max)
       if (get_y_or_n () == 0)
 	{
 	  tui_puts ("\n");
+	  tui_refresh_cmd_win ();
 	  return;
 	}
     }

  reply	other threads:[~2015-01-07 21:59 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-06 16:12 Eli Zaretskii
2015-01-06 18:37 ` Doug Evans
2015-01-06 19:06   ` Eli Zaretskii
2015-01-06 20:54     ` Doug Evans
2015-01-07 18:30       ` Eli Zaretskii
2015-01-07 19:08         ` Doug Evans
2015-01-07 19:20           ` Eli Zaretskii
2015-01-07 19:30             ` Doug Evans
2015-01-07 19:48               ` Eli Zaretskii
2015-01-07 20:45                 ` Doug Evans
2015-01-07 21:59                   ` Doug Evans [this message]
2015-01-19 17:55                     ` Eli Zaretskii
2015-01-19 18:32                       ` Doug Evans
2015-01-31 21:37                         ` Eli Zaretskii
2015-02-03 17:52                           ` Pedro Alves
2015-02-03 18:47                             ` Eli Zaretskii
2015-02-04 11:55                             ` Pedro Alves
2015-02-04 12:27                               ` Pedro Alves
2015-02-04 15:39                                 ` Eli Zaretskii
2015-02-04 15:38                               ` Eli Zaretskii
2015-01-07 15:18   ` Pedro Alves
2015-01-07 17:57     ` Eli Zaretskii
2015-01-07 18:09       ` Doug Evans
2015-01-07 18:34         ` Eli Zaretskii
2015-01-07 19:16           ` Doug Evans
2015-01-07 19:32             ` Eli Zaretskii
2015-01-07 22:30               ` Pedro Alves
2015-01-19 17:52                 ` Eli Zaretskii
2015-01-07 18:00     ` Doug Evans
2015-01-07 18:12       ` Doug Evans
2015-01-07 18:34         ` Eli Zaretskii
2015-01-07 18:21       ` Eli Zaretskii
2015-01-07 18:56         ` Doug Evans
2015-01-07 19:11           ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=21677.44074.982761.250152@ruffy2.mtv.corp.google.com \
    --to=dje@google.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).