From: Tom Tromey via Gdb-patches <gdb-patches@sourceware.org>
To: Tom Tromey <tromey@adacore.com>
Cc: Patrick Monnerat via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] gdb: add a file event mask parameter to add_file_handler
Date: Tue, 30 Aug 2022 11:34:56 -0600 [thread overview]
Message-ID: <87a67lbpof.fsf@tromey.com> (raw)
In-Reply-To: <877d2xtuxh.fsf@tromey.com> (Tom Tromey's message of "Wed, 24 Aug 2022 11:26:02 -0600")
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 <tromey@adacore.com>
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
next prev parent reply other threads:[~2022-08-30 17:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-19 17:46 Patrick Monnerat via Gdb-patches
2022-08-23 19:09 ` Tom Tromey
2022-08-24 15:26 ` Patrick Monnerat via Gdb-patches
2022-08-24 17:26 ` Tom Tromey
2022-08-30 17:34 ` Tom Tromey via Gdb-patches [this message]
2022-08-31 10:47 ` Patrick Monnerat via Gdb-patches
2022-08-31 16:51 ` Tom Tromey via Gdb-patches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a67lbpof.fsf@tromey.com \
--to=gdb-patches@sourceware.org \
--cc=tromey@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox