Make gdb_flush also flush the wrap buffer
authorIain Buclaw <ibuclaw@gdcproject.org>
Wed, 5 Feb 2020 11:25:09 +0000 (12:25 +0100)
committerTom Tromey <tromey@adacore.com>
Fri, 7 Feb 2020 20:07:39 +0000 (13:07 -0700)
This changes gdb_flush to also flush the internal wrap buffer.  A few
places needed to continue using the previous approach, so this also
introduces ui_file_flush for those.

gdb/ChangeLog
2020-02-05  Iain Buclaw  <ibuclaw@gdcproject.org>

        * gdb/event-loop.c (gdb_wait_for_event): Update.
        * gdb/printcmd.c (printf_command): Update.
        * gdb/remote-fileio.c (remote_fileio_func_write): Update.
        * gdb/remote-sim.c (gdb_os_flush_stdout): Update.
        (gdb_os_flush_stderr): Update.
        * gdb/remote.c (remote_console_output): Update.
        * gdb/ui-file.c (gdb_flush): Rename to...
        (ui_file_flush): ...this.
        (stderr_file::write): Update.
        (stderr_file::puts): Update.
        * gdb/ui-file.h (gdb_flush): Rename to...
        (ui_file_flush): ...this.
        * gdb/utils.c (gdb_flush): Add function.
        * gdb/utils.h (gdb_flush): Add declaration.

Change-Id: I7ca143d30f03dc39f218f6e880eb9bca9e15af39

gdb/ChangeLog
gdb/event-loop.c
gdb/event-top.c
gdb/printcmd.c
gdb/remote-fileio.c
gdb/remote-sim.c
gdb/remote.c
gdb/ui-file.c
gdb/ui-file.h
gdb/utils.c
gdb/utils.h

index 2b0e92229310619339dc218ce64d59f5ec7094be..928fb9c9b95a16af9164a9f9586fc0e80b914ac2 100644 (file)
@@ -1,3 +1,20 @@
+2020-02-05  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+        * gdb/event-loop.c (gdb_wait_for_event): Update.
+        * gdb/printcmd.c (printf_command): Update.
+        * gdb/remote-fileio.c (remote_fileio_func_write): Update.
+        * gdb/remote-sim.c (gdb_os_flush_stdout): Update.
+        (gdb_os_flush_stderr): Update.
+        * gdb/remote.c (remote_console_output): Update.
+        * gdb/ui-file.c (gdb_flush): Rename to...
+        (ui_file_flush): ...this.
+        (stderr_file::write): Update.
+        (stderr_file::puts): Update.
+        * gdb/ui-file.h (gdb_flush): Rename to...
+        (ui_file_flush): ...this.
+        * gdb/utils.c (gdb_flush): Add function.
+        * gdb/utils.h (gdb_flush): Add declaration.
+
 2020-02-07  Tom Tromey  <tromey@adacore.com>
 
        PR breakpoints/24915:
index 32f4ccaae741edd9926bad461c319f3d7f87a042..5be050df39357e442008313e1c9463779254e0c6 100644 (file)
@@ -747,8 +747,8 @@ gdb_wait_for_event (int block)
   int num_found = 0;
 
   /* Make sure all output is done before getting another event.  */
-  gdb_flush (gdb_stdout);
-  gdb_flush (gdb_stderr);
+  ui_file_flush (gdb_stdout);
+  ui_file_flush (gdb_stderr);
 
   if (gdb_notifier.num_fds == 0)
     return -1;
index 9f219f60ba12215780c99ef5c3366880f978dccf..8ac6965f38874e209830ca53be5a38edf2647037 100644 (file)
@@ -416,7 +416,7 @@ display_gdb_prompt (const char *new_prompt)
       /* Don't use a _filtered function here.  It causes the assumed
          character position to be off, since the newline we read from
          the user is not accounted for.  */
-      fputs_unfiltered (actual_gdb_prompt.c_str (), gdb_stdout);
+      fprintf_unfiltered (gdb_stdout, "%s", actual_gdb_prompt.c_str ());
       gdb_flush (gdb_stdout);
     }
 }
index 95739cd77d2ab63bcd6181e72731befeb05c03a2..ed2c8d47add3ff980c403625cbdf4a86f47fc43e 100644 (file)
@@ -2720,7 +2720,7 @@ printf_command (const char *arg, int from_tty)
   ui_printf (arg, gdb_stdout);
   reset_terminal_style (gdb_stdout);
   wrap_here ("");
-  gdb_flush (gdb_stdout);
+  ui_file_flush (gdb_stdout);
 }
 
 /* Implement the "eval" command.  */
index e75068390a10c6aa63094bc8ec08423a42657afc..40add06509ed56e37a8701447b2182f749dc2093 100644 (file)
@@ -641,7 +641,7 @@ remote_fileio_func_write (remote_target *remote, char *buf)
       case FIO_FD_CONSOLE_OUT:
        ui_file_write (target_fd == 1 ? gdb_stdtarg : gdb_stdtargerr,
                       (char *) buffer, length);
-       gdb_flush (target_fd == 1 ? gdb_stdtarg : gdb_stdtargerr);
+       ui_file_flush (target_fd == 1 ? gdb_stdtarg : gdb_stdtargerr);
        ret = length;
        break;
       default:
index 582d206d60c7a13c285a98ee1fd5a56a3390e3db..16fd6bf7e232f66df60d51a0f6ed441330d915d7 100644 (file)
@@ -361,7 +361,7 @@ gdb_os_write_stdout (host_callback *p, const char *buf, int len)
 static void
 gdb_os_flush_stdout (host_callback *p)
 {
-  gdb_flush (gdb_stdtarg);
+  ui_file_flush (gdb_stdtarg);
 }
 
 /* GDB version of os_write_stderr callback.  */
@@ -386,7 +386,7 @@ gdb_os_write_stderr (host_callback *p, const char *buf, int len)
 static void
 gdb_os_flush_stderr (host_callback *p)
 {
-  gdb_flush (gdb_stdtargerr);
+  ui_file_flush (gdb_stdtargerr);
 }
 
 /* GDB version of printf_filtered callback.  */
index 73213806b5a561bd0ccda242d0b962743266b19f..19470805c70a81bdb7dd1e82050f77bdeb8ce1a8 100644 (file)
@@ -6784,7 +6784,7 @@ remote_console_output (const char *msg)
       tb[1] = 0;
       fputs_unfiltered (tb, gdb_stdtarg);
     }
-  gdb_flush (gdb_stdtarg);
+  ui_file_flush (gdb_stdtarg);
 }
 
 struct stop_reply : public notif_event
index 10192a98cd04a9289bcd2cb14fae748d0a9993a6..61e9d205023db895174805f99330b44b7e673b24 100644 (file)
@@ -91,7 +91,7 @@ null_file::write_async_safe (const char *buf, long sizeof_buf)
 \f
 
 void
-gdb_flush (struct ui_file *file)
+ui_file_flush (struct ui_file *file)
 {
   file->flush ();
 }
@@ -315,7 +315,7 @@ stdio_file::can_emit_style_escape ()
 void
 stderr_file::write (const char *buf, long length_buf)
 {
-  gdb_flush (gdb_stdout);
+  ui_file_flush (gdb_stdout);
   stdio_file::write (buf, length_buf);
 }
 
@@ -325,7 +325,7 @@ stderr_file::write (const char *buf, long length_buf)
 void
 stderr_file::puts (const char *linebuffer)
 {
-  gdb_flush (gdb_stdout);
+  ui_file_flush (gdb_stdout);
   stdio_file::puts (linebuffer);
 }
 
index 1df477d5b84a8e88a8bc50e26775c7cc1950de20..b0bc3f23421c1a9357daf061722ffdf61418f742 100644 (file)
@@ -100,7 +100,7 @@ public:
 /* A preallocated null_file stream.  */
 extern null_file null_stream;
 
-extern void gdb_flush (ui_file *);
+extern void ui_file_flush (ui_file *);
 
 extern int ui_file_isatty (struct ui_file *);
 
index d58c8742baeefd8c7cd15e219557c098bc26608f..49625b1921345555d3e9f539b25083f0d5ca55ea 100644 (file)
@@ -1544,6 +1544,15 @@ flush_wrap_buffer (struct ui_file *stream)
     }
 }
 
+/* See utils.h.  */
+
+void
+gdb_flush (struct ui_file *stream)
+{
+  flush_wrap_buffer (stream);
+  ui_file_flush (stream);
+}
+
 /* Indicate that if the next sequence of characters overflows the line,
    a newline should be inserted here rather than when it hits the end.
    If INDENT is non-null, it is a string to be printed to indent the
index 3f00a2f2386eabb448c79ea5bb0feb6d56019fa3..10877da56ee3e6ad19b03f8300978256589b7991 100644 (file)
@@ -323,6 +323,12 @@ extern struct ui_file **current_ui_gdb_stdin_ptr (void);
 extern struct ui_file **current_ui_gdb_stderr_ptr (void);
 extern struct ui_file **current_ui_gdb_stdlog_ptr (void);
 
+/* Flush STREAM.  This is a wrapper for ui_file_flush that also
+   flushes any output pending from uses of the *_filtered output
+   functions; that output is kept in a special buffer so that
+   pagination and styling are handled properly.  */
+extern void gdb_flush (struct ui_file *);
+
 /* The current top level's ui_file streams.  */
 
 /* Normal results */
This page took 0.034718 seconds and 4 git commands to generate.