From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 2/3] Unbuffer stdout and stderr on windows
Date: Thu, 25 Jul 2013 05:10:00 -0000 [thread overview]
Message-ID: <1374728963-25187-3-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1374728963-25187-1-git-send-email-yao@codesourcery.com>
This is the V2. We have some changes in V2:
- Replace '_WIN32' with '__MINGW32__'.
- Check flag 'cygwin_tty'.
- Postpone setting stdout/stderr until the option is parsed.
---------------------------------------------------------------
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.
gdb:
2013-07-25 Joseph Myers <joseph@codesourcery.com>
* main.c (captured_main) [__MINGW32__]: Set stdout and stderr
unbuffered on Windows.
---
gdb/main.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/gdb/main.c b/gdb/main.c
index 029f365..4777286 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -750,6 +750,18 @@ captured_main (void *data)
quiet = 1;
}
+#ifdef __MINGW32__
+ if (cygwin_tty)
+ {
+ /* A Cygwin session may not look like a terminal to the Windows
+ runtime; ensure unbuffered output. Note that setvbuf may be
+ used after the file is opened but before any other operation
+ is performed. */
+ setvbuf (stdout, NULL, _IONBF, BUFSIZ);
+ setvbuf (stderr, NULL, _IONBF, BUFSIZ);
+ }
+#endif
+
/* Initialize all files. Give the interpreter a chance to take
control of the console via the deprecated_init_ui_hook (). */
gdb_init (gdb_program_name);
--
1.7.7.6
next prev parent reply other threads:[~2013-07-25 5:10 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-25 5:10 [PATCH 0/3] Test mingw32 GDB in cygwin Yao Qi
2013-07-25 5:10 ` Yao Qi [this message]
2013-07-25 5:10 ` [PATCH 3/3] native mingw32 gdb, eol format Yao Qi
2013-07-25 5:10 ` [PATCH 1/3] New option --cygwin-tty Yao Qi
2013-07-25 7:34 ` Corinna Vinschen
2013-07-25 7:37 ` Pierre Muller
2013-07-25 7:55 ` Yao Qi
2013-07-25 8:18 ` Corinna Vinschen
2013-07-25 8:26 ` Corinna Vinschen
2013-07-25 9:05 ` Yao Qi
2013-07-25 10:20 ` Corinna Vinschen
2013-07-25 12:08 ` Yao Qi
2013-07-25 15:21 ` Corinna Vinschen
2013-07-26 19:40 ` Doug Evans
2013-07-25 7:31 ` [PATCH 0/3] Test mingw32 GDB in cygwin Pierre Muller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1374728963-25187-3-git-send-email-yao@codesourcery.com \
--to=yao@codesourcery.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox