Make out and error streams be per UI

stderr_fileopen () references stderr directly, which doesn't work when
we have a separate UI with its own stderr-like stream.  So this also
adds a "errstream" to "struct ui", and plumbs stderr_fileopen to take
a stream parameter.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

	* event-top.c (gdb_setup_readline): Pass the UI's outstream and
	errstream to stdout_fileopen and stderr_fileopen.
	* exceptions.c: Include top.h.
	(print_flush): Open the current UI's outstream file descriptor,
	instead of hardcoding file descriptor 1.
	* main.c (captured_main): Save the main UI's out and error
	streams.  Adjust stderr_fileopen call.
	* top.h (struct ui) <outstream, errstream>: New fields.
	* ui-file.c (stderr_fileopen): Add stream parameter.  Use it
	instead of stderr.
	* ui-file.h (stderr_fileopen): Add stream parameter and update
	comment.
This commit is contained in:
Pedro Alves 2016-06-21 01:11:47 +01:00
parent 41fd2b0f5d
commit 694ec099d2
7 changed files with 33 additions and 8 deletions

View file

@ -681,9 +681,9 @@ stderr_file_fputs (const char *linebuffer, struct ui_file *file)
#endif
struct ui_file *
stderr_fileopen (void)
stderr_fileopen (FILE *stream)
{
struct ui_file *ui_file = stdio_fileopen (stderr);
struct ui_file *ui_file = stdio_fileopen (stream);
#ifdef __MINGW32__
/* There is no real line-buffering on Windows, see