const struct btrace_config *btrace_conf (const struct btrace_target_info *) override;
bool augmented_libraries_svr4_read () override;
void follow_fork (inferior *, ptid_t, target_waitkind, bool, bool) override;
+ void follow_clone (ptid_t child_ptid) override;
void follow_exec (inferior *, ptid_t, const char *) override;
int insert_fork_catchpoint (int) override;
int remove_fork_catchpoint (int) override;
else
thread = add_thread (this, ptid);
- /* We start by assuming threads are resumed. That state then gets updated
- when we process a matching stop reply. */
- get_remote_thread_info (thread)->set_resumed ();
+ /* We start by assuming threads are resumed. That state then gets
+ updated when we process a matching stop reply. */
+ if (executing)
+ get_remote_thread_info (thread)->set_resumed ();
set_executing (this, ptid, executing);
set_running (this, ptid, running);
}
else
switch_to_thread (find_thread_ptid (this, curr_thread));
+
+ get_remote_thread_info (inferior_thread ())->set_resumed ();
}
/* init_wait_for_inferior should be called before get_offsets in order
|| kind == TARGET_WAITKIND_VFORKED);
}
-/* Return THREAD's pending status if it is a pending fork parent, else
- return nullptr. */
+/* Determine if WS represents an event with a new child - a fork,
+ vfork, or clone. */
+
+static bool
+is_new_child_status (target_waitkind kind)
+{
+ return (kind == TARGET_WAITKIND_FORKED
+ || kind == TARGET_WAITKIND_VFORKED
+ || kind == TARGET_WAITKIND_THREAD_CLONED);
+}
+
+/* Return a reference to the field that records the THREAD's pending
+ child status, if there's one. */
+
+static const target_waitstatus &
+thread_pending_status (struct thread_info *thread)
+{
+ return (thread->has_pending_waitstatus ()
+ ? thread->pending_waitstatus ()
+ : thread->pending_follow);
+}
+
+/* Return THREAD's pending status if it is a pending fork/vfork (but
+ not clone) parent, else return nullptr. */
static const target_waitstatus *
thread_pending_fork_status (struct thread_info *thread)
{
- const target_waitstatus &ws
- = (thread->has_pending_waitstatus ()
- ? thread->pending_waitstatus ()
- : thread->pending_follow);
+ const target_waitstatus &ws = thread_pending_status (thread);
if (!is_fork_status (ws.kind ()))
return nullptr;
return &ws;
}
+/* Return THREAD's pending status if is is a pending fork/vfork/clone
+ event, else return nullptr. */
+
+static const target_waitstatus *
+thread_pending_child_status (thread_info *thread)
+{
+ const target_waitstatus &ws = thread_pending_status (thread);
+
+ if (!is_new_child_status (ws.kind ()))
+ return nullptr;
+
+ return &ws;
+}
+
/* Detach the specified process. */
void
}
}
+void
+remote_target::follow_clone (ptid_t child_ptid)
+{
+ remote_add_thread (child_ptid, false, false, false);
+}
+
/* Target follow-exec function for remote targets. Save EXECD_PATHNAME
in the program space of the new inferior. */
if (priv->get_resume_state () == resume_state::RESUMED_PENDING_VCONT)
any_pending_vcont_resume = true;
- /* If a thread is the parent of an unfollowed fork, then we
- can't do a global wildcard, as that would resume the fork
- child. */
- if (thread_pending_fork_status (tp) != nullptr)
+ /* If a thread is the parent of an unfollowed fork/vfork/clone,
+ then we can't do a global wildcard, as that would resume the
+ pending child. */
+ if (thread_pending_child_status (tp) != nullptr)
may_global_wildcard_vcont = false;
}
{
struct notif_client *notif = ¬if_client_stop;
- /* For any threads stopped at a fork event, remove the corresponding
- fork child threads from the CONTEXT list. */
+ /* For any threads stopped at a (v)fork/clone event, remove the
+ corresponding child threads from the CONTEXT list. */
for (thread_info *thread : all_non_exited_threads (this))
{
- const target_waitstatus *ws = thread_pending_fork_status (thread);
+ const target_waitstatus *ws = thread_pending_child_status (thread);
if (ws == nullptr)
continue;
context->remove_thread (ws->child_ptid ());
}
- /* Check for any pending fork events (not reported or processed yet)
- in process PID and remove those fork child threads from the
- CONTEXT list as well. */
+ /* Check for any pending (v)fork/clone events (not reported or
+ processed yet) in process PID and remove those child threads from
+ the CONTEXT list as well. */
remote_notif_get_pending_events (notif);
for (auto &event : get_remote_state ()->stop_reply_queue)
if (event->ws.kind () == TARGET_WAITKIND_FORKED
- || event->ws.kind () == TARGET_WAITKIND_VFORKED)
+ || event->ws.kind () == TARGET_WAITKIND_VFORKED
+ || event->ws.kind () == TARGET_WAITKIND_THREAD_CLONED)
context->remove_thread (event->ws.child_ptid ());
else if (event->ws.kind () == TARGET_WAITKIND_THREAD_EXITED)
context->remove_thread (event->ptid);
event->ws.set_forked (read_ptid (++p1, &p));
else if (strprefix (p, p1, "vfork"))
event->ws.set_vforked (read_ptid (++p1, &p));
+ else if (strprefix (p, p1, "clone"))
+ event->ws.set_thread_cloned (read_ptid (++p1, &p));
else if (strprefix (p, p1, "vforkdone"))
{
event->ws.set_vfork_done ();
case TARGET_WAITKIND_FORKED:
case TARGET_WAITKIND_VFORKED:
case TARGET_WAITKIND_VFORK_DONE:
+ case TARGET_WAITKIND_THREAD_CLONED:
case TARGET_WAITKIND_EXECD:
case TARGET_WAITKIND_THREAD_CREATED:
case TARGET_WAITKIND_SYSCALL_ENTRY:
struct regcache *regcache;
char *buf_start = buf;
- if ((status.kind () == TARGET_WAITKIND_FORKED && cs.report_fork_events)
+ if ((status.kind () == TARGET_WAITKIND_FORKED
+ && cs.report_fork_events)
|| (status.kind () == TARGET_WAITKIND_VFORKED
- && cs.report_vfork_events))
+ && cs.report_vfork_events)
+ || status.kind () == TARGET_WAITKIND_THREAD_CLONED)
{
enum gdb_signal signal = GDB_SIGNAL_TRAP;
- const char *event = (status.kind () == TARGET_WAITKIND_FORKED
- ? "fork" : "vfork");
+
+ auto kind_remote_str = [] (target_waitkind kind)
+ {
+ switch (kind)
+ {
+ case TARGET_WAITKIND_FORKED:
+ return "fork";
+ case TARGET_WAITKIND_VFORKED:
+ return "vfork";
+ case TARGET_WAITKIND_THREAD_CLONED:
+ return "clone";
+ default:
+ gdb_assert_not_reached ("unhandled kind");
+ }
+ };
+
+ const char *event = kind_remote_str (status.kind ());
sprintf (buf, "T%02x%s:", signal, event);
buf += strlen (buf);