public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Introduce and use flush_streams
@ 2020-04-13 21:10 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2020-04-13 21:10 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c1cd3163d99efe4f7cbe7f228859fd93f28e06bb

commit c1cd3163d99efe4f7cbe7f228859fd93f28e06bb
Author: Tom Tromey <tom@tromey.com>
Date:   Mon Apr 13 12:42:59 2020 -0600

    Introduce and use flush_streams
    
    Code in gdbsupport can't call gdb_flush, so this introduces a new
    "flush_streams" function that must be supplied by the client.
    
    Note that the similar gdb_flush_out_err exists, but it isn't defined
    in quite the same way, so it wasn't clear to me whether the two could
    be merged.
    
    gdb/ChangeLog
    2020-04-13  Tom Tromey  <tom@tromey.com>
    
            * utils.c (flush_streams): New function.
            * event-loop.c (gdb_wait_for_event): Call flush_streams.
    
    gdbsupport/ChangeLog
    2020-04-13  Tom Tromey  <tom@tromey.com>
    
            * errors.h (flush_streams): Declare.

Diff:
---
 gdb/ChangeLog        | 5 +++++
 gdb/event-loop.c     | 3 +--
 gdb/utils.c          | 9 +++++++++
 gdbsupport/ChangeLog | 4 ++++
 gdbsupport/errors.h  | 4 ++++
 5 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d4facee8884..c0b3ae78d30 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2020-04-13  Tom Tromey  <tom@tromey.com>
+
+	* utils.c (flush_streams): New function.
+	* event-loop.c (gdb_wait_for_event): Call flush_streams.
+
 2020-04-13  Tom Tromey  <tom@tromey.com>
 
 	* event-loop.c (handle_file_event): Use warning, not
diff --git a/gdb/event-loop.c b/gdb/event-loop.c
index a5d2f6fa1cc..4ce8899612c 100644
--- a/gdb/event-loop.c
+++ b/gdb/event-loop.c
@@ -663,8 +663,7 @@ gdb_wait_for_event (int block)
   int num_found = 0;
 
   /* Make sure all output is done before getting another event.  */
-  gdb_stdout->flush ();
-  gdb_stderr->flush ();
+  flush_streams ();
 
   if (gdb_notifier.num_fds == 0)
     return -1;
diff --git a/gdb/utils.c b/gdb/utils.c
index f5b20331b1e..2f2cd845c4b 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -691,6 +691,15 @@ malloc_failure (long size)
     }
 }
 
+/* See common/errors.h.  */
+
+void
+flush_streams ()
+{
+  gdb_stdout->flush ();
+  gdb_stderr->flush ();
+}
+
 /* My replacement for the read system call.
    Used like `read' but keeps going if `read' returns too soon.  */
 
diff --git a/gdbsupport/ChangeLog b/gdbsupport/ChangeLog
index 880a6ae7658..a065a9abaff 100644
--- a/gdbsupport/ChangeLog
+++ b/gdbsupport/ChangeLog
@@ -1,3 +1,7 @@
+2020-04-13  Tom Tromey  <tom@tromey.com>
+
+	* errors.h (flush_streams): Declare.
+
 2020-04-13  Tom Tromey  <tom@tromey.com>
 
 	* gdb_select.h: Move from ../gdb/.
diff --git a/gdbsupport/errors.h b/gdbsupport/errors.h
index da13482798a..f8f6c157f23 100644
--- a/gdbsupport/errors.h
+++ b/gdbsupport/errors.h
@@ -87,4 +87,8 @@ extern void perror_with_name (const char *string) ATTRIBUTE_NORETURN;
 
 extern void malloc_failure (long size) ATTRIBUTE_NORETURN;
 
+/* Flush stdout and stderr.  Must be provided by the client.  */
+
+extern void flush_streams ();
+
 #endif /* COMMON_ERRORS_H */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-04-13 21:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-13 21:10 [binutils-gdb] Introduce and use flush_streams Tom Tromey

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).