aboutsummaryrefslogtreecommitdiff
path: root/gdb/fbsd-nat.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2022-02-22 11:22:14 -0800
committerJohn Baldwin <jhb@FreeBSD.org>2022-02-22 11:22:14 -0800
commitb146ba14d7019e046f5691ffbffa1d852b798c72 (patch)
tree864815823848712c9bd97a6503e5f34772e6b446 /gdb/fbsd-nat.c
parente05523bd2411bac0277da73556f4d01f6c7448aa (diff)
downloadfsf-binutils-gdb-b146ba14d7019e046f5691ffbffa1d852b798c72.zip
fsf-binutils-gdb-b146ba14d7019e046f5691ffbffa1d852b798c72.tar.gz
fsf-binutils-gdb-b146ba14d7019e046f5691ffbffa1d852b798c72.tar.bz2
inf-ptrace: Add an event_pipe to be used for async mode in subclasses.
Subclasses of inf_ptrace_target have to opt-in to using the event_pipe by implementing the can_async_p and async methods. For subclasses which do this, inf_ptrace_target provides is_async_p, async_wait_fd and closes the pipe in the close target method. inf_ptrace_target also provides wrapper routines around the event pipe (async_file_open, async_file_close, async_file_flush, and async_file_mark) for use in target methods such as async. inf_ptrace_target also exports a static async_file_mark_if_open function which can be used in SIGCHLD signal handlers.
Diffstat (limited to 'gdb/fbsd-nat.c')
-rw-r--r--gdb/fbsd-nat.c50
1 files changed, 9 insertions, 41 deletions
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index 6f1f208..ba84265 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -21,7 +21,6 @@
#include "gdbsupport/block-signals.h"
#include "gdbsupport/byte-vector.h"
#include "gdbsupport/event-loop.h"
-#include "gdbsupport/event-pipe.h"
#include "gdbcore.h"
#include "inferior.h"
#include "regcache.h"
@@ -932,8 +931,6 @@ fbsd_nat_target::update_thread_list ()
/* Async mode support. */
-static event_pipe fbsd_nat_event_pipe;
-
/* Implement the "can_async_p" target method. */
bool
@@ -946,22 +943,6 @@ fbsd_nat_target::can_async_p ()
return true;
}
-/* Implement the "is_async_p" target method. */
-
-bool
-fbsd_nat_target::is_async_p ()
-{
- return fbsd_nat_event_pipe.is_open ();
-}
-
-/* Implement the "async_wait_fd" target method. */
-
-int
-fbsd_nat_target::async_wait_fd ()
-{
- return fbsd_nat_event_pipe.event_fd ();
-}
-
/* SIGCHLD handler notifies the event-loop in async mode. */
static void
@@ -969,8 +950,7 @@ sigchld_handler (int signo)
{
int old_errno = errno;
- if (fbsd_nat_event_pipe.is_open ())
- fbsd_nat_event_pipe.mark ();
+ fbsd_nat_target::async_file_mark_if_open ();
errno = old_errno;
}
@@ -997,34 +977,22 @@ fbsd_nat_target::async (int enable)
if (enable)
{
- if (!fbsd_nat_event_pipe.open ())
+ if (!async_file_open ())
internal_error (__FILE__, __LINE__, "failed to create event pipe.");
- add_file_handler (fbsd_nat_event_pipe.event_fd (),
- handle_target_event, NULL, "fbsd-nat");
+ add_file_handler (async_wait_fd (), handle_target_event, NULL, "fbsd-nat");
/* Trigger a poll in case there are pending events to
handle. */
- fbsd_nat_event_pipe.mark ();
+ async_file_mark ();
}
else
{
- delete_file_handler (fbsd_nat_event_pipe.event_fd ());
- fbsd_nat_event_pipe.close ();
+ delete_file_handler (async_wait_fd ());
+ async_file_close ();
}
}
-/* Implement the "close" target method. */
-
-void
-fbsd_nat_target::close ()
-{
- if (is_async_p ())
- async (0);
-
- inf_ptrace_target::close ();
-}
-
#ifdef TDP_RFPPWAIT
/*
To catch fork events, PT_FOLLOW_FORK is set on every traced process
@@ -1100,7 +1068,7 @@ fbsd_add_vfork_done (ptid_t pid)
/* If we're in async mode, need to tell the event loop there's
something here to process. */
if (target_is_async_p ())
- fbsd_nat_event_pipe.mark ();
+ async_file_mark ();
}
/* Check for a pending vfork done event for a specific PID. */
@@ -1499,7 +1467,7 @@ fbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
/* Ensure any subsequent events trigger a new event in the loop. */
if (is_async_p ())
- fbsd_nat_event_pipe.flush ();
+ async_file_flush ();
wptid = wait_1 (ptid, ourstatus, target_options);
@@ -1510,7 +1478,7 @@ fbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
&& ((ourstatus->kind () != TARGET_WAITKIND_IGNORE
&& ourstatus->kind() != TARGET_WAITKIND_NO_RESUMED)
|| ptid != minus_one_ptid))
- fbsd_nat_event_pipe.mark ();
+ async_file_mark ();
fbsd_nat_debug_printf ("returning [%s], [%s]",
target_pid_to_str (wptid).c_str (),