the ptid of the followed inferior. */
void
-fbsd_nat_target::follow_fork (bool follow_child, bool detach_fork)
+fbsd_nat_target::follow_fork (ptid_t child_ptid, target_waitkind fork_kind,
+ bool follow_child, bool detach_fork)
{
if (!follow_child && detach_fork)
{
- struct thread_info *tp = inferior_thread ();
- pid_t child_pid = tp->pending_follow.value.related_pid.pid ();
+ pid_t child_pid = child_ptid.pid ();
/* Breakpoints have already been detached from the child by
infrun.c. */
perror_with_name (("ptrace"));
#ifndef PTRACE_VFORK
- if (tp->pending_follow.kind == TARGET_WAITKIND_VFORKED)
+ if (fork_kind == TARGET_WAITKIND_VFORKED)
{
/* We can't insert breakpoints until the child process has
finished with the shared memory region. The parent
#endif
#ifdef TDP_RFPPWAIT
- void follow_fork (bool, bool) override;
+ void follow_fork (ptid_t, target_waitkind, bool, bool) override;
int insert_fork_catchpoint (int) override;
int remove_fork_catchpoint (int) override;
static bool
follow_fork_inferior (bool follow_child, bool detach_fork)
{
- int has_vforked;
- ptid_t parent_ptid, child_ptid;
-
- has_vforked = (inferior_thread ()->pending_follow.kind
- == TARGET_WAITKIND_VFORKED);
- parent_ptid = inferior_ptid;
- child_ptid = inferior_thread ()->pending_follow.value.related_pid;
+ target_waitkind fork_kind = inferior_thread ()->pending_follow.kind;
+ gdb_assert (fork_kind == TARGET_WAITKIND_FORKED
+ || fork_kind == TARGET_WAITKIND_VFORKED);
+ bool has_vforked = fork_kind == TARGET_WAITKIND_VFORKED;
+ ptid_t parent_ptid = inferior_ptid;
+ ptid_t child_ptid = inferior_thread ()->pending_follow.value.related_pid;
if (has_vforked
&& !non_stop /* Non-stop always resumes both branches. */
switch_to_thread (child_thr);
}
- target_follow_fork (follow_child, detach_fork);
+ target_follow_fork (child_ptid, fork_kind, follow_child, detach_fork);
/* If we ended up creating a new inferior, call post_create_inferior to inform
the various subcomponents. */
unchanged. */
void
-linux_nat_target::follow_fork (bool follow_child, bool detach_fork)
+linux_nat_target::follow_fork (ptid_t child_ptid, target_waitkind fork_kind,
+ bool follow_child, bool detach_fork)
{
if (!follow_child)
{
- struct lwp_info *child_lp = NULL;
- int has_vforked;
- ptid_t parent_ptid, child_ptid;
- int parent_pid, child_pid;
-
- has_vforked = (inferior_thread ()->pending_follow.kind
- == TARGET_WAITKIND_VFORKED);
- parent_ptid = inferior_ptid;
+ bool has_vforked = fork_kind == TARGET_WAITKIND_VFORKED;
+ ptid_t parent_ptid = inferior_ptid;
child_ptid = inferior_thread ()->pending_follow.value.related_pid;
- parent_pid = parent_ptid.lwp ();
- child_pid = child_ptid.lwp ();
+ int parent_pid = parent_ptid.lwp ();
+ int child_pid = child_ptid.lwp ();
/* We're already attached to the parent, by default. */
- child_lp = add_lwp (child_ptid);
+ lwp_info *child_lp = add_lwp (child_ptid);
child_lp->stopped = 1;
child_lp->last_resume_kind = resume_stop;
void post_attach (int) override;
- void follow_fork (bool, bool) override;
+ void follow_fork (ptid_t, target_waitkind, bool, bool) override;
std::vector<static_tracepoint_marker>
static_tracepoint_markers_by_strid (const char *id) override;
the ptid of the followed inferior. */
void
-obsd_nat_target::follow_fork (bool follow_child, bool detach_fork)
+obsd_nat_target::follow_fork (ptid_t child_ptid, target_waitkind fork_kind,
+ bool follow_child, bool detach_fork)
{
if (!follow_child)
{
- struct thread_info *tp = inferior_thread ();
- pid_t child_pid = tp->pending_follow.value.related_pid.pid ();
-
/* Breakpoints have already been detached from the child by
infrun.c. */
- if (ptrace (PT_DETACH, child_pid, (PTRACE_TYPE_ARG3)1, 0) == -1)
+ if (ptrace (PT_DETACH, child_ptid.pid (), (PTRACE_TYPE_ARG3)1, 0) == -1)
perror_with_name (("ptrace"));
}
}
ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
#ifdef PT_GET_PROCESS_STATE
- void follow_fork (bool, bool) override;
+ void follow_fork (ptid_t, target_waitkind, bool, bool) override;
int insert_fork_catchpoint (int) override;
const struct btrace_config *btrace_conf (const struct btrace_target_info *) override;
bool augmented_libraries_svr4_read () override;
- void follow_fork (bool, bool) override;
+ void follow_fork (ptid_t, target_waitkind, bool, bool) override;
void follow_exec (inferior *, ptid_t, const char *) override;
int insert_fork_catchpoint (int) override;
int remove_fork_catchpoint (int) override;
remote target as well. */
void
-remote_target::follow_fork (bool follow_child, bool detach_fork)
+remote_target::follow_fork (ptid_t child_ptid, target_waitkind fork_kind,
+ bool follow_child, bool detach_fork)
{
struct remote_state *rs = get_remote_state ();
- enum target_waitkind kind = inferior_thread ()->pending_follow.kind;
- if ((kind == TARGET_WAITKIND_FORKED && remote_fork_event_p (rs))
- || (kind == TARGET_WAITKIND_VFORKED && remote_vfork_event_p (rs)))
+ if ((fork_kind == TARGET_WAITKIND_FORKED && remote_fork_event_p (rs))
+ || (fork_kind == TARGET_WAITKIND_VFORKED && remote_vfork_event_p (rs)))
{
/* When following the parent and detaching the child, we detach
the child here. For the case of following the child and
if (detach_fork && !follow_child)
{
/* Detach the fork child. */
- ptid_t child_ptid;
- pid_t child_pid;
-
- child_ptid = inferior_thread ()->pending_follow.value.related_pid;
- child_pid = child_ptid.pid ();
-
- remote_detach_pid (child_pid);
+ remote_detach_pid (child_ptid.pid ());
}
}
}
target_debug_do_print (host_address_to_string (X.data ()))
#define target_debug_print_gdb_unique_xmalloc_ptr_char(X) \
target_debug_do_print (X.get ())
+#define target_debug_print_target_waitkind(X) \
+ target_debug_do_print (pulongest (X))
static void
target_debug_print_struct_target_waitstatus_p (struct target_waitstatus *status)
int remove_fork_catchpoint (int arg0) override;
int insert_vfork_catchpoint (int arg0) override;
int remove_vfork_catchpoint (int arg0) override;
- void follow_fork (bool arg0, bool arg1) override;
+ void follow_fork (ptid_t arg0, target_waitkind arg1, bool arg2, bool arg3) override;
int insert_exec_catchpoint (int arg0) override;
int remove_exec_catchpoint (int arg0) override;
void follow_exec (inferior *arg0, ptid_t arg1, const char *arg2) override;
int remove_fork_catchpoint (int arg0) override;
int insert_vfork_catchpoint (int arg0) override;
int remove_vfork_catchpoint (int arg0) override;
- void follow_fork (bool arg0, bool arg1) override;
+ void follow_fork (ptid_t arg0, target_waitkind arg1, bool arg2, bool arg3) override;
int insert_exec_catchpoint (int arg0) override;
int remove_exec_catchpoint (int arg0) override;
void follow_exec (inferior *arg0, ptid_t arg1, const char *arg2) override;
}
void
-target_ops::follow_fork (bool arg0, bool arg1)
+target_ops::follow_fork (ptid_t arg0, target_waitkind arg1, bool arg2, bool arg3)
{
- this->beneath ()->follow_fork (arg0, arg1);
+ this->beneath ()->follow_fork (arg0, arg1, arg2, arg3);
}
void
-dummy_target::follow_fork (bool arg0, bool arg1)
+dummy_target::follow_fork (ptid_t arg0, target_waitkind arg1, bool arg2, bool arg3)
{
- default_follow_fork (this, arg0, arg1);
+ default_follow_fork (this, arg0, arg1, arg2, arg3);
}
void
-debug_target::follow_fork (bool arg0, bool arg1)
+debug_target::follow_fork (ptid_t arg0, target_waitkind arg1, bool arg2, bool arg3)
{
fprintf_unfiltered (gdb_stdlog, "-> %s->follow_fork (...)\n", this->beneath ()->shortname ());
- this->beneath ()->follow_fork (arg0, arg1);
+ this->beneath ()->follow_fork (arg0, arg1, arg2, arg3);
fprintf_unfiltered (gdb_stdlog, "<- %s->follow_fork (", this->beneath ()->shortname ());
- target_debug_print_bool (arg0);
+ target_debug_print_ptid_t (arg0);
fputs_unfiltered (", ", gdb_stdlog);
- target_debug_print_bool (arg1);
+ target_debug_print_target_waitkind (arg1);
+ fputs_unfiltered (", ", gdb_stdlog);
+ target_debug_print_bool (arg2);
+ fputs_unfiltered (", ", gdb_stdlog);
+ target_debug_print_bool (arg3);
fputs_unfiltered (")\n", gdb_stdlog);
}
}
static void
-default_follow_fork (struct target_ops *self, bool follow_child,
+default_follow_fork (struct target_ops *self, ptid_t child_ptid,
+ target_waitkind fork_kind, bool follow_child,
bool detach_fork)
{
/* Some target returned a fork event, but did not know how to follow it. */
/* See target.h. */
void
-target_follow_fork (bool follow_child, bool detach_fork)
+target_follow_fork (ptid_t child_ptid, target_waitkind fork_kind,
+ bool follow_child, bool detach_fork)
{
target_ops *target = current_inferior ()->top_target ();
- return target->follow_fork (follow_child, detach_fork);
+ return target->follow_fork (child_ptid, fork_kind, follow_child, detach_fork);
}
/* See target.h. */
TARGET_DEFAULT_RETURN (1);
virtual int remove_vfork_catchpoint (int)
TARGET_DEFAULT_RETURN (1);
- virtual void follow_fork (bool, bool)
+ virtual void follow_fork (ptid_t, target_waitkind, bool, bool)
TARGET_DEFAULT_FUNC (default_follow_fork);
virtual int insert_exec_catchpoint (int)
TARGET_DEFAULT_RETURN (1);
extern int target_remove_vfork_catchpoint (int pid);
-/* If the inferior forks or vforks, this function will be called at
- the next resume in order to perform any bookkeeping and fiddling
- necessary to continue debugging either the parent or child, as
- requested, and releasing the other. Information about the fork
- or vfork event is available via get_last_target_status (). */
+/* Call the follow_fork method on the current target stack.
-void target_follow_fork (bool follow_child, bool detach_fork);
+ This function is called when the inferior forks or vforks, to perform any
+ bookkeeping and fiddling necessary to continue debugging either the parent,
+ the child or both. */
+
+void target_follow_fork (ptid_t child_ptid, target_waitkind fork_kind,
+ bool follow_child, bool detach_fork);
/* Handle the target-specific bookkeeping required when the inferior makes an
exec call.