X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Finf-ptrace.c;h=797a70a7ea9a13f4f78f27f8dba3006646d382b1;hb=7f9f62ba187205cd123fd2e96909e6d19ad708eb;hp=301d59d58621720eb018dcf883545e8c6b4ca46e;hpb=b77209e0003218790c76f67c5ee3e5802168ecaa;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c index 301d59d586..797a70a7ea 100644 --- a/gdb/inf-ptrace.c +++ b/gdb/inf-ptrace.c @@ -89,11 +89,14 @@ inf_ptrace_follow_fork (struct target_ops *ops, int follow_child) if (ptrace (PT_DETACH, pid, (PTRACE_TYPE_ARG3)1, 0) == -1) perror_with_name (("ptrace")); + /* Switch inferior_ptid out of the parent's way. */ + inferior_ptid = pid_to_ptid (fpid); + /* Delete the parent. */ - delete_thread_silent (last_tp->ptid); + detach_inferior (pid); /* Add the child. */ - inferior_ptid = pid_to_ptid (fpid); + add_inferior (fpid); tp = add_thread_silent (inferior_ptid); tp->step_resume_breakpoint = step_resume_breakpoint; @@ -111,6 +114,7 @@ inf_ptrace_follow_fork (struct target_ops *ops, int follow_child) if (ptrace (PT_DETACH, fpid, (PTRACE_TYPE_ARG3)1, 0) == -1) perror_with_name (("ptrace")); + detach_inferior (pid); } return 0; @@ -247,6 +251,8 @@ inf_ptrace_attach (char *args, int from_tty) inferior_ptid = pid_to_ptid (pid); + add_inferior (pid); + /* Always add a main thread. If some target extends the ptrace target, it should decorate the ptid later with more info. */ add_thread_silent (inferior_ptid); @@ -307,6 +313,7 @@ inf_ptrace_detach (char *args, int from_tty) #endif inferior_ptid = null_ptid; + detach_inferior (pid); unpush_target (ptrace_ops_hack); }