Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Add eventswitch() in signal code
details: https://anonhg.NetBSD.org/src/rev/5833119328bc
branches: trunk
changeset: 450973:5833119328bc
user: kamil <kamil%NetBSD.org@localhost>
date: Wed May 01 17:21:55 2019 +0000
description:
Add eventswitch() in signal code
Route all crash and debugger related signal through eventswitch(), that
calls sigswitch() with preprocessed arguments.
This code avoids code duplication and allows to introduce changes that
will affect all callers of sigswitch() in debugger-related events.
No functional change intended.
diffstat:
sys/kern/kern_exec.c | 10 +++-------
sys/kern/kern_fork.c | 22 +++++-----------------
sys/kern/kern_sig.c | 29 ++++++++++++++++++++++-------
sys/sys/signalvar.h | 3 ++-
4 files changed, 32 insertions(+), 32 deletions(-)
diffs (163 lines):
diff -r e0e769f3dfbd -r 5833119328bc sys/kern/kern_exec.c
--- a/sys/kern/kern_exec.c Wed May 01 17:02:40 2019 +0000
+++ b/sys/kern/kern_exec.c Wed May 01 17:21:55 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_exec.c,v 1.462 2018/11/11 10:55:58 maxv Exp $ */
+/* $NetBSD: kern_exec.c,v 1.463 2019/05/01 17:21:55 kamil Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.462 2018/11/11 10:55:58 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.463 2019/05/01 17:21:55 kamil Exp $");
#include "opt_exec.h"
#include "opt_execfmt.h"
@@ -1271,11 +1271,7 @@
if ((p->p_slflag & (PSL_TRACED|PSL_SYSCALL)) == PSL_TRACED) {
mutex_enter(p->p_lock);
- p->p_xsig = SIGTRAP;
- p->p_sigctx.ps_faked = true; // XXX
- p->p_sigctx.ps_info._signo = p->p_xsig;
- p->p_sigctx.ps_info._code = TRAP_EXEC;
- sigswitch(0, SIGTRAP, false);
+ eventswitch(SIGTRAP, TRAP_EXEC);
// XXX ktrpoint(KTR_PSIG)
mutex_exit(p->p_lock);
mutex_enter(proc_lock);
diff -r e0e769f3dfbd -r 5833119328bc sys/kern/kern_fork.c
--- a/sys/kern/kern_fork.c Wed May 01 17:02:40 2019 +0000
+++ b/sys/kern/kern_fork.c Wed May 01 17:21:55 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_fork.c,v 1.209 2019/04/07 14:50:41 kamil Exp $ */
+/* $NetBSD: kern_fork.c,v 1.210 2019/05/01 17:21:55 kamil 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.209 2019/04/07 14:50:41 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.210 2019/05/01 17:21:55 kamil Exp $");
#include "opt_ktrace.h"
#include "opt_dtrace.h"
@@ -575,11 +575,7 @@
*/
if (tracefork || tracevfork) {
mutex_enter(p1->p_lock);
- p1->p_xsig = SIGTRAP;
- p1->p_sigctx.ps_faked = true; // XXX
- p1->p_sigctx.ps_info._signo = p1->p_xsig;
- p1->p_sigctx.ps_info._code = TRAP_CHLD;
- sigswitch(0, SIGTRAP, false);
+ eventswitch(SIGTRAP, TRAP_CHLD);
// XXX ktrpoint(KTR_PSIG)
mutex_exit(p1->p_lock);
mutex_enter(proc_lock);
@@ -597,12 +593,8 @@
*/
if (tracevforkdone) {
mutex_enter(p1->p_lock);
- p1->p_xsig = SIGTRAP;
- p1->p_sigctx.ps_faked = true; // XXX
- p1->p_sigctx.ps_info._signo = p1->p_xsig;
- p1->p_sigctx.ps_info._code = TRAP_CHLD;
p1->p_vfpid_done = retval[0];
- sigswitch(0, SIGTRAP, false);
+ eventswitch(SIGTRAP, TRAP_CHLD);
// XXX ktrpoint(KTR_PSIG)
mutex_exit(p1->p_lock);
// proc_lock unlocked
@@ -627,11 +619,7 @@
}
mutex_enter(p->p_lock);
- p->p_xsig = SIGTRAP;
- p->p_sigctx.ps_faked = true; // XXX
- p->p_sigctx.ps_info._signo = p->p_xsig;
- p->p_sigctx.ps_info._code = TRAP_CHLD;
- sigswitch(0, SIGTRAP, false);
+ eventswitch(SIGTRAP, TRAP_CHLD);
// XXX ktrpoint(KTR_PSIG)
mutex_exit(p->p_lock);
}
diff -r e0e769f3dfbd -r 5833119328bc sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c Wed May 01 17:02:40 2019 +0000
+++ b/sys/kern/kern_sig.c Wed May 01 17:21:55 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_sig.c,v 1.352 2019/04/03 08:34:33 kamil Exp $ */
+/* $NetBSD: kern_sig.c,v 1.353 2019/05/01 17:21:55 kamil 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.352 2019/04/03 08:34:33 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.353 2019/05/01 17:21:55 kamil Exp $");
#include "opt_ptrace.h"
#include "opt_dtrace.h"
@@ -914,11 +914,7 @@
if (ISSET(p->p_slflag, PSL_TRACED) &&
!(p->p_pptr == p->p_opptr && ISSET(p->p_lflag, PL_PPWAIT))) {
- p->p_xsig = signo;
- p->p_sigctx.ps_faked = true; // XXX
- p->p_sigctx.ps_info._signo = signo;
- p->p_sigctx.ps_info._code = ksi->ksi_code;
- sigswitch(0, signo, false);
+ eventswitch(signo, ksi->ksi_code);
// XXX ktrpoint(KTR_PSIG)
mutex_exit(p->p_lock);
return;
@@ -1537,6 +1533,25 @@
}
}
+void
+eventswitch(int signo, int code)
+{
+ struct lwp *l = curlwp;
+ struct proc *p = l->l_proc;
+
+ KASSERT(mutex_owned(proc_lock));
+ KASSERT(mutex_owned(p->p_lock));
+ KASSERT(l->l_stat == LSONPROC);
+ KASSERT(p->p_nrlwps > 0);
+
+ p->p_xsig = signo;
+ p->p_sigctx.ps_faked = true;
+ p->p_sigctx.ps_info._signo = signo;
+ p->p_sigctx.ps_info._code = code;
+
+ sigswitch(0, signo, false);
+}
+
/*
* Stop the current process and switch away when being stopped or traced.
*/
diff -r e0e769f3dfbd -r 5833119328bc sys/sys/signalvar.h
--- a/sys/sys/signalvar.h Wed May 01 17:02:40 2019 +0000
+++ b/sys/sys/signalvar.h Wed May 01 17:21:55 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: signalvar.h,v 1.91 2018/05/20 04:00:35 kamil Exp $ */
+/* $NetBSD: signalvar.h,v 1.92 2019/05/01 17:21:55 kamil Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -136,6 +136,7 @@
void setsigvec(struct proc *, int, struct sigaction *);
int killpg1(struct lwp *, struct ksiginfo *, int, int);
void proc_unstop(struct proc *p);
+void eventswitch(int, int);
void sigswitch(int, int, bool);
Home |
Main Index |
Thread Index |
Old Index