forked from Imagelibrary/binutils-gdb
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:
@@ -1,3 +1,18 @@
|
|||||||
|
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.
|
||||||
|
|
||||||
2016-06-21 Pedro Alves <palves@redhat.com>
|
2016-06-21 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
* event-top.c (input_fd): Delete.
|
* event-top.c (input_fd): Delete.
|
||||||
|
|||||||
@@ -1237,8 +1237,8 @@ gdb_setup_readline (void)
|
|||||||
mess it up here. The sync stuff should really go away over
|
mess it up here. The sync stuff should really go away over
|
||||||
time. */
|
time. */
|
||||||
if (!batch_silent)
|
if (!batch_silent)
|
||||||
gdb_stdout = stdio_fileopen (stdout);
|
gdb_stdout = stdio_fileopen (ui->outstream);
|
||||||
gdb_stderr = stderr_fileopen ();
|
gdb_stderr = stderr_fileopen (ui->errstream);
|
||||||
gdb_stdlog = gdb_stderr; /* for moment */
|
gdb_stdlog = gdb_stderr; /* for moment */
|
||||||
gdb_stdtarg = gdb_stderr; /* for moment */
|
gdb_stdtarg = gdb_stderr; /* for moment */
|
||||||
gdb_stdtargerr = gdb_stderr; /* for moment */
|
gdb_stdtargerr = gdb_stderr; /* for moment */
|
||||||
|
|||||||
@@ -26,10 +26,12 @@
|
|||||||
#include "ui-out.h"
|
#include "ui-out.h"
|
||||||
#include "serial.h"
|
#include "serial.h"
|
||||||
#include "gdbthread.h"
|
#include "gdbthread.h"
|
||||||
|
#include "top.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_flush (void)
|
print_flush (void)
|
||||||
{
|
{
|
||||||
|
struct ui *ui = current_ui;
|
||||||
struct serial *gdb_stdout_serial;
|
struct serial *gdb_stdout_serial;
|
||||||
struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
|
struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
|
||||||
|
|
||||||
@@ -56,7 +58,7 @@ print_flush (void)
|
|||||||
gdb_flush (gdb_stderr);
|
gdb_flush (gdb_stderr);
|
||||||
|
|
||||||
/* 3. The system-level buffer. */
|
/* 3. The system-level buffer. */
|
||||||
gdb_stdout_serial = serial_fdopen (1);
|
gdb_stdout_serial = serial_fdopen (fileno (ui->outstream));
|
||||||
if (gdb_stdout_serial)
|
if (gdb_stdout_serial)
|
||||||
{
|
{
|
||||||
serial_drain_output (gdb_stdout_serial);
|
serial_drain_output (gdb_stdout_serial);
|
||||||
|
|||||||
@@ -507,7 +507,11 @@ captured_main (void *data)
|
|||||||
ndir = 0;
|
ndir = 0;
|
||||||
|
|
||||||
saved_command_line = (char *) xstrdup ("");
|
saved_command_line = (char *) xstrdup ("");
|
||||||
|
|
||||||
ui->instream = stdin;
|
ui->instream = stdin;
|
||||||
|
ui->outstream = stdout;
|
||||||
|
ui->errstream = stderr;
|
||||||
|
|
||||||
ui->input_fd = fileno (stdin);
|
ui->input_fd = fileno (stdin);
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
@@ -517,7 +521,7 @@ captured_main (void *data)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
gdb_stdout = stdio_fileopen (stdout);
|
gdb_stdout = stdio_fileopen (stdout);
|
||||||
gdb_stderr = stderr_fileopen ();
|
gdb_stderr = stderr_fileopen (stderr);
|
||||||
|
|
||||||
gdb_stdlog = gdb_stderr; /* for moment */
|
gdb_stdlog = gdb_stderr; /* for moment */
|
||||||
gdb_stdtarg = gdb_stderr; /* for moment */
|
gdb_stdtarg = gdb_stderr; /* for moment */
|
||||||
|
|||||||
@@ -73,6 +73,10 @@ struct ui
|
|||||||
Set to NULL if we are executing a user-defined command or
|
Set to NULL if we are executing a user-defined command or
|
||||||
interacting via a GUI. */
|
interacting via a GUI. */
|
||||||
FILE *instream;
|
FILE *instream;
|
||||||
|
/* Standard output stream. */
|
||||||
|
FILE *outstream;
|
||||||
|
/* Standard error stream. */
|
||||||
|
FILE *errstream;
|
||||||
|
|
||||||
/* The file descriptor for the input stream, so that we can register
|
/* The file descriptor for the input stream, so that we can register
|
||||||
it with the event loop. */
|
it with the event loop. */
|
||||||
|
|||||||
@@ -681,9 +681,9 @@ stderr_file_fputs (const char *linebuffer, struct ui_file *file)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct ui_file *
|
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__
|
#ifdef __MINGW32__
|
||||||
/* There is no real line-buffering on Windows, see
|
/* There is no real line-buffering on Windows, see
|
||||||
|
|||||||
@@ -135,8 +135,8 @@ extern struct ui_file *mem_fileopen (void);
|
|||||||
/* Open/create a STDIO based UI_FILE using the already open FILE. */
|
/* Open/create a STDIO based UI_FILE using the already open FILE. */
|
||||||
extern struct ui_file *stdio_fileopen (FILE *file);
|
extern struct ui_file *stdio_fileopen (FILE *file);
|
||||||
|
|
||||||
/* Create a ui_file from stderr. */
|
/* Likewise, for stderr-like streams. */
|
||||||
extern struct ui_file *stderr_fileopen (void);
|
extern struct ui_file *stderr_fileopen (FILE *file);
|
||||||
|
|
||||||
|
|
||||||
/* Open NAME returning an STDIO based UI_FILE. */
|
/* Open NAME returning an STDIO based UI_FILE. */
|
||||||
|
|||||||
Reference in New Issue
Block a user