gdb/
* event-top.c (gdb_setup_readline): Call stderr_fileopen instead of stdio_fileopen. * main.c (captured_main) [__MINGW32__]: Set stderr unbuffered. .Call stderr_fileopen instead of stdio_fileopen. * ui-file.c [__MINGW32__] (stderr_file_write): New function. [__MINGW32__] (stderr_file_fputs): New function. (stderr_fileopen): New function. * ui-file.h (stderr_fileopen): Declare.
This commit is contained in:
parent
7e10503172
commit
ffa4ac956c
5 changed files with 79 additions and 2 deletions
|
@ -1,3 +1,15 @@
|
|||
2013-08-28 Yao Qi <yao@codesourcery.com>
|
||||
Pedro Alves <palves@redhat.com>
|
||||
|
||||
* event-top.c (gdb_setup_readline): Call stderr_fileopen
|
||||
instead of stdio_fileopen.
|
||||
* main.c (captured_main) [__MINGW32__]: Set stderr unbuffered.
|
||||
.Call stderr_fileopen instead of stdio_fileopen.
|
||||
* ui-file.c [__MINGW32__] (stderr_file_write): New function.
|
||||
[__MINGW32__] (stderr_file_fputs): New function.
|
||||
(stderr_fileopen): New function.
|
||||
* ui-file.h (stderr_fileopen): Declare.
|
||||
|
||||
2013-08-27 Doug Evans <dje@google.com>
|
||||
|
||||
* dwarf2read.c (struct dwarf2_cu): Tweak comment.
|
||||
|
|
|
@ -955,7 +955,7 @@ gdb_setup_readline (void)
|
|||
time. */
|
||||
if (!batch_silent)
|
||||
gdb_stdout = stdio_fileopen (stdout);
|
||||
gdb_stderr = stdio_fileopen (stderr);
|
||||
gdb_stderr = stderr_fileopen ();
|
||||
gdb_stdlog = gdb_stderr; /* for moment */
|
||||
gdb_stdtarg = gdb_stderr; /* for moment */
|
||||
gdb_stdtargerr = gdb_stderr; /* for moment */
|
||||
|
|
|
@ -375,8 +375,15 @@ captured_main (void *data)
|
|||
saved_command_line[0] = '\0';
|
||||
instream = stdin;
|
||||
|
||||
#ifdef __MINGW32__
|
||||
/* Ensure stderr is unbuffered. A Cygwin pty or pipe is implemented
|
||||
as a Windows pipe, and Windows buffers on pipes. */
|
||||
setvbuf (stderr, NULL, _IONBF, BUFSIZ);
|
||||
#endif
|
||||
|
||||
gdb_stdout = stdio_fileopen (stdout);
|
||||
gdb_stderr = stdio_fileopen (stderr);
|
||||
gdb_stderr = stderr_fileopen ();
|
||||
|
||||
gdb_stdlog = gdb_stderr; /* for moment */
|
||||
gdb_stdtarg = gdb_stderr; /* for moment */
|
||||
gdb_stdin = stdio_fileopen (stdin);
|
||||
|
|
|
@ -654,6 +654,60 @@ stdio_file_fseek (struct ui_file *file, long offset, int whence)
|
|||
return fseek (stdio->file, offset, whence);
|
||||
}
|
||||
|
||||
#ifdef __MINGW32__
|
||||
/* This is the implementation of ui_file method to_write for stderr.
|
||||
gdb_stdout is flushed before writing to gdb_stderr. */
|
||||
|
||||
static void
|
||||
stderr_file_write (struct ui_file *file, const char *buf, long length_buf)
|
||||
{
|
||||
gdb_flush (gdb_stdout);
|
||||
stdio_file_write (file, buf, length_buf);
|
||||
}
|
||||
|
||||
/* This is the implementation of ui_file method to_fputs for stderr.
|
||||
gdb_stdout is flushed before writing to gdb_stderr. */
|
||||
|
||||
static void
|
||||
stderr_file_fputs (const char *linebuffer, struct ui_file *file)
|
||||
{
|
||||
gdb_flush (gdb_stdout);
|
||||
stdio_file_fputs (linebuffer, file);
|
||||
}
|
||||
#endif
|
||||
|
||||
struct ui_file *
|
||||
stderr_fileopen (void)
|
||||
{
|
||||
struct ui_file *ui_file = stdio_fileopen (stderr);
|
||||
|
||||
#ifdef __MINGW32__
|
||||
/* There is no real line-buffering on Windows, see
|
||||
http://msdn.microsoft.com/en-us/library/86cebhfs%28v=vs.71%29.aspx
|
||||
so the stdout is either fully-buffered or non-buffered. We can't
|
||||
make stdout non-buffered, because of two concerns,
|
||||
1. non-buffering hurts performance,
|
||||
2. non-buffering may change GDB's behavior when it is interacting
|
||||
with front-end, such as Emacs.
|
||||
|
||||
We decided to leave stdout as fully buffered, but flush it first
|
||||
when something is written to stderr. */
|
||||
|
||||
/* Method 'to_write_async_safe' is not overwritten, because there's
|
||||
no way to flush a stream in an async-safe manner. Fortunately,
|
||||
it doesn't really matter, because:
|
||||
- that method is only used for printing internal debug output
|
||||
from signal handlers.
|
||||
- Windows hosts don't have a concept of async-safeness. Signal
|
||||
handlers run in a separate thread, so they can call
|
||||
the regular non-async-safe output routines freely. */
|
||||
set_ui_file_write (ui_file, stderr_file_write);
|
||||
set_ui_file_fputs (ui_file, stderr_file_fputs);
|
||||
#endif
|
||||
|
||||
return ui_file;
|
||||
}
|
||||
|
||||
/* Like fdopen(). Create a ui_file from a previously opened FILE. */
|
||||
|
||||
struct ui_file *
|
||||
|
|
|
@ -129,6 +129,10 @@ extern struct ui_file *mem_fileopen (void);
|
|||
/* Open/create a STDIO based UI_FILE using the already open FILE. */
|
||||
extern struct ui_file *stdio_fileopen (FILE *file);
|
||||
|
||||
/* Create a ui_file from stderr. */
|
||||
extern struct ui_file *stderr_fileopen (void);
|
||||
|
||||
|
||||
/* Open NAME returning an STDIO based UI_FILE. */
|
||||
extern struct ui_file *gdb_fopen (const char *name, const char *mode);
|
||||
|
||||
|
|
Loading…
Reference in a new issue