From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH v2 06/12] Introduce and use flush_streams
Date: Sat, 14 Mar 2020 12:51:52 -0600 [thread overview]
Message-ID: <20200314185158.7816-7-tom@tromey.com> (raw)
In-Reply-To: <20200314185158.7816-1-tom@tromey.com>
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-03-14 Tom Tromey <tom@tromey.com>
* utils.c (flush_streams): New function.
* event-loop.c (gdb_wait_for_event): Call flush_streams.
gdbsupport/ChangeLog
2020-03-14 Tom Tromey <tom@tromey.com>
* errors.h (flush_streams): Declare.
---
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/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 0b470120a22..f9cde46ad8d 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/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 */
--
2.17.2
next prev parent reply other threads:[~2020-03-14 18:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-14 18:51 [PATCH v2 00/12] Merge event loop implementations Tom Tromey
2020-03-14 18:51 ` [PATCH v2 01/12] Move start_event_loop out of event-loop.c Tom Tromey
2020-03-14 18:51 ` [PATCH v2 02/12] Move event-loop configury to common.m4 Tom Tromey
2020-03-14 18:51 ` [PATCH v2 03/12] Move gdb_select.h to gdbsupport/ Tom Tromey
2020-03-14 18:51 ` [PATCH v2 04/12] Include <chrono> in event-loop.c Tom Tromey
2020-03-14 18:51 ` [PATCH v2 05/12] Use warning in event-loop Tom Tromey
2020-03-14 18:51 ` Tom Tromey [this message]
2020-03-14 18:51 ` [PATCH v2 07/12] Introduce async-event.[ch] Tom Tromey
2020-03-14 18:51 ` [PATCH v2 08/12] Move event-loop.[ch] to gdbsupport/ Tom Tromey
2020-03-14 18:51 ` [PATCH v2 09/12] Implement event-loop glue for gdbserver Tom Tromey
2020-03-14 18:51 ` [PATCH v2 10/12] Switch gdbserver to gdbsupport event loop Tom Tromey
2020-03-14 18:51 ` [PATCH v2 11/12] Move gdb_notifier comment Tom Tromey
2020-03-14 18:51 ` [PATCH v2 12/12] Remove gdb_fildes_t Tom Tromey
2020-04-13 21:08 ` [PATCH v2 00/12] Merge event loop implementations Tom Tromey
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=20200314185158.7816-7-tom@tromey.com \
--to=tom@tromey.com \
--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).