public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Unbuffer stdout and stderr on windows
@ 2013-07-22  3:07 Yao Qi
  2013-07-22 15:41 ` Eli Zaretskii
  0 siblings, 1 reply; 44+ messages in thread
From: Yao Qi @ 2013-07-22  3:07 UTC (permalink / raw)
  To: gdb-patches

Hi,
This patch is to disable the buffering on windows host, because the
error message and gdb prompt come out in different orders, which
causes a lot of test fails.

We call setvbuf this place, because it is a place "before any other
operation is performed".  See the doc below:

  "The setvbuf() function may be used after the stream pointed to by
stream is associated with an open file but before any other operation
(other than an unsuccessful call to setvbuf()) is performed on the
stream."

It is not the first time this patch show up here.  Daniel posted it
http://sourceware.org/ml/gdb-patches/2009-06/msg00433.html and Joel
preferred it as the exact same piece of code is in their tree as well
http://sourceware.org/ml/gdb-patches/2009-06/msg00434.html
Eli wanted to check this patch didn't interfere with Emacs 23 GDB
interface on Windows, which is probably the last question to this
patch.  The discussion stopped there.  I build native mingw32 gdb
with buffering disabled, and use it with Emacs 24.3 in Windows
cmd.exe.  Emacs+GDB behave correctly.

Is it OK?

gdb:

2013-07-22  Joseph Myers  <joseph@codesourcery.com>

	* main.c (captured_main): Set stdout and stderr unbuffered on
	Windows.
---
 gdb/main.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/gdb/main.c b/gdb/main.c
index 440094e..7529dc5 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -375,6 +375,13 @@ captured_main (void *data)
   saved_command_line[0] = '\0';
   instream = stdin;
 
+#ifdef _WIN32
+  /* A Cygwin ssh session may not look like a terminal to the Windows
+     runtime; ensure unbuffered output.  */
+  setvbuf (stdout, NULL, _IONBF, BUFSIZ);
+  setvbuf (stderr, NULL, _IONBF, BUFSIZ);
+#endif
+
   gdb_stdout = stdio_fileopen (stdout);
   gdb_stderr = stdio_fileopen (stderr);
   gdb_stdlog = gdb_stderr;	/* for moment */
-- 
1.7.7.6

^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2013-08-28 12:25 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-22  3:07 [PATCH] Unbuffer stdout and stderr on windows Yao Qi
2013-07-22 15:41 ` Eli Zaretskii
2013-07-23  6:35   ` Yao Qi
2013-07-23 17:52     ` Eli Zaretskii
2013-07-29 19:26       ` Christopher Faylor
2013-07-29 19:30         ` Eli Zaretskii
2013-07-29 19:51           ` Pedro Alves
2013-07-31  3:40             ` Christopher Faylor
2013-08-12 21:11               ` Joel Brobecker
2013-08-13 17:28                 ` Christopher Faylor
2013-08-13 18:08                 ` Eli Zaretskii
2013-08-14  0:05                   ` Joel Brobecker
2013-08-15 17:36                   ` Christopher Faylor
2013-08-15 17:44                     ` Eli Zaretskii
2013-08-15 17:59                       ` Christopher Faylor
2013-08-15 18:44                         ` Eli Zaretskii
2013-08-16 11:46                         ` Pedro Alves
2013-08-16 12:34                           ` Yao Qi
2013-08-16 13:20                             ` Eli Zaretskii
2013-08-16 13:37                             ` Pedro Alves
2013-08-16 14:03                               ` Eli Zaretskii
2013-08-16 14:21                                 ` Pedro Alves
2013-08-16 14:57                                   ` Eli Zaretskii
2013-08-16 15:10                                     ` Pedro Alves
2013-08-16 15:24                                       ` Pedro Alves
2013-08-16 15:43                                         ` Eli Zaretskii
2013-08-16 16:41                                           ` Christopher Faylor
2013-08-16 15:41                                       ` Eli Zaretskii
2013-08-22  6:14                                       ` Yao Qi
2013-08-22 14:18                                         ` Joel Brobecker
2013-08-23  2:20                                           ` Yao Qi
2013-08-23 13:38                                             ` Joel Brobecker
2013-08-27 20:39                                             ` Pedro Alves
2013-08-28  7:23                                               ` Yao Qi
2013-08-28  9:39                                                 ` Pedro Alves
2013-08-28 12:25                                                   ` Yao Qi
2013-08-16 13:17                           ` Eli Zaretskii
2013-08-16 13:30                             ` Pedro Alves
2013-08-16 13:42                               ` Eli Zaretskii
2013-08-16 14:13                                 ` Pedro Alves
2013-08-16 14:44                                   ` Eli Zaretskii
2013-08-16 15:05                                     ` Pedro Alves
2013-08-16 15:13                                       ` Eli Zaretskii
2013-07-29 19:30         ` Christopher Faylor

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).