Skip to content

Commit

Permalink
Introduce and use flush_streams
Browse files Browse the repository at this point in the history
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  <[email protected]>

	* utils.c (flush_streams): New function.
	* event-loop.c (gdb_wait_for_event): Call flush_streams.

gdbsupport/ChangeLog
2020-04-13  Tom Tromey  <[email protected]>

	* errors.h (flush_streams): Declare.
  • Loading branch information
tromey committed Apr 13, 2020
1 parent 29f2bf4 commit c1cd316
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
5 changes: 5 additions & 0 deletions gdb/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2020-04-13 Tom Tromey <[email protected]>

* utils.c (flush_streams): New function.
* event-loop.c (gdb_wait_for_event): Call flush_streams.

2020-04-13 Tom Tromey <[email protected]>

* event-loop.c (handle_file_event): Use warning, not
Expand Down
3 changes: 1 addition & 2 deletions gdb/event-loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions gdb/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */

Expand Down
4 changes: 4 additions & 0 deletions gdbsupport/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2020-04-13 Tom Tromey <[email protected]>

* errors.h (flush_streams): Declare.

2020-04-13 Tom Tromey <[email protected]>

* gdb_select.h: Move from ../gdb/.
Expand Down
4 changes: 4 additions & 0 deletions gdbsupport/errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

0 comments on commit c1cd316

Please sign in to comment.