Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys PR kern/52117: move stop code for debuged children after...
details: https://anonhg.NetBSD.org/src/rev/158b1f61165b
branches: trunk
changeset: 352425:158b1f61165b
user: martin <martin%NetBSD.org@localhost>
date: Fri Mar 31 08:47:04 2017 +0000
description:
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.
diffstat:
sys/arch/x86/x86/syscall.c | 16 ++--------------
sys/kern/kern_fork.c | 15 +++++++++++++--
sys/kern/kern_sig.c | 21 ++++++++++++++++-----
3 files changed, 31 insertions(+), 21 deletions(-)
diffs (130 lines):
diff -r 5c0bbaa5fdf9 -r 158b1f61165b sys/arch/x86/x86/syscall.c
--- a/sys/arch/x86/x86/syscall.c Fri Mar 31 08:38:13 2017 +0000
+++ b/sys/arch/x86/x86/syscall.c Fri Mar 31 08:47:04 2017 +0000
@@ -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 @@
{
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;
diff -r 5c0bbaa5fdf9 -r 158b1f61165b sys/kern/kern_fork.c
--- a/sys/kern/kern_fork.c Fri Mar 31 08:38:13 2017 +0000
+++ b/sys/kern/kern_fork.c Fri Mar 31 08:47:04 2017 +0000
@@ -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 @@
(*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.
*/
diff -r 5c0bbaa5fdf9 -r 158b1f61165b sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c Fri Mar 31 08:38:13 2017 +0000
+++ b/sys/kern/kern_sig.c Fri Mar 31 08:47:04 2017 +0000
@@ -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 @@
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 @@
* 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 @@
* 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;
Home |
Main Index |
Thread Index |
Old Index