From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 4C2033857C6A for ; Tue, 18 Jan 2022 17:57:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4C2033857C6A Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 20IHvmQj031740 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 18 Jan 2022 12:57:52 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 20IHvmQj031740 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 3050F1EAA4; Tue, 18 Jan 2022 12:57:48 -0500 (EST) Message-ID: Date: Tue, 18 Jan 2022 12:57:47 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH] gdb: unbuffer all input streams when not using readline Content-Language: en-US To: Andrew Burgess Cc: gdb-patches@sourceware.org References: <20220117164051.1854133-1-aburgess@redhat.com> <20220118170913.GH622389@redhat.com> From: Simon Marchi In-Reply-To: <20220118170913.GH622389@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Tue, 18 Jan 2022 17:57:48 +0000 X-Spam-Status: No, score=-3033.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Jan 2022 17:57:56 -0000 >> How difficult would it be to just have different behaviors on Windows, >> >> opening the stream only once, vs Linux, opening three streams? > > I think it would be easy enough to implement new-ui differently for > unix vs for windows. > > But, if I've left you with the impression that this is a possible > solution, then I failed with my commit message. Even on Linux, when > we're not using new-ui at all, we currently can loose commands unless > we switch to unbuffered input. No, you did mention it, my bad. > Another option; maybe there's some ioctl that can be used to tell the > kernel that a newline at the start of a read request should be > considered a line break. However, if such an ioctl exits, I've failed > to find it. > > The final option that I considered is to place glibc into unbuffered > mode, and then do the buffering ourselves within gdb. This obviously > adds a load more complexity which is why I'd rather not do this. > > But, if we did do this, then at the end of > gdb_readline_no_editing_callback we could set the flag > call_stdin_event_handler_again_p, and things would "just work". Yes, I think that would make sense. Instead of using call_stdin_event_handler_again_p, I would use a event in the event loop (using create_async_event_handler) for that. That means we go back to the event loop, so it's fair for the other event sources, versus call_stdin_event_handler_again_p which is a tight loop. > I can take a look at gathering some performance figures for sure and > will update once I have some data, but this patch is fixing an > existing bug... Yeah, so I am in favor of merging this patch and then looking if re-enabling some buffering is desirable. The important thing is the test that you had, which will hopefully prevent introducing a similar bug. Simon