Deleted Added
full compact
procfs_ctl.c (54292) procfs_ctl.c (69507)
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:
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 54292 1999-12-08 08:59:40Z phk $
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:
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 if (!TRACE_WAIT_P(curp, p))
161 mtx_enter(&sched_lock, MTX_SPIN);
162 if (!TRACE_WAIT_P(curp, p)) {
163 mtx_exit(&sched_lock, MTX_SPIN);
162 return (EBUSY);
164 return (EBUSY);
165 }
166 mtx_exit(&sched_lock, MTX_SPIN);
163 }
164
165
166#ifdef FIX_SSTEP
167 /*
168 * do single-step fixup if needed
169 */
170 FIX_SSTEP(p);

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

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

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

292 error = EOPNOTSUPP;
293
294 nm = vfs_findname(ctlnames, msg, xlen);
295 if (nm) {
296 error = procfs_control(curp, p, nm->nm_val);
297 } else {
298 nm = vfs_findname(signames, msg, xlen);
299 if (nm) {
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);
300 if (TRACE_WAIT_P(curp, p)) {
301 p->p_xstat = nm->nm_val;
302#ifdef FIX_SSTEP
303 FIX_SSTEP(p);
304#endif
305 setrunnable(p);
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);
306 } else {
322 } else {
323 mtx_exit(&sched_lock, MTX_SPIN);
307 psignal(p, nm->nm_val);
308 }
309 error = 0;
310 }
311 }
312
313 return (error);
314}
324 psignal(p, nm->nm_val);
325 }
326 error = 0;
327 }
328 }
329
330 return (error);
331}