public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/7] FreeBSD target async mode and related refactoring
@ 2021-06-07 17:09 John Baldwin
  2021-06-07 17:09 ` [RFC PATCH 1/7] gdbsupport: Add an event-pipe class John Baldwin
                   ` (8 more replies)
  0 siblings, 9 replies; 25+ messages in thread
From: John Baldwin @ 2021-06-07 17:09 UTC (permalink / raw)
  To: gdb-patches

I hacked on this over the weekend.  For the testsuite on FreeBSD/amd64
it doesn't seem to add any new regressions and fixes various tests.
Patch 7 fixes a few more failures I noticed when comparing the
before/after logs.

This is an RFC as I have a few questions / thoughts I'd like some
feedback on before refining this further:

1) I haven't yet tested this on Linux and will need to do so to make
   sure the initial event_pipe refactoring doesn't cause regressions.

2) gdbsupport/event-pipe.cc probably doesn't build on Windows
   (gdb/ser-event.c doesn't use pipes on Windows which I didn't
   find until after I'd written this patch).  I think I'd like to only
   build event-pipe.cc for systems with HAVE_PIPE or HAVE_PIPE2.
   I just don't know how to express this in Makefile.am.

   I could potentially add a follow-up patch to change gdb/ser-events.c
   to use event_pipe rather than duplicating very similar logic for
   the non-Windows case.  The one difference I noticed so far is
   that the existing Linux event pipe drains any existing input
   in the "mark" method before writing the new character, but the
   ser-events version does not do the drain.

   An alternative perhaps is that instead of adding event_pipe to
   gdbsupport, I could add a slightly more abstract interface that is
   more like ser_events.c but at the lower level API where the
   event_fd / mark / post methods used an Event on Windows.  I'm not
   sure this is really needed though as if Windows wanted to use an
   event in the future for async mode it would be in Windows-specific
   code and could just use an Event directly.

3) I was surprised by the need to enable async mode explicitly in
   target::attach.  I had assumed that the policy of async vs
   non-async would have belonged in the core and that the core would
   have enabled async if it wanted during attach.  Similarly, I would
   expect do_target_wait_1 in infrun.c to check target_is_async_p
   rather than target_can_async_p for deciding whether to clear
   TARGET_WNOHANG.

4) It may be that some of this can be pulled into inf-ptrace to
   simplify adding async support on other platforms.  For example,
   inf-ptrace.c could export a 'ptrace_event_pipe' and provide
   implementations of is_async_p and async_waitfd that used that along
   with possibly some class helper methods to wrap the flush/mark
   methods to mostly hide ptrace_event_pipe (though the sigchld
   handlers probably still want to access it directly).  This would
   mean that the linux_nat_target::close and fbsd_nat_target::close
   methods could collapse back up into inf_ptrace_target along with
   ::is_async_p and ::async_waitfd.  Targets on other platforms
   would opt-in by providing ::can_async_p.

5) I don't understand why linux_nat_target::resume enables async
   mode explicitly similar to ::attach.  I don't think I need it
   in the FreeBSD target, but I'd feel better about that if I knew
   why the Linux target needed it.

John Baldwin (7):
  gdbsupport: Add an event-pipe class.
  gdb linux-nat: Convert linux_nat_event_pipe to the event_pipe class.
  gdbserver linux-low: Convert linux_event_pipe to the event-pipe class.
  fbsd-nat: Implement async target support.
  fbsd nat: Include ptrace operation in error messages.
  fbsd nat: Switch function entry debug message from lwp to nat.
  fbsd nat: Return NULL rather than failing thread_alive.

 gdb/ChangeLog            |  49 ++++++++++
 gdb/fbsd-nat.c           | 202 +++++++++++++++++++++++++++++++++++----
 gdb/fbsd-nat.h           |  13 +++
 gdb/inf-ptrace.c         |  27 +++++-
 gdb/linux-nat.c          |  48 +++-------
 gdbserver/ChangeLog      |   8 ++
 gdbserver/linux-low.cc   |  39 ++------
 gdbsupport/ChangeLog     |   7 ++
 gdbsupport/Makefile.am   |   1 +
 gdbsupport/Makefile.in   |  21 ++--
 gdbsupport/event-pipe.cc | 100 +++++++++++++++++++
 gdbsupport/event-pipe.h  |  55 +++++++++++
 12 files changed, 470 insertions(+), 100 deletions(-)
 create mode 100644 gdbsupport/event-pipe.cc
 create mode 100644 gdbsupport/event-pipe.h

-- 
2.31.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2021-07-20 22:35 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).