From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by sourceware.org (Postfix) with ESMTPS id CB930385841A for ; Tue, 30 Aug 2022 17:34:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CB930385841A Received: by mail-io1-xd2d.google.com with SMTP id c4so9847790iof.3 for ; Tue, 30 Aug 2022 10:34:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc; bh=uOsovUzTf9lY1WWChzB489qM0D/3dMIR7z0Vra73tUc=; b=v8CP3iq+w9s+9ZSrRYSFUIVg72NHoKKYCq8DJa9HaCm9FXoiwFNFPzCzF/DDgQ4gTX cvj3Rq79KGoKBDjUt8HLodn2Ldu7VeXZWIplB7kTtpeH+GOD8Gr22JGONZCygHs3Fku6 30CsviO65jWI4AJAQTLCpYA7pR3NxZWcQ4Crt6449vhIvQCyWdCNGj5ZXdcJ113Y653N p/CI78lTQC5YrooyKCkumxUSBwMysx8Rjt8eza0AVX/feVQ6NDz6I6pnoqTPDbI8l4zK 9pzUm9USFRaHRQ/YDpa6ZxYFYNvWuvqtBWRchfABCIKX4EuD29sf9jmsU9NZ869Fv7mx dv0Q== X-Gm-Message-State: ACgBeo3ibVwC+qBXe7O3pQNJSo8oCgiT1caVvhNA9t+8TX0H//tyO3to 0d3YFRHKDDIva7GF5srlgfAzag== X-Google-Smtp-Source: AA6agR49WEs090FwW8FRC+jVQ3l2m8aDweBTL2oQPm4idjl2WnnKDdNTchwQ71rnYMg5ov9eogqgfw== X-Received: by 2002:a05:6638:140e:b0:343:4ed7:c0f9 with SMTP id k14-20020a056638140e00b003434ed7c0f9mr12937151jad.135.1661880897949; Tue, 30 Aug 2022 10:34:57 -0700 (PDT) Received: from murgatroyd (97-122-83-53.hlrn.qwest.net. [97.122.83.53]) by smtp.gmail.com with ESMTPSA id g3-20020a02b703000000b0034a56f2f120sm1457030jam.155.2022.08.30.10.34.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 10:34:57 -0700 (PDT) From: Tom Tromey To: Tom Tromey Cc: Patrick Monnerat , Patrick Monnerat via Gdb-patches Subject: Re: [PATCH] gdb: add a file event mask parameter to add_file_handler References: <20220819174601.144876-1-patrick@monnerat.net> <874jy2dbf6.fsf@tromey.com> <1f5cd3c2-9552-c75a-1add-e3ceebc63e3e@monnerat.net> <877d2xtuxh.fsf@tromey.com> X-Attribution: Tom Date: Tue, 30 Aug 2022 11:34:56 -0600 In-Reply-To: <877d2xtuxh.fsf@tromey.com> (Tom Tromey's message of "Wed, 24 Aug 2022 11:26:02 -0600") Message-ID: <87a67lbpof.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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: Tue, 30 Aug 2022 17:35:01 -0000 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? 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