From patchwork Thu Mar 7 06:06:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 31761 Received: (qmail 59326 invoked by alias); 7 Mar 2019 06:06:10 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 59314 invoked by uid 89); 7 Mar 2019 06:06:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=screen, buffered, stdio, inheriting X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 07 Mar 2019 06:06:08 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 797A05601B; Thu, 7 Mar 2019 01:06:07 -0500 (EST) 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 2Dk9a-xq2HTy; Thu, 7 Mar 2019 01:06:07 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 07FCF56019; Thu, 7 Mar 2019 01:06:07 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 5935386B57; Thu, 7 Mar 2019 10:06:01 +0400 (+04) Date: Thu, 7 Mar 2019 10:06:01 +0400 From: Joel Brobecker To: Tom Tromey Cc: Pedro Alves , gdb-patches@sourceware.org Subject: Re: [PATCH] Remove excess calls to gdb_flush Message-ID: <20190307060601.GB26408@adacore.com> References: <20190219205426.4168-1-tromey@adacore.com> <63a71432-2cd2-cde9-0f27-0115f795334c@redhat.com> <87k1hdtdf0.fsf@tromey.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87k1hdtdf0.fsf@tromey.com> User-Agent: Mutt/1.9.4 (2018-02-28) > >>>>> "Pedro" == Pedro Alves writes: > > Pedro> On 02/19/2019 08:54 PM, Tom Tromey wrote: > >> > >> my belief being that gdb's standard output > >> streams are line buffered (by inheriting the behavior from stdio) > > Pedro> That's only true if gdb is connected to a pty. If gdb is started with > Pedro> a pipe or regular file for stdout/stderr instead, then it won't be. I > Pedro> guess we could fix that with a setvbuf call at startup though. > > I'll take a look. I think the scenario being discussed here is slightly different from what the diff below is for, but I thought I'd mention it, just in case. At AdaCore, we have the following local change: --- a/gdb/main.c +++ b/gdb/main.c @@ -527,6 +527,17 @@ captured_main_1 (struct captured_main_args *context) error (_("fatal error: libbfd ABI mismatch")); #ifdef __MINGW32__ + /* On Windows hosts, when built using MinGW, we have some problems + with the terminal when running the debugger either under a cygwin + environment, or when connected to a GUI: When the debugger prints + an error, the actual printing on screen of the error message is + delayed and only finally printed after the next GDB prompt. + We avoid this issue by turning off buffering of stdout and stderr. */ + setvbuf (stdout, NULL, _IONBF, 0); + setvbuf (stderr, NULL, _IONBF, 0); +#endif + +#ifdef __MINGW32__ /* On Windows, argv[0] is not necessarily set to absolute form when GDB is found along PATH, without which relocation doesn't work. */ gdb_program_name = windows_get_absolute_argv0 (argv[0]);