version 1.319.6.6, 2017/02/05 13:40:56 |
version 1.319.6.7, 2017/08/28 17:53:07 |
Line 83 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 83 __KERNEL_RCSID(0, "$NetBSD$"); |
|
#include <sys/param.h> |
#include <sys/param.h> |
#include <sys/signalvar.h> |
#include <sys/signalvar.h> |
#include <sys/proc.h> |
#include <sys/proc.h> |
|
#include <sys/ptrace.h> |
#include <sys/systm.h> |
#include <sys/systm.h> |
#include <sys/wait.h> |
#include <sys/wait.h> |
#include <sys/ktrace.h> |
#include <sys/ktrace.h> |
Line 116 static sigset_t stopsigmask __cacheline |
|
Line 117 static sigset_t stopsigmask __cacheline |
|
sigset_t sigcantmask __cacheline_aligned; |
sigset_t sigcantmask __cacheline_aligned; |
|
|
static void ksiginfo_exechook(struct proc *, void *); |
static void ksiginfo_exechook(struct proc *, void *); |
|
static void proc_stop(struct proc *, int); |
static void proc_stop_callout(void *); |
static void proc_stop_callout(void *); |
static int sigchecktrace(void); |
static int sigchecktrace(void); |
static int sigpost(struct lwp *, sig_t, int, int); |
static int sigpost(struct lwp *, sig_t, int, int); |
Line 345 siginit(struct proc *p) |
|
Line 347 siginit(struct proc *p) |
|
*/ |
*/ |
l = LIST_FIRST(&p->p_lwps); |
l = LIST_FIRST(&p->p_lwps); |
l->l_sigwaited = NULL; |
l->l_sigwaited = NULL; |
l->l_sigstk.ss_flags = SS_DISABLE; |
l->l_sigstk = SS_INIT; |
l->l_sigstk.ss_size = 0; |
|
l->l_sigstk.ss_sp = 0; |
|
ksiginfo_queue_init(&l->l_sigpend.sp_info); |
ksiginfo_queue_init(&l->l_sigpend.sp_info); |
sigemptyset(&l->l_sigpend.sp_set); |
sigemptyset(&l->l_sigpend.sp_set); |
|
|
Line 415 execsigs(struct proc *p) |
|
Line 415 execsigs(struct proc *p) |
|
*/ |
*/ |
l = LIST_FIRST(&p->p_lwps); |
l = LIST_FIRST(&p->p_lwps); |
l->l_sigwaited = NULL; |
l->l_sigwaited = NULL; |
l->l_sigstk.ss_flags = SS_DISABLE; |
l->l_sigstk = SS_INIT; |
l->l_sigstk.ss_size = 0; |
|
l->l_sigstk.ss_sp = 0; |
|
ksiginfo_queue_init(&l->l_sigpend.sp_info); |
ksiginfo_queue_init(&l->l_sigpend.sp_info); |
sigemptyset(&l->l_sigpend.sp_set); |
sigemptyset(&l->l_sigpend.sp_set); |
mutex_exit(p->p_lock); |
mutex_exit(p->p_lock); |
Line 1222 kpsignal2(struct proc *p, ksiginfo_t *ks |
|
Line 1220 kpsignal2(struct proc *p, ksiginfo_t *ks |
|
ksiginfo_t *kp; |
ksiginfo_t *kp; |
lwpid_t lid; |
lwpid_t lid; |
sig_t action; |
sig_t action; |
bool toall; |
bool toall, debtrap = false; |
int error = 0; |
int error = 0; |
|
|
KASSERT(!cpu_intr_p()); |
KASSERT(!cpu_intr_p()); |
Line 1235 kpsignal2(struct proc *p, ksiginfo_t *ks |
|
Line 1233 kpsignal2(struct proc *p, ksiginfo_t *ks |
|
* If the process is being created by fork, is a zombie or is |
* If the process is being created by fork, is a zombie or is |
* exiting, then just drop the signal here and bail out. |
* 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; |
return 0; |
|
} |
|
|
/* XXX for core dump/debugger */ |
/* XXX for core dump/debugger */ |
p->p_sigctx.ps_lwp = ksi->ksi_lid; |
p->p_sigctx.ps_lwp = ksi->ksi_lid; |
Line 1351 kpsignal2(struct proc *p, ksiginfo_t *ks |
|
Line 1354 kpsignal2(struct proc *p, ksiginfo_t *ks |
|
* the signal to it. |
* the signal to it. |
*/ |
*/ |
if (lid != 0) { |
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 (l != NULL) { |
if ((error = sigput(&l->l_sigpend, p, kp)) != 0) |
if ((error = sigput(&l->l_sigpend, p, kp)) != 0) |
goto out; |
goto out; |
Line 1535 sigswitch(bool ppsig, int ppmask, int si |
|
Line 1544 sigswitch(bool ppsig, int ppmask, int si |
|
*/ |
*/ |
if (p->p_stat == SACTIVE && (p->p_sflag & PS_STOPPING) == 0) { |
if (p->p_stat == SACTIVE && (p->p_sflag & PS_STOPPING) == 0) { |
KASSERT(signo != 0); |
KASSERT(signo != 0); |
proc_stop(p, 1, signo); |
proc_stop(p, signo); |
KASSERT(p->p_nrlwps > 0); |
KASSERT(p->p_nrlwps > 0); |
} |
} |
|
|
Line 2099 sigexit(struct lwp *l, int signo) |
|
Line 2108 sigexit(struct lwp *l, int signo) |
|
* Put process 'p' into the stopped state and optionally, notify the parent. |
* Put process 'p' into the stopped state and optionally, notify the parent. |
*/ |
*/ |
void |
void |
proc_stop(struct proc *p, int notify, int signo) |
proc_stop(struct proc *p, int signo) |
{ |
{ |
struct lwp *l; |
struct lwp *l; |
|
|
Line 2110 proc_stop(struct proc *p, int notify, in |
|
Line 2119 proc_stop(struct proc *p, int notify, in |
|
* LWPs to a halt so they are included in p->p_nrlwps. We musn't |
* LWPs to a halt so they are included in p->p_nrlwps. We musn't |
* unlock between here and the p->p_nrlwps check below. |
* unlock between here and the p->p_nrlwps check below. |
*/ |
*/ |
p->p_sflag |= PS_STOPPING; |
p->p_sflag |= PS_STOPPING | PS_NOTIFYSTOP; |
if (notify) |
|
p->p_sflag |= PS_NOTIFYSTOP; |
|
else |
|
p->p_sflag &= ~PS_NOTIFYSTOP; |
|
membar_producer(); |
membar_producer(); |
|
|
proc_stop_lwps(p); |
proc_stop_lwps(p); |
Line 2258 proc_unstop(struct proc *p) |
|
Line 2263 proc_unstop(struct proc *p) |
|
} |
} |
} |
} |
|
|
|
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 |
static int |
filt_sigattach(struct knote *kn) |
filt_sigattach(struct knote *kn) |
{ |
{ |