From: Patrick Monnerat via Gdb-patches <gdb-patches@sourceware.org>
To: Tom Tromey <tom@tromey.com>,
Patrick Monnerat via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] gdb: add a file event mask parameter to add_file_handler
Date: Wed, 24 Aug 2022 17:26:25 +0200 [thread overview]
Message-ID: <1f5cd3c2-9552-c75a-1add-e3ceebc63e3e@monnerat.net> (raw)
In-Reply-To: <874jy2dbf6.fsf@tromey.com>
On 8/23/22 21:09, Tom Tromey wrote:
>>>>>> "Patrick" == Patrick Monnerat via Gdb-patches <gdb-patches@sourceware.org> 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
next prev parent reply other threads:[~2022-08-24 15:26 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 [this message]
2022-08-24 17:26 ` Tom Tromey
2022-08-30 17:34 ` Tom Tromey via Gdb-patches
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=1f5cd3c2-9552-c75a-1add-e3ceebc63e3e@monnerat.net \
--to=gdb-patches@sourceware.org \
--cc=patrick@monnerat.net \
--cc=tom@tromey.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