From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16459 invoked by alias); 25 Jul 2013 05:10:20 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 16418 invoked by uid 89); 25 Jul 2013 05:10:20 -0000 X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_50,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RDNS_NONE,TW_TV,TW_VB autolearn=no version=3.3.1 Received: from Unknown (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 25 Jul 2013 05:10:19 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1V2DoZ-000386-OF from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Wed, 24 Jul 2013 22:10:11 -0700 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 24 Jul 2013 22:10:11 -0700 Received: from qiyao.dyndns.org.dyndns.org (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.2.247.3; Wed, 24 Jul 2013 22:10:10 -0700 From: Yao Qi To: Subject: [PATCH 2/3] Unbuffer stdout and stderr on windows Date: Thu, 25 Jul 2013 05:10:00 -0000 Message-ID: <1374728963-25187-3-git-send-email-yao@codesourcery.com> In-Reply-To: <1374728963-25187-1-git-send-email-yao@codesourcery.com> References: <1374728963-25187-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2013-07/txt/msg00593.txt.bz2 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 * 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