]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Introduce and use flush_streams
authorTom Tromey <tom@tromey.com>
Mon, 13 Apr 2020 18:42:59 +0000 (12:42 -0600)
committerTom Tromey <tromey@adacore.com>
Mon, 13 Apr 2020 20:10:04 +0000 (14:10 -0600)
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.

gdb/ChangeLog
gdb/event-loop.c
gdb/utils.c
gdbsupport/ChangeLog
gdbsupport/errors.h

index d4facee888418efd96444d923d2dabec656fcd40..c0b3ae78d30bab37533710c01bd6f05749b7d4f5 100644 (file)
@@ -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
index a5d2f6fa1cc4cc00df49dd1cd0523d9585854727..4ce8899612c425c222dc128df8cab67c6b1eed90 100644 (file)
@@ -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;
index f5b20331b1e2f2966cea7abce27836b639874508..2f2cd845c4b14218c5f906e44c4542c270902b21 100644 (file)
@@ -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.  */
 
index 880a6ae7658c347b33b7c1aa16557c4941f570f0..a065a9abaffcb1628f4f5b71cfc2e77fefa13e6d 100644 (file)
@@ -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/.
index da13482798a6fa6728012d3e11e6cf0bfc42a6f6..f8f6c157f2313d6ccd6bb00412163b30e9e2a502 100644 (file)
@@ -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 */