From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from jupiter.monnerat.net (jupiter.monnerat.net [46.226.111.226]) by sourceware.org (Postfix) with ESMTPS id 172D83852769 for ; Wed, 24 Aug 2022 15:26:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 172D83852769 Received: from [192.168.0.128] ([192.168.0.128]) by jupiter.monnerat.net (8.14.8/8.14.8) with ESMTP id 27OFQPd3015672 (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Aug 2022 17:26:31 +0200 DKIM-Filter: OpenDKIM Filter v2.10.3 jupiter.monnerat.net 27OFQPd3015672 Message-ID: <1f5cd3c2-9552-c75a-1add-e3ceebc63e3e@monnerat.net> Date: Wed, 24 Aug 2022 17:26:25 +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 , Patrick Monnerat via Gdb-patches References: <20220819174601.144876-1-patrick@monnerat.net> <874jy2dbf6.fsf@tromey.com> From: Patrick Monnerat In-Reply-To: <874jy2dbf6.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, JMQ_SPF_NEUTRAL, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Wed, 24 Aug 2022 15:26:34 -0000 On 8/23/22 21:09, Tom Tromey wrote: >>>>>> "Patrick" == Patrick Monnerat via Gdb-patches writes: > Thanks for the patch. > > Patrick> +#if defined(POLLRDHUP) > > Space before the '('. Sure: my bad ! > Patrick> void > Patrick> add_file_handler (int fd, handler_func *proc, gdb_client_data client_data, > Patrick> - std::string &&name, bool is_ui) > Patrick> + std::string &&name, bool is_ui, int mask) > Patrick> { > Patrick> + if (fd < 0 || (mask & (GDB_READABLE | GDB_WRITABLE | GDB_EXCEPTION)) == 0) > Patrick> + return; > > Is there ever a situation where this can happen and it is not a bug in > the caller? I am wondering if this ought to be an assert instead. Yes. In Insight, command input from stdin is disabled by setting main_ui->input_fd to -1. A later call to register_file_handler from async_enable_stdin causes add_file_handler to be called with fd = -1. Maybe I should add a comment for this. > > Patrick> +/* Tell add_file_handler what events we are interested in. */ > Patrick> + > Patrick> +#define GDB_READABLE (1<<1) > Patrick> +#define GDB_WRITABLE (1<<2) > Patrick> +#define GDB_EXCEPTION (1<<3) > > I tend to think it would be better to use enum_flags here. I thought so too and did try to use enum_flags! Unfortunately the same int field (file_handler::mask) stores either these bits in case of select use, or a poll mask as defined by the system when poll is used. We then have a type conflict: it can be resolved but is rather cumbersome (a simple cast would be awful). Your opinion? Thanks for the review. Patrick