aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/fbsd-nat.c8
-rw-r--r--gdb/fbsd-nat.h2
-rw-r--r--gdb/infrun.c15
-rw-r--r--gdb/linux-nat.c19
-rw-r--r--gdb/linux-nat.h2
-rw-r--r--gdb/obsd-nat.c8
-rw-r--r--gdb/obsd-nat.h2
-rw-r--r--gdb/remote.c18
-rw-r--r--gdb/target-debug.h2
-rw-r--r--gdb/target-delegates.c24
-rw-r--r--gdb/target.c8
-rw-r--r--gdb/target.h15
12 files changed, 59 insertions, 64 deletions
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index 33eddb5..0ae1195 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -1471,12 +1471,12 @@ fbsd_nat_target::create_inferior (const char *exec_file,
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. */
@@ -1485,7 +1485,7 @@ fbsd_nat_target::follow_fork (bool follow_child, bool detach_fork)
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
diff --git a/gdb/fbsd-nat.h b/gdb/fbsd-nat.h
index a590654..3fb502c 100644
--- a/gdb/fbsd-nat.h
+++ b/gdb/fbsd-nat.h
@@ -85,7 +85,7 @@ public:
#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;
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 04206b3..815ebf4 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -404,13 +404,12 @@ show_follow_fork_mode_string (struct ui_file *file, int from_tty,
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. */
@@ -649,7 +648,7 @@ holding the child stopped. Try \"set detach-on-fork\" or \
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. */
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 2b52dbd..e4d0206 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -449,24 +449,19 @@ typedef std::unique_ptr<struct lwp_info, lwp_deleter> lwp_info_up;
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;
diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h
index feeadda..ee36c56 100644
--- a/gdb/linux-nat.h
+++ b/gdb/linux-nat.h
@@ -133,7 +133,7 @@ public:
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;
diff --git a/gdb/obsd-nat.c b/gdb/obsd-nat.c
index a8164dd..46fdc06 100644
--- a/gdb/obsd-nat.c
+++ b/gdb/obsd-nat.c
@@ -194,17 +194,15 @@ obsd_nat_target::post_startup_inferior (ptid_t pid)
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"));
}
}
diff --git a/gdb/obsd-nat.h b/gdb/obsd-nat.h
index 60b078f..ddd4baf 100644
--- a/gdb/obsd-nat.h
+++ b/gdb/obsd-nat.h
@@ -30,7 +30,7 @@ class obsd_nat_target : public inf_ptrace_target
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;
diff --git a/gdb/remote.c b/gdb/remote.c
index 96e2750..e488ca6 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -682,7 +682,7 @@ public:
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;
@@ -5920,13 +5920,13 @@ extended_remote_target::detach (inferior *inf, int from_tty)
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
@@ -5937,13 +5937,7 @@ remote_target::follow_fork (bool follow_child, bool detach_fork)
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 ());
}
}
}
diff --git a/gdb/target-debug.h b/gdb/target-debug.h
index c3004c2..5949441 100644
--- a/gdb/target-debug.h
+++ b/gdb/target-debug.h
@@ -174,6 +174,8 @@
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)
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 3e759a2..fa4cc5b 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -56,7 +56,7 @@ struct dummy_target : public target_ops
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;
@@ -231,7 +231,7 @@ struct debug_target : public target_ops
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;
@@ -1519,26 +1519,30 @@ debug_target::remove_vfork_catchpoint (int arg0)
}
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);
}
diff --git a/gdb/target.c b/gdb/target.c
index 7875289..b0f3e88 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -2701,7 +2701,8 @@ target_program_signals (gdb::array_view<const unsigned char> program_signals)
}
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. */
@@ -2712,11 +2713,12 @@ default_follow_fork (struct target_ops *self, bool follow_child,
/* 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. */
diff --git a/gdb/target.h b/gdb/target.h
index ddd4f38..5ba73f4 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -636,7 +636,7 @@ struct target_ops
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);
@@ -1713,13 +1713,14 @@ extern int target_insert_vfork_catchpoint (int pid);
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.