Deleted Added
sdiff udiff text old ( 54292 ) new ( 69507 )
full compact
1/*
2 * Copyright (c) 1993 Jan-Simon Pendry
3 * Copyright (c) 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Jan-Simon Pendry.
8 *

--- 23 unchanged lines hidden (view full) ---

32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 * @(#)procfs_ctl.c 8.4 (Berkeley) 6/15/94
38 *
39 * From:
40 * $FreeBSD: head/sys/fs/procfs/procfs_ctl.c 69507 2000-12-02 01:58:15Z jhb $
41 */
42
43#include <sys/param.h>
44#include <sys/systm.h>
45#include <sys/proc.h>
46#include <sys/vnode.h>
47#include <sys/ptrace.h>
48#include <sys/signalvar.h>

--- 104 unchanged lines hidden (view full) ---

153 * Allow WAIT any time, of course.
154 */
155 switch (op) {
156 case PROCFS_CTL_DETACH:
157 case PROCFS_CTL_WAIT:
158 break;
159
160 default:
161 mtx_enter(&sched_lock, MTX_SPIN);
162 if (!TRACE_WAIT_P(curp, p)) {
163 mtx_exit(&sched_lock, MTX_SPIN);
164 return (EBUSY);
165 }
166 mtx_exit(&sched_lock, MTX_SPIN);
167 }
168
169
170#ifdef FIX_SSTEP
171 /*
172 * do single-step fixup if needed
173 */
174 FIX_SSTEP(p);

--- 58 unchanged lines hidden (view full) ---

233 /*
234 * Wait for the target process to stop.
235 * If the target is not being traced then just wait
236 * to enter
237 */
238 case PROCFS_CTL_WAIT:
239 error = 0;
240 if (p->p_flag & P_TRACED) {
241 mtx_enter(&sched_lock, MTX_SPIN);
242 while (error == 0 &&
243 (p->p_stat != SSTOP) &&
244 (p->p_flag & P_TRACED) &&
245 (p->p_pptr == curp)) {
246 mtx_exit(&sched_lock, MTX_SPIN);
247 error = tsleep((caddr_t) p,
248 PWAIT|PCATCH, "procfsx", 0);
249 mtx_enter(&sched_lock, MTX_SPIN);
250 }
251 if (error == 0 && !TRACE_WAIT_P(curp, p))
252 error = EBUSY;
253 mtx_exit(&sched_lock, MTX_SPIN);
254 } else {
255 mtx_enter(&sched_lock, MTX_SPIN);
256 while (error == 0 && p->p_stat != SSTOP) {
257 mtx_exit(&sched_lock, MTX_SPIN);
258 error = tsleep((caddr_t) p,
259 PWAIT|PCATCH, "procfs", 0);
260 mtx_enter(&sched_lock, MTX_SPIN);
261 }
262 mtx_exit(&sched_lock, MTX_SPIN);
263 }
264 return (error);
265
266 default:
267 panic("procfs_control");
268 }
269
270 mtx_enter(&sched_lock, MTX_SPIN);
271 if (p->p_stat == SSTOP)
272 setrunnable(p);
273 mtx_exit(&sched_lock, MTX_SPIN);
274 return (0);
275}
276
277int
278procfs_doctl(curp, p, pfs, uio)
279 struct proc *curp;
280 struct pfsnode *pfs;
281 struct uio *uio;

--- 24 unchanged lines hidden (view full) ---

306 error = EOPNOTSUPP;
307
308 nm = vfs_findname(ctlnames, msg, xlen);
309 if (nm) {
310 error = procfs_control(curp, p, nm->nm_val);
311 } else {
312 nm = vfs_findname(signames, msg, xlen);
313 if (nm) {
314 mtx_enter(&sched_lock, MTX_SPIN);
315 if (TRACE_WAIT_P(curp, p)) {
316 p->p_xstat = nm->nm_val;
317#ifdef FIX_SSTEP
318 FIX_SSTEP(p);
319#endif
320 setrunnable(p);
321 mtx_exit(&sched_lock, MTX_SPIN);
322 } else {
323 mtx_exit(&sched_lock, MTX_SPIN);
324 psignal(p, nm->nm_val);
325 }
326 error = 0;
327 }
328 }
329
330 return (error);
331}