From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3761 invoked by alias); 1 Aug 2013 08:06:16 -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 3736 invoked by uid 89); 1 Aug 2013 08:06:16 -0000 X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_40,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RDNS_NONE 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, 01 Aug 2013 08:06:15 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1V4ntf-0005Dv-8c from Yao_Qi@mentor.com ; Thu, 01 Aug 2013 01:06:07 -0700 Received: from SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 1 Aug 2013 01:06:07 -0700 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-05.mgc.mentorg.com (147.34.97.43) with Microsoft SMTP Server id 14.2.247.3; Thu, 1 Aug 2013 01:06:06 -0700 Message-ID: <51FA16C6.6010006@codesourcery.com> Date: Thu, 01 Aug 2013 08:06:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Eli Zaretskii CC: Subject: Re: [PATCH 2/3] Unbuffer stdout and stderr in cygwin References: <1375087546-22591-1-git-send-email-yao@codesourcery.com> <1375087546-22591-3-git-send-email-yao@codesourcery.com> <83siyxxtif.fsf@gnu.org> In-Reply-To: <83siyxxtif.fsf@gnu.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-SW-Source: 2013-08/txt/msg00004.txt.bz2 On 07/29/2013 11:42 PM, Eli Zaretskii wrote: > I would suggest to call the function using_cygwin_pty or some such. > "is_in_cygwin" is IMO too ambiguous. > OK, fixed in patch 1/3. >> >+ setvbuf (stdout, NULL, _IONBF, BUFSIZ); >> >+ setvbuf (stderr, NULL, _IONBF, BUFSIZ); > How about using line buffering instead on both streams? Or at least > leave stdout line-buffered? Did you try that, and if so, did that > have the same problems that triggered these patches? I tried line-buffering for stdout, but get some regressions in python related testing, FAIL: gdb.python/py-explore-cc.exp: explore int_ptr_ref (timeout) FAIL: gdb.python/py-explore-cc.exp: explore b (timeout) FAIL: gdb.python/py-explore-cc.exp: explore B (timeout) FAIL: gdb.python/py-explore.exp: explore ss_ptr (timeout) FAIL: gdb.python/py-explore.exp: explore darray_ref (timeout) FAIL: gdb.python/py-explore.exp: explore su (timeout) FAIL: gdb.python/py-explore.exp: explore cs (timeout) FAIL: gdb.python/py-explore.exp: explore cu (timeout) however, I don't triage these fails yet. > > You see, the way your patch works, using GDB from a Cygwin shell > window will always do the above, even when not running the test > suite. Users might be unhappy that their standard output suddenly > becomes much less efficient. Yes, I get your point. GDB would be less efficient on output. How about this patch? still unbuffering stdout and stderr, due to these regression? -- Yao (齐尧) gdb: 2013-08-01 Joseph Myers Yao Qi * main.c (captured_main) [__MINGW32__]: Set stdout and stderr unbuffered if GDB is using Cygwin pty. --- gdb/main.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/gdb/main.c b/gdb/main.c index 677f587..3a2fee6 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -375,6 +375,18 @@ captured_main (void *data) saved_command_line[0] = '\0'; instream = stdin; +#ifdef __MINGW32__ + if (using_cygwin_pty ()) + { + /* A Cygwin session may not look like a terminal to the Windows + runtime; ensure stdout and stderr is unbuffered. 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 + gdb_stdout = stdio_fileopen (stdout); gdb_stderr = stdio_fileopen (stderr); gdb_stdlog = gdb_stderr; /* for moment */ -- 1.7.7.6