From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30544 invoked by alias); 22 Aug 2013 14:18:00 -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 30520 invoked by uid 89); 22 Aug 2013 14:18:00 -0000 X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_HOSTKARMA_NO autolearn=ham version=3.3.2 Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 22 Aug 2013 14:17:59 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id DF6951167FD; Thu, 22 Aug 2013 10:18:03 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 2SYAAbGtyigY; Thu, 22 Aug 2013 10:18:03 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id A05261167ED; Thu, 22 Aug 2013 10:18:03 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 68F4AC3DA9; Thu, 22 Aug 2013 07:17:56 -0700 (PDT) Date: Thu, 22 Aug 2013 14:18:00 -0000 From: Joel Brobecker To: Yao Qi Cc: Pedro Alves , Eli Zaretskii , gdb-patches@sourceware.org Subject: Re: [PATCH] Unbuffer stdout and stderr on windows Message-ID: <20130822141756.GB5221@adacore.com> References: <83eh9uonlg.fsf@gnu.org> <20130815175940.GD6955@ednor.casa.cgf.cx> <520E1109.7000304@redhat.com> <520E1C34.2000907@codesourcery.com> <520E2B13.8020706@redhat.com> <83r4dtn35q.fsf@gnu.org> <520E357E.6080803@redhat.com> <83mwohn0nj.fsf@gnu.org> <520E40CD.7080604@redhat.com> <5215AC28.3030506@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5215AC28.3030506@codesourcery.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2013-08/txt/msg00640.txt.bz2 > This patch below generally implements what we discussed here... Thanks, Yao. > 2013-08-22 Yao Qi > > * main.c (captured_main) [__MINGW32__]: Set stderr unbuffered. > and all update_stderr_ui_file. > * ui-file.c (stderr_file_write): New function. > (stderr_file_fputs): New function. > (update_stderr_ui_file): New function. > * ui-file.h (update_stderr_ui_file): Declare. Just some thoughts I had while skimming through your patch... > +#ifdef __MINGW32__ > + /* Ensure stderr is unbuffered. */ > + setvbuf (stderr, NULL, _IONBF, BUFSIZ); > +#endif Can you also document the reason why you make stderr unbuffered here? If we capture most of what was discussed, it'll help anyone trying to understand the code later on... > gdb_stdout = stdio_fileopen (stdout); > gdb_stderr = 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 decide to leave stdout as fully buffered, but flush it first decided > + when something is written to stderr. */ > + update_stderr_ui_file (gdb_stderr); > +#endif Just a question: Would it be possible to emulate line buffering as well? In my experience, the size of the buffer is fairly big, and causes the output to appear only at fairly large intervals, and in fairly large blobs. > + > gdb_stdlog = gdb_stderr; /* for moment */ > gdb_stdtarg = gdb_stderr; /* for moment */ > gdb_stdin = stdio_fileopen (stdin); > diff --git a/gdb/ui-file.c b/gdb/ui-file.c > index cf5a86d..649d892 100644 > --- a/gdb/ui-file.c > +++ b/gdb/ui-file.c > @@ -654,6 +654,32 @@ stdio_file_fseek (struct ui_file *file, long offset, int whence) > return fseek (stdio->file, offset, whence); > } > > +static void > +stderr_file_write (struct ui_file *file, const char *buf, long length_buf) Please, document every new function, no matter how trivial. That way, there is no discussion about whether the function should be documented or not. Thank you, -- Joel