From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 9GIpJUw8D2N2YDAAWB0awg (envelope-from ) for ; Wed, 31 Aug 2022 06:47:40 -0400 Received: by simark.ca (Postfix, from userid 112) id 8BB681E4A7; Wed, 31 Aug 2022 06:47:40 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=pXmGLEAZ; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_DYNAMIC, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 37D731E13B for ; Wed, 31 Aug 2022 06:47:40 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8FD0D38515C1 for ; Wed, 31 Aug 2022 10:47:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8FD0D38515C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1661942859; bh=wbA4TLx+ZCTKZn7hdf49BikEHSNLnAAmbeRlZ4SVny0=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=pXmGLEAZbaQxafVNWUv25Jyj36Uf1rJjsJ4NaWAFdi7Bd1B0vOX7r09HEtHEbtdFA Ek0IA8k7hi1ubQLLFkMon0DgRCpTj7WzesD1zmZ9KlOlhIYd1Kjzm+WJqYuGpQIGut CbydyWYf+q0gI4Xd0W3XlMnOM5MN+9t+JEHBZUpE= Received: from jupiter.monnerat.net (jupiter.monnerat.net [46.226.111.226]) by sourceware.org (Postfix) with ESMTPS id B33023858D39 for ; Wed, 31 Aug 2022 10:47:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B33023858D39 Received: from [192.168.0.128] ([192.168.0.128]) by jupiter.monnerat.net (8.14.8/8.14.8) with ESMTP id 27VAlAHp002670 (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256 verify=OK); Wed, 31 Aug 2022 12:47:16 +0200 DKIM-Filter: OpenDKIM Filter v2.10.3 jupiter.monnerat.net 27VAlAHp002670 Message-ID: <693da8b0-9f7d-2a62-8e99-7e64a8dc5593@monnerat.net> Date: Wed, 31 Aug 2022 12:47:10 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH] gdb: add a file event mask parameter to add_file_handler Content-Language: en-US To: Tom Tromey References: <20220819174601.144876-1-patrick@monnerat.net> <874jy2dbf6.fsf@tromey.com> <1f5cd3c2-9552-c75a-1add-e3ceebc63e3e@monnerat.net> <877d2xtuxh.fsf@tromey.com> <87a67lbpof.fsf@tromey.com> In-Reply-To: <87a67lbpof.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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: , From: Patrick Monnerat via Gdb-patches Reply-To: Patrick Monnerat Cc: Patrick Monnerat via Gdb-patches Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 8/30/22 19:34, Tom Tromey wrote: > Patrick> Yes. In Insight, command input from stdin is disabled by setting > Patrick> main_ui->input_fd to -1. A later call to register_file_handler from > Patrick> async_enable_stdin causes add_file_handler to be called with fd = > Patrick> -1. Maybe I should add a comment for this. > > Tom> I took this same approach in my DAP implementation, which is why I > Tom> changed gdb to always call the 'ui' methods to manipulate the event > Tom> handlers. In my patch I then change these methods to check for the -1 > Tom> case. > > Tom> I can submit this bit separately next week. > Tom> Or you can do it, it's trivial. > > What do you think of this? This is great! I applied your changes to Insight and dropped the fd<0 test in add_file_handler with total success. I'll soon submit version 2 of my patch with the fd<0 test removed, and an updated test for mask==0 (this case should call delete_file_handler). This would have to be pushed after your patch, of course! Thanks a lot. Patrick > Tom > > commit 73d104a6fc246f0cd7d42a4ed1c009304fb55327 > Author: Tom Tromey > Date: Tue Aug 30 11:30:13 2022 -0600 > > Let ui::input_fd be -1 > > This changes gdb so that, if ui::input_fd is set to -1, then it will > not be registered with the event loop. This is useful for the DAP > support code I wrote, but as it turns out to also be useful to > Insight, it seems best to check it in separately. > > diff --git a/gdb/event-top.c b/gdb/event-top.c > index 02b3786320f..4547d614522 100644 > --- a/gdb/event-top.c > +++ b/gdb/event-top.c > @@ -533,8 +533,9 @@ stdin_event_handler (int error, gdb_client_data client_data) > void > ui::register_file_handler () > { > - add_file_handler (input_fd, stdin_event_handler, this, > - string_printf ("ui-%d", num), true); > + if (input_fd != -1) > + add_file_handler (input_fd, stdin_event_handler, this, > + string_printf ("ui-%d", num), true); > } > > /* See top.h. */ > @@ -542,7 +543,8 @@ ui::register_file_handler () > void > ui::unregister_file_handler () > { > - delete_file_handler (input_fd); > + if (input_fd != -1) > + delete_file_handler (input_fd); > } > > /* Re-enable stdin after the end of an execution command in > diff --git a/gdb/top.h b/gdb/top.h > index 5c1db84b2ce..9ea07262c39 100644 > --- a/gdb/top.h > +++ b/gdb/top.h > @@ -118,7 +118,8 @@ struct ui > FILE *errstream; > > /* The file descriptor for the input stream, so that we can register > - it with the event loop. */ > + it with the event loop. This can be set to -1 to prevent this > + registration. */ > int input_fd; > > /* Whether ISATTY returns true on input_fd. Cached here because