Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Instead of copying parts of sigswitch to process_stoptra...
details: https://anonhg.NetBSD.org/src/rev/9acf62c3a220
branches: trunk
changeset: 352297:9acf62c3a220
user: christos <christos%NetBSD.org@localhost>
date: Fri Mar 24 17:40:44 2017 +0000
description:
Instead of copying parts of sigswitch to process_stoptrace, use it directly.
Rename process_stoptrace -> proc_stoptrace and put it in kern_sig.c so we
don't need to expose any more functions from it.
diffstat:
sys/kern/kern_sig.c | 33 ++++++++++++++++++++++++++++-----
sys/kern/kern_syscall.c | 8 ++++----
sys/kern/sys_process.c | 42 ++----------------------------------------
sys/sys/proc.h | 3 +--
sys/sys/ptrace.h | 5 ++---
5 files changed, 37 insertions(+), 54 deletions(-)
diffs (224 lines):
diff -r 5ea97a7ab373 -r 9acf62c3a220 sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c Fri Mar 24 17:09:36 2017 +0000
+++ b/sys/kern/kern_sig.c Fri Mar 24 17:40:44 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_sig.c,v 1.333 2017/03/23 21:59:55 christos Exp $ */
+/* $NetBSD: kern_sig.c,v 1.334 2017/03/24 17:40:44 christos 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.333 2017/03/23 21:59:55 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.334 2017/03/24 17:40:44 christos Exp $");
#include "opt_ptrace.h"
#include "opt_dtrace.h"
@@ -83,6 +83,7 @@
#include <sys/param.h>
#include <sys/signalvar.h>
#include <sys/proc.h>
+#include <sys/ptrace.h>
#include <sys/systm.h>
#include <sys/wait.h>
#include <sys/ktrace.h>
@@ -116,6 +117,7 @@
sigset_t sigcantmask __cacheline_aligned;
static void ksiginfo_exechook(struct proc *, void *);
+static void proc_stop(struct proc *, int);
static void proc_stop_callout(void *);
static int sigchecktrace(void);
static int sigpost(struct lwp *, sig_t, int, int);
@@ -1535,7 +1537,7 @@
*/
if (p->p_stat == SACTIVE && (p->p_sflag & PS_STOPPING) == 0) {
KASSERT(signo != 0);
- proc_stop(p, 0, signo);
+ proc_stop(p, signo);
KASSERT(p->p_nrlwps > 0);
}
@@ -2099,7 +2101,7 @@
* Put process 'p' into the stopped state and optionally, notify the parent.
*/
void
-proc_stop(struct proc *p, int now, int signo)
+proc_stop(struct proc *p, int signo)
{
struct lwp *l;
@@ -2121,7 +2123,7 @@
* LWP to stop will take care of it.
*/
- if (p->p_nrlwps == 0 || (now && p->p_nrlwps == 1 && p == curproc)) {
+ if (p->p_nrlwps == 0) {
proc_stop_done(p, true, PS_NOCLDSTOP);
} else {
/*
@@ -2254,6 +2256,27 @@
}
}
+void
+proc_stoptrace(int trapno)
+{
+ struct lwp *l = curlwp;
+ struct proc *p = l->l_proc, *pp;
+
+ mutex_enter(p->p_lock);
+ pp = p->p_pptr;
+ if (pp->p_pid == 1) {
+ CLR(p->p_slflag, PSL_SYSCALL); /* XXXSMP */
+ mutex_exit(p->p_lock);
+ return;
+ }
+
+ p->p_xsig = SIGTRAP;
+ p->p_sigctx.ps_info._signo = p->p_xsig;
+ p->p_sigctx.ps_info._code = trapno;
+ sigswitch(true, 0, p->p_xsig);
+ mutex_exit(p->p_lock);
+}
+
static int
filt_sigattach(struct knote *kn)
{
diff -r 5ea97a7ab373 -r 9acf62c3a220 sys/kern/kern_syscall.c
--- a/sys/kern/kern_syscall.c Fri Mar 24 17:09:36 2017 +0000
+++ b/sys/kern/kern_syscall.c Fri Mar 24 17:40:44 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_syscall.c,v 1.15 2017/03/23 21:59:55 christos Exp $ */
+/* $NetBSD: kern_syscall.c,v 1.16 2017/03/24 17:40:44 christos Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_syscall.c,v 1.15 2017/03/23 21:59:55 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_syscall.c,v 1.16 2017/03/24 17:40:44 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_modular.h"
@@ -248,7 +248,7 @@
#ifdef PTRACE
if ((curlwp->l_proc->p_slflag & (PSL_SYSCALL|PSL_TRACED)) ==
(PSL_SYSCALL|PSL_TRACED)) {
- process_stoptrace(TRAP_SCE);
+ proc_stoptrace(TRAP_SCE);
if (curlwp->l_proc->p_slflag & PSL_SYSCALLEMU) {
/* tracer will emulate syscall for us */
error = EJUSTRETURN;
@@ -289,7 +289,7 @@
#ifdef PTRACE
if ((p->p_slflag & (PSL_SYSCALL|PSL_TRACED|PSL_SYSCALLEMU)) ==
(PSL_SYSCALL|PSL_TRACED)) {
- process_stoptrace(TRAP_SCX);
+ proc_stoptrace(TRAP_SCX);
}
CLR(p->p_slflag, PSL_SYSCALLEMU);
#endif
diff -r 5ea97a7ab373 -r 9acf62c3a220 sys/kern/sys_process.c
--- a/sys/kern/sys_process.c Fri Mar 24 17:09:36 2017 +0000
+++ b/sys/kern/sys_process.c Fri Mar 24 17:40:44 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_process.c,v 1.177 2017/03/23 21:59:55 christos Exp $ */
+/* $NetBSD: sys_process.c,v 1.178 2017/03/24 17:40:44 christos Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -118,7 +118,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_process.c,v 1.177 2017/03/23 21:59:55 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_process.c,v 1.178 2017/03/24 17:40:44 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_ptrace.h"
@@ -185,44 +185,6 @@
#endif
return error;
}
-
-void
-process_stoptrace(int trapno)
-{
- struct lwp *l = curlwp;
- struct proc *p = l->l_proc, *pp;
-
- mutex_enter(p->p_lock);
- mutex_enter(proc_lock);
- pp = p->p_pptr;
- if (pp->p_pid == 1) {
- CLR(p->p_slflag, PSL_SYSCALL); /* XXXSMP */
- mutex_exit(p->p_lock);
- mutex_exit(proc_lock);
- return;
- }
-
- p->p_sigctx.ps_info._signo = SIGTRAP;
- p->p_sigctx.ps_info._code = trapno;
- p->p_xsig = SIGTRAP;
- proc_stop(p, 1, SIGSTOP);
- mutex_exit(proc_lock);
-
- if (sigispending(l, 0)) {
- lwp_lock(l);
- l->l_flag |= LW_PENDSIG;
- lwp_unlock(l);
- }
- /* Switch and wait until we come to a stop */
- do {
- mutex_exit(p->p_lock);
- lwp_lock(l);
- mi_switch(l);
- mutex_enter(p->p_lock);
- } while (p->p_sflag & PS_STOPPING);
-
- mutex_exit(p->p_lock);
-}
#endif /* KTRACE || PTRACE_HOOKS */
/*
diff -r 5ea97a7ab373 -r 9acf62c3a220 sys/sys/proc.h
--- a/sys/sys/proc.h Fri Mar 24 17:09:36 2017 +0000
+++ b/sys/sys/proc.h Fri Mar 24 17:40:44 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: proc.h,v 1.338 2017/02/23 03:34:23 kamil Exp $ */
+/* $NetBSD: proc.h,v 1.339 2017/03/24 17:40:44 christos Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -538,7 +538,6 @@
void child_return(void *);
int proc_isunder(struct proc *, struct lwp *);
-void proc_stop(struct proc *, int, int);
int proc_uidmatch(kauth_cred_t, kauth_cred_t);
int proc_vmspace_getref(struct proc *, struct vmspace **);
diff -r 5ea97a7ab373 -r 9acf62c3a220 sys/sys/ptrace.h
--- a/sys/sys/ptrace.h Fri Mar 24 17:09:36 2017 +0000
+++ b/sys/sys/ptrace.h Fri Mar 24 17:40:44 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ptrace.h,v 1.59 2017/03/23 21:59:54 christos Exp $ */
+/* $NetBSD: ptrace.h,v 1.60 2017/03/24 17:40:44 christos Exp $ */
/*-
* Copyright (c) 1984, 1993
@@ -208,8 +208,7 @@
int process_domem(struct lwp *, struct lwp *, struct uio *);
-void process_stoptrace(int);
-
+void proc_stoptrace(int);
void proc_reparent(struct proc *, struct proc *);
void proc_changeparent(struct proc *, struct proc *);
Home |
Main Index |
Thread Index |
Old Index