PR kern/52117: move stop code for debuged children after fork into MI code.
XXX we might want to revisit this when handling the same event for vfork better.
This commit is contained in:
parent
eabd5e1de9
commit
1fd4f01ae0
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: syscall.c,v 1.14 2016/07/07 06:55:40 msaitoh Exp $ */
|
||||
/* $NetBSD: syscall.c,v 1.15 2017/03/31 08:47:04 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2000, 2009 The NetBSD Foundation, Inc.
|
||||
@ -30,7 +30,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.14 2016/07/07 06:55:40 msaitoh Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.15 2017/03/31 08:47:04 martin Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -65,18 +65,6 @@ child_return(void *arg)
|
||||
{
|
||||
struct lwp *l = arg;
|
||||
struct trapframe *tf = l->l_md.md_regs;
|
||||
struct proc *p = l->l_proc;
|
||||
|
||||
if (p->p_slflag & PSL_TRACED) {
|
||||
ksiginfo_t ksi;
|
||||
|
||||
mutex_enter(proc_lock);
|
||||
KSI_INIT_EMPTY(&ksi);
|
||||
ksi.ksi_signo = SIGTRAP;
|
||||
ksi.ksi_lid = l->l_lid;
|
||||
kpsignal(p, &ksi, NULL);
|
||||
mutex_exit(proc_lock);
|
||||
}
|
||||
|
||||
X86_TF_RAX(tf) = 0;
|
||||
X86_TF_RFLAGS(tf) &= ~PSL_C;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_fork.c,v 1.199 2017/01/13 23:00:35 kamil Exp $ */
|
||||
/* $NetBSD: kern_fork.c,v 1.200 2017/03/31 08:47:04 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2001, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
@ -67,7 +67,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.199 2017/01/13 23:00:35 kamil Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.200 2017/03/31 08:47:04 martin Exp $");
|
||||
|
||||
#include "opt_ktrace.h"
|
||||
#include "opt_dtrace.h"
|
||||
@ -500,6 +500,17 @@ fork1(struct lwp *l1, int flags, int exitsig, void *stack, size_t stacksize,
|
||||
(*p2->p_emul->e_syscall_intern)(p2);
|
||||
#endif
|
||||
|
||||
/* if we are being traced, give the owner a chance to interfere */
|
||||
if (p2->p_slflag & PSL_TRACED) {
|
||||
ksiginfo_t ksi;
|
||||
|
||||
KSI_INIT_EMPTY(&ksi);
|
||||
ksi.ksi_signo = SIGTRAP;
|
||||
ksi.ksi_code = TRAP_CHLD;
|
||||
ksi.ksi_lid = l2->l_lid;
|
||||
kpsignal(p2, &ksi, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Update stats now that we know the fork was successful.
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_sig.c,v 1.334 2017/03/24 17:40:44 christos Exp $ */
|
||||
/* $NetBSD: kern_sig.c,v 1.335 2017/03/31 08:47:04 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
@ -70,7 +70,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.334 2017/03/24 17:40:44 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.335 2017/03/31 08:47:04 martin Exp $");
|
||||
|
||||
#include "opt_ptrace.h"
|
||||
#include "opt_dtrace.h"
|
||||
@ -1224,7 +1224,7 @@ kpsignal2(struct proc *p, ksiginfo_t *ksi)
|
||||
ksiginfo_t *kp;
|
||||
lwpid_t lid;
|
||||
sig_t action;
|
||||
bool toall;
|
||||
bool toall, debtrap = false;
|
||||
int error = 0;
|
||||
|
||||
KASSERT(!cpu_intr_p());
|
||||
@ -1237,8 +1237,13 @@ kpsignal2(struct proc *p, ksiginfo_t *ksi)
|
||||
* If the process is being created by fork, is a zombie or is
|
||||
* exiting, then just drop the signal here and bail out.
|
||||
*/
|
||||
if (p->p_stat != SACTIVE && p->p_stat != SSTOP)
|
||||
if (p->p_stat == SIDL && signo == SIGTRAP
|
||||
&& (p->p_slflag & PSL_TRACED)) {
|
||||
/* allow an initial SIGTRAP for traced processes */
|
||||
debtrap = true;
|
||||
} else if (p->p_stat != SACTIVE && p->p_stat != SSTOP) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* XXX for core dump/debugger */
|
||||
p->p_sigctx.ps_lwp = ksi->ksi_lid;
|
||||
@ -1353,7 +1358,13 @@ kpsignal2(struct proc *p, ksiginfo_t *ksi)
|
||||
* the signal to it.
|
||||
*/
|
||||
if (lid != 0) {
|
||||
l = lwp_find(p, lid);
|
||||
if (__predict_false(debtrap)) {
|
||||
l = LIST_FIRST(&p->p_lwps);
|
||||
if (l->l_lid != lid)
|
||||
l = NULL;
|
||||
} else {
|
||||
l = lwp_find(p, lid);
|
||||
}
|
||||
if (l != NULL) {
|
||||
if ((error = sigput(&l->l_sigpend, p, kp)) != 0)
|
||||
goto out;
|
||||
|
Loading…
Reference in New Issue
Block a user