public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: John Baldwin <jhb@FreeBSD.org>
To: Pedro Alves <pedro@palves.net>, gdb-patches@sourceware.org
Subject: Re: [RFC PATCH 1/7] gdbsupport: Add an event-pipe class.
Date: Mon, 12 Jul 2021 12:07:11 -0400	[thread overview]
Message-ID: <b7727fa5-80f1-5f18-49c4-433ef3856701@FreeBSD.org> (raw)
In-Reply-To: <acd3df6a-6bae-c611-b2ad-1976eed30759@palves.net>

On 6/27/21 9:12 AM, Pedro Alves wrote:
> On 2021-06-07 6:09 p.m., John Baldwin wrote:
>> This pulls out the implementation of an event pipe used to implement
>> target async support in both linux-low.cc (gdbserver) and linux-nat.c
>> (gdb).
>>
> 
> Seems like a good idea, thanks.
> 
>> +  /* Create a new pipe.  */
>> +  bool open ();
>> +
>> +  /* Close the pipe.  */
>> +  void close ();
>> +
>> +  /* True if the event pipe has been initialized.  */
>> +  bool active () const { return fds[0] != -1; }
>> +
> 
> Did you consider "is_open" instead of "active"?  I think reading "active()" at the call
> sites can make one wonder whether "active" is a different state from being
> open, like e.g., the pipe is open but not registered in the event loop.

Hmmm, I hadn't considered is_open.  I think was just going off the names of the existing
macros in the Linux targets, but I prefer is_open and will switch to that.

>> diff --git a/gdbsupport/event-pipe.h b/gdbsupport/event-pipe.h
>> new file mode 100644
>> index 0000000000..1717ea6790
>> --- /dev/null
>> +++ b/gdbsupport/event-pipe.h
>> @@ -0,0 +1,55 @@
>> +/* Event pipe for GDB, the GNU debugger.
>> +
>> +   Copyright (C) 2021 Free Software Foundation, Inc.
>> +
>> +   This file is part of GDB.
>> +
>> +   This program is free software; you can redistribute it and/or modify
>> +   it under the terms of the GNU General Public License as published by
>> +   the Free Software Foundation; either version 3 of the License, or
>> +   (at your option) any later version.
>> +
>> +   This program is distributed in the hope that it will be useful,
>> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> +   GNU General Public License for more details.
>> +
>> +   You should have received a copy of the GNU General Public License
>> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
>> +
>> +#ifndef COMMON_EVENT_PIPE_H
>> +#define COMMON_EVENT_PIPE_H
>> +
>> +/* An event pipe used as a waitable file in the event loop in place of
>> +   some other event not associated with a file descriptor.  */
> 
> Note this comment can be a little bit unclear given we also have
> create_async_event_handler / mark_async_event_handler, for events not associated
> with a file descriptor.
> 
> We need to use a pipe iff we need to wake up the select/poll in the event loop
> from a signal handler, otherwise we can use the cheaper mark_async_event_handler
> from mainline code.
> 
> Maybe mention in the comment that this is used for implementing the well-known
> self-pipe trick?

Yeah, I wanted to find a way to mention that anyway, and these are good points.
Here is what I came up with:

/* An event pipe used as a waitable file in the event loop in place of
    some other event associated with a signal.  The handler for the
    signal marks the event pipe to force a wakeup in the event loop.
    This uses the well-known self-pipe trick.  */

-- 
John Baldwin

  reply	other threads:[~2021-07-12 16:07 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-07 17:09 [RFC PATCH 0/7] FreeBSD target async mode and related refactoring John Baldwin
2021-06-07 17:09 ` [RFC PATCH 1/7] gdbsupport: Add an event-pipe class John Baldwin
2021-06-25 21:37   ` Lancelot SIX
2021-06-27 16:12   ` Pedro Alves
2021-07-12 16:07     ` John Baldwin [this message]
2021-07-13 12:27       ` Pedro Alves
2021-06-07 17:09 ` [RFC PATCH 2/7] gdb linux-nat: Convert linux_nat_event_pipe to the event_pipe class John Baldwin
2021-06-27 16:12   ` Pedro Alves
2021-07-13 13:51     ` John Baldwin
2021-06-07 17:09 ` [RFC PATCH 3/7] gdbserver linux-low: Convert linux_event_pipe to the event-pipe class John Baldwin
2021-06-07 17:09 ` [RFC PATCH 4/7] fbsd-nat: Implement async target support John Baldwin
2021-06-07 22:49   ` John Baldwin
2021-06-27 16:12     ` Pedro Alves
2021-07-12 16:32       ` John Baldwin
2021-07-13 12:38         ` Pedro Alves
2021-07-20 22:35           ` John Baldwin
2021-06-07 17:09 ` [RFC PATCH 5/7] fbsd nat: Include ptrace operation in error messages John Baldwin
2021-06-27 16:13   ` Pedro Alves
2021-06-27 16:42     ` Pedro Alves
2021-07-12 15:11     ` John Baldwin
2021-07-13 12:43       ` Pedro Alves
2021-06-07 17:09 ` [RFC PATCH 6/7] fbsd nat: Switch function entry debug message from lwp to nat John Baldwin
2021-06-07 17:09 ` [RFC PATCH 7/7] fbsd nat: Return NULL rather than failing thread_alive John Baldwin
2021-06-25 23:35 ` [RFC PATCH 0/7] FreeBSD target async mode and related refactoring Lancelot SIX
2021-06-27 16:38 ` Pedro Alves

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=b7727fa5-80f1-5f18-49c4-433ef3856701@FreeBSD.org \
    --to=jhb@freebsd.org \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).