+2018-01-19 Simon Marchi <simon.marchi@ericsson.com>
+
+ * inf-ptrace.c (inf_ptrace_detach): Adjust call to
+ inf_ptrace_detach_success.
+ (inf_ptrace_detach_success): Add inferior parameter, use it
+ instead of inferior_ptid, pass it to detach_inferior.
+ * inf-ptrace.h (inf_ptrace_detach_success): Add inferior
+ parameter.
+ * inferior.c (detach_inferior): Add overload that takes an
+ inferior object.
+ * inferior.h (detach_inferior): Likewise.
+ * linux-nat.c (linux_nat_detach): Use the inf parameter, don't
+ use inferior_ptid, adjust call to inf_ptrace_detach_success.
+ * linux-thread-db.c (thread_db_detach): Use inf parameter.
+
2018-01-19 Simon Marchi <simon.marchi@ericsson.com>
* target.h (struct target_ops) <to_detach>: Add inferior
error (_("This system does not support detaching from a process"));
#endif
- inf_ptrace_detach_success (ops);
+ inf_ptrace_detach_success (ops, inf);
}
/* See inf-ptrace.h. */
void
-inf_ptrace_detach_success (struct target_ops *ops)
+inf_ptrace_detach_success (struct target_ops *ops, inferior *inf)
{
- pid_t pid = ptid_get_pid (inferior_ptid);
-
inferior_ptid = null_ptid;
- detach_inferior (pid);
+ detach_inferior (inf);
inf_child_maybe_unpush_target (ops);
}
/* Cleanup the inferior after a successful ptrace detach. */
-extern void inf_ptrace_detach_success (struct target_ops *ops);
+extern void inf_ptrace_detach_success (struct target_ops *ops, inferior *inf);
#endif
exit_inferior_1 (inf, 1);
}
+/* See inferior.h. */
+
void
-detach_inferior (int pid)
+detach_inferior (inferior *inf)
{
- struct inferior *inf = find_inferior_pid (pid);
+ /* Save the pid, since exit_inferior_1 will reset it. */
+ int pid = inf->pid;
exit_inferior_1 (inf, 0);
printf_unfiltered (_("[Inferior %d detached]\n"), pid);
}
+/* See inferior.h. */
+
+void
+detach_inferior (int pid)
+{
+ detach_inferior (find_inferior_pid (pid));
+}
+
void
inferior_appeared (struct inferior *inf, int pid)
{
extern void delete_inferior (struct inferior *todel);
/* Delete an existing inferior list entry, due to inferior detaching. */
+extern void detach_inferior (inferior *inf);
+
+/* Same as the above, but with the inferior specified by PID. */
extern void detach_inferior (int pid);
extern void exit_inferior (int pid);
static void
linux_nat_detach (struct target_ops *ops, inferior *inf, int from_tty)
{
- int pid;
struct lwp_info *main_lwp;
-
- pid = ptid_get_pid (inferior_ptid);
+ int pid = inf->pid;
/* Don't unregister from the event loop, as there may be other
inferiors running. */
iterate_over_lwps (pid_to_ptid (pid), detach_callback, NULL);
/* Only the initial process should be left right now. */
- gdb_assert (num_lwps (ptid_get_pid (inferior_ptid)) == 1);
+ gdb_assert (num_lwps (pid) == 1);
main_lwp = find_lwp_pid (pid_to_ptid (pid));
detach_one_lwp (main_lwp, &signo);
- inf_ptrace_detach_success (ops);
+ inf_ptrace_detach_success (ops, inf);
}
}
{
struct target_ops *target_beneath = find_target_beneath (ops);
- delete_thread_db_info (ptid_get_pid (inferior_ptid));
+ delete_thread_db_info (inf->pid);
target_beneath->to_detach (target_beneath, inf, from_tty);