sys_process.c: extract ptrace_unsuspend()

Reviewed by:	jhb
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differrential revision:	https://reviews.freebsd.org/D30351
This commit is contained in:
Konstantin Belousov 2021-05-18 19:25:50 +03:00
parent 91aae953cb
commit d7a7ea5be6
2 changed files with 17 additions and 6 deletions

View File

@ -610,6 +610,19 @@ proc_set_traced(struct proc *p, bool stop)
p->p_ptevents = PTRACE_DEFAULT;
}
void
ptrace_unsuspend(struct proc *p)
{
PROC_LOCK_ASSERT(p, MA_OWNED);
PROC_SLOCK(p);
p->p_flag &= ~(P_STOPPED_TRACE | P_STOPPED_SIG | P_WAITED);
thread_unsuspend(p);
PROC_SUNLOCK(p);
itimer_proc_continue(p);
kqtimer_proc_continue(p);
}
static int
proc_can_ptrace(struct thread *td, struct proc *p)
{
@ -1164,12 +1177,7 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
* suspended, use PT_SUSPEND to suspend it before
* continuing the process.
*/
PROC_SLOCK(p);
p->p_flag &= ~(P_STOPPED_TRACE | P_STOPPED_SIG | P_WAITED);
thread_unsuspend(p);
PROC_SUNLOCK(p);
itimer_proc_continue(p);
kqtimer_proc_continue(p);
ptrace_unsuspend(p);
break;
case PT_WRITE_I:

View File

@ -240,6 +240,9 @@ int proc_write_fpregs32(struct thread *_td, struct fpreg32 *_fpreg32);
int proc_read_dbregs32(struct thread *_td, struct dbreg32 *_dbreg32);
int proc_write_dbregs32(struct thread *_td, struct dbreg32 *_dbreg32);
#endif
void ptrace_unsuspend(struct proc *p);
#else /* !_KERNEL */
#include <sys/cdefs.h>