From: mpi Date: Mon, 10 May 2021 18:01:24 +0000 (+0000) Subject: Revert previous, it introduced a regression with breakpoints in gdb. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=0fbe85fcb67ac9a5fb576922ef3d54cf4b9dc5da;p=openbsd Revert previous, it introduced a regression with breakpoints in gdb. --- diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index f92de3126f9..80952582fb5 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig.c,v 1.280 2021/05/06 09:33:22 mpi Exp $ */ +/* $OpenBSD: kern_sig.c,v 1.281 2021/05/10 18:01:24 mpi Exp $ */ /* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */ /* @@ -124,7 +124,7 @@ const int sigprop[NSIG + 1] = { void setsigvec(struct proc *, int, struct sigaction *); -int proc_stop(struct proc *p, int, int); +void proc_stop(struct proc *p, int); void proc_stop_sweep(void *); void *proc_stop_si; @@ -1061,7 +1061,8 @@ ptsignal(struct proc *p, int signum, enum signal_type type) if (pr->ps_flags & PS_PPWAIT) goto out; atomic_clearbits_int(siglist, mask); - proc_stop(p, signum, 0); + pr->ps_xsig = signum; + proc_stop(p, 0); goto out; } /* @@ -1169,12 +1170,17 @@ out: * * while (signum = cursig(curproc)) * postsig(signum); + * + * Assumes that if the P_SINTR flag is set, we're holding both the + * kernel and scheduler locks. */ int cursig(struct proc *p) { struct process *pr = p->p_p; int sigpending, signum, mask, prop; + int dolock = (p->p_flag & P_SINTR) == 0; + int s; KERNEL_ASSERT_LOCKED(); @@ -1211,22 +1217,31 @@ cursig(struct proc *p) */ if (((pr->ps_flags & (PS_TRACED | PS_PPWAIT)) == PS_TRACED) && signum != SIGKILL) { + pr->ps_xsig = signum; single_thread_set(p, SINGLE_SUSPEND, 0); - signum = proc_stop(p, signum, 1); + + if (dolock) + SCHED_LOCK(s); + proc_stop(p, 1); + if (dolock) + SCHED_UNLOCK(s); + single_thread_clear(p, 0); /* * If we are no longer being traced, or the parent * didn't give us a signal, look for more signals. */ - if ((pr->ps_flags & PS_TRACED) == 0 || signum == 0) + if ((pr->ps_flags & PS_TRACED) == 0 || + pr->ps_xsig == 0) continue; /* * If the new signal is being masked, look for other * signals. */ + signum = pr->ps_xsig; mask = sigmask(signum); if ((p->p_sigmask & mask) != 0) continue; @@ -1271,7 +1286,12 @@ cursig(struct proc *p) (pr->ps_pgrp->pg_jobc == 0 && prop & SA_TTYSTOP)) break; /* == ignore */ - proc_stop(p, signum, 1); + pr->ps_xsig = signum; + if (dolock) + SCHED_LOCK(s); + proc_stop(p, 1); + if (dolock) + SCHED_UNLOCK(s); break; } else if (prop & SA_IGNORE) { /* @@ -1311,21 +1331,15 @@ keep: * Put the argument process into the stopped state and notify the parent * via wakeup. Signals are handled elsewhere. The process must not be * on the run queue. - * - * Assumes that if the P_SINTR flag is set, we're holding the scheduler - * lock. */ -int -proc_stop(struct proc *p, int signum, int sw) +void +proc_stop(struct proc *p, int sw) { struct process *pr = p->p_p; - int dolock = (p->p_flag & P_SINTR) == 0; - int s; - - pr->ps_xsig = signum; - if (dolock) - SCHED_LOCK(s); +#ifdef MULTIPROCESSOR + SCHED_ASSERT_LOCKED(); +#endif p->p_stat = SSTOP; atomic_clearbits_int(&pr->ps_flags, PS_WAITED); @@ -1338,11 +1352,6 @@ proc_stop(struct proc *p, int signum, int sw) softintr_schedule(proc_stop_si); if (sw) mi_switch(); - - if (dolock) - SCHED_UNLOCK(s); - - return pr->ps_xsig; } /* @@ -1367,27 +1376,6 @@ proc_stop_sweep(void *v) } } -void -proc_unstop(struct proc *p, int signum) -{ - struct process *pr = p->p_p; - - KASSERT(signum >= 0); - KASSERT(p->p_stat == SSTOP); - - if (signum != 0) - pr->ps_xsig = signum; - - /* - * If we're being traced (possibly because someone attached us - * while we were stopped), check for a signal from the debugger. - */ - if ((pr->ps_flags & PS_TRACED) != 0 && pr->ps_xsig != 0) - atomic_setbits_int(&p->p_siglist, sigmask(pr->ps_xsig)); - - setrunnable(p); -} - /* * Take the action for the specified signal * from the current set of pending signals. @@ -2054,7 +2042,7 @@ single_thread_set(struct proc *p, enum single_thread_mode mode, int wait) if (q->p_flag & P_WEXIT) { if (mode == SINGLE_EXIT) { if (q->p_stat == SSTOP) { - proc_unstop(q, 0); + setrunnable(q); atomic_inc_int(&pr->ps_singlecount); } } @@ -2081,7 +2069,7 @@ single_thread_set(struct proc *p, enum single_thread_mode mode, int wait) break; case SSTOP: if (mode == SINGLE_EXIT) { - proc_unstop(q, 0); + setrunnable(q); atomic_inc_int(&pr->ps_singlecount); } break; @@ -2150,7 +2138,7 @@ single_thread_clear(struct proc *p, int flag) */ if (q->p_stat == SSTOP && (q->p_flag & flag) == 0) { if (q->p_wchan == 0) - proc_unstop(q, 0); + setrunnable(q); else q->p_stat = SSLEEP; } diff --git a/sys/kern/sched_bsd.c b/sys/kern/sched_bsd.c index 015d3b5fa91..f0bb6ef7228 100644 --- a/sys/kern/sched_bsd.c +++ b/sys/kern/sched_bsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sched_bsd.c,v 1.66 2021/05/06 09:33:22 mpi Exp $ */ +/* $OpenBSD: sched_bsd.c,v 1.67 2021/05/10 18:01:24 mpi Exp $ */ /* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */ /*- @@ -456,6 +456,12 @@ setrunnable(struct proc *p) default: panic("setrunnable"); case SSTOP: + /* + * If we're being traced (possibly because someone attached us + * while we were stopped), check for a signal from the debugger. + */ + if ((pr->ps_flags & PS_TRACED) != 0 && pr->ps_xsig != 0) + atomic_setbits_int(&p->p_siglist, sigmask(pr->ps_xsig)); prio = p->p_usrpri; unsleep(p); break; diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 20bfd33f203..e5056ccdcc7 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_process.c,v 1.87 2021/05/06 09:33:22 mpi Exp $ */ +/* $OpenBSD: sys_process.c,v 1.88 2021/05/10 18:01:24 mpi Exp $ */ /* $NetBSD: sys_process.c,v 1.55 1996/05/15 06:17:47 tls Exp $ */ /*- @@ -484,8 +484,9 @@ ptrace_ctrl(struct proc *p, int req, pid_t pid, caddr_t addr, int data) /* Finally, deliver the requested signal (or none). */ if (t->p_stat == SSTOP) { + tr->ps_xsig = data; SCHED_LOCK(s); - proc_unstop(t, data); + setrunnable(t); SCHED_UNLOCK(s); } else { if (data != 0) diff --git a/sys/sys/signalvar.h b/sys/sys/signalvar.h index 934768a5112..fb97fb252a7 100644 --- a/sys/sys/signalvar.h +++ b/sys/sys/signalvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: signalvar.h,v 1.47 2021/05/06 09:33:22 mpi Exp $ */ +/* $OpenBSD: signalvar.h,v 1.48 2021/05/10 18:01:24 mpi Exp $ */ /* $NetBSD: signalvar.h,v 1.17 1996/04/22 01:23:31 christos Exp $ */ /* @@ -103,7 +103,6 @@ struct sigio_ref; /* * Machine-independent functions: */ -void proc_unstop(struct proc *, int); int coredump(struct proc *p); void execsigs(struct proc *p); int cursig(struct proc *p);