Deleted Added
full compact
procfs_dbregs.c (136004) procfs_dbregs.c (147692)
1/*-
2 * Copyright (c) 1999 Brian Scott Dean, brdean@unx.sas.com.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Jan-Simon Pendry under the following copyrights and conditions:
7 *
8 * Copyright (c) 1993 Jan-Simon Pendry

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

35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 * From: @(#)procfs_regs.c 8.4 (Berkeley) 6/15/94
40 *
41 * From:
42 * $Id: procfs_regs.c,v 3.2 1993/12/15 09:40:17 jsp Exp $
1/*-
2 * Copyright (c) 1999 Brian Scott Dean, brdean@unx.sas.com.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Jan-Simon Pendry under the following copyrights and conditions:
7 *
8 * Copyright (c) 1993 Jan-Simon Pendry

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

35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 * From: @(#)procfs_regs.c 8.4 (Berkeley) 6/15/94
40 *
41 * From:
42 * $Id: procfs_regs.c,v 3.2 1993/12/15 09:40:17 jsp Exp $
43 * $FreeBSD: head/sys/fs/procfs/procfs_dbregs.c 136004 2004-10-01 05:01:17Z das $
43 * $FreeBSD: head/sys/fs/procfs/procfs_dbregs.c 147692 2005-06-30 07:49:22Z peter $
44 */
45
44 */
45
46#include "opt_compat.h"
47
46#include <sys/param.h>
47#include <sys/systm.h>
48#include <sys/lock.h>
49#include <sys/mutex.h>
50#include <sys/proc.h>
51#include <sys/ptrace.h>
52#include <sys/uio.h>
53
54#include <machine/reg.h>
55
56#include <fs/pseudofs/pseudofs.h>
57#include <fs/procfs/procfs.h>
58
48#include <sys/param.h>
49#include <sys/systm.h>
50#include <sys/lock.h>
51#include <sys/mutex.h>
52#include <sys/proc.h>
53#include <sys/ptrace.h>
54#include <sys/uio.h>
55
56#include <machine/reg.h>
57
58#include <fs/pseudofs/pseudofs.h>
59#include <fs/procfs/procfs.h>
60
61#ifdef COMPAT_IA32
62#include <sys/procfs.h>
63#include <machine/fpu.h>
64#include <compat/ia32/ia32_reg.h>
65
66extern struct sysentvec ia32_freebsd_sysvec;
67/*
68 * PROC(write, dbregs, td2, &r) becomes
69 * proc_write_dbregs(td2, &r) or
70 * proc_write_dbregs32(td2, &r32)
71 *
72 * UIOMOVE_FROMBUF(r, uio) becomes
73 * uiomove_frombuf(&r, sizeof(r), uio) or
74 * uiomove_frombuf(&r32, sizeof(r32), uio)
75 */
76#define PROC(d, w, t, r) wrap32 ? \
77 proc_ ## d ## _ ## w ## 32(t, r ## 32) : \
78 proc_ ## d ## _ ## w(t, r)
79#define UIOMOVE_FROMBUF(k, u) wrap32 ? \
80 uiomove_frombuf(& k ## 32, sizeof(k ## 32), u) : \
81 uiomove_frombuf(& k, sizeof(k), u)
82#else
83#define PROC(d, w, t, r) proc_ ## d ## _ ## w(t, r)
84#define UIOMOVE_FROMBUF(k, u) uiomove_frombuf(& k, sizeof(k), u)
85#endif
86
59int
60procfs_doprocdbregs(PFS_FILL_ARGS)
61{
62 int error;
63 struct dbreg r;
87int
88procfs_doprocdbregs(PFS_FILL_ARGS)
89{
90 int error;
91 struct dbreg r;
92 struct thread *td2;
93#ifdef COMPAT_IA32
94 struct dbreg32 r32;
95 int wrap32 = 0;
96#endif
64
65 PROC_LOCK(p);
66 KASSERT(p->p_lock > 0, ("proc not held"));
67 if (p_candebug(td, p) != 0) {
68 PROC_UNLOCK(p);
69 return (EPERM);
70 }
71
72 /* XXXKSE: */
97
98 PROC_LOCK(p);
99 KASSERT(p->p_lock > 0, ("proc not held"));
100 if (p_candebug(td, p) != 0) {
101 PROC_UNLOCK(p);
102 return (EPERM);
103 }
104
105 /* XXXKSE: */
73 error = proc_read_dbregs(FIRST_THREAD_IN_PROC(p), &r);
106 td2 = FIRST_THREAD_IN_PROC(p);
107#ifdef COMPAT_IA32
108 if (td->td_proc->p_sysent == &ia32_freebsd_sysvec) {
109 if (td2->td_proc->p_sysent != &ia32_freebsd_sysvec) {
110 PROC_UNLOCK(p);
111 return (EINVAL);
112 }
113 wrap32 = 1;
114 }
115#endif
116 error = PROC(read, dbregs, td2, &r);
74 if (error == 0) {
75 PROC_UNLOCK(p);
117 if (error == 0) {
118 PROC_UNLOCK(p);
76 error = uiomove_frombuf(&r, sizeof(r), uio);
119 error = UIOMOVE_FROMBUF(r, uio);
77 PROC_LOCK(p);
78 }
79 if (error == 0 && uio->uio_rw == UIO_WRITE) {
80 if (!P_SHOULDSTOP(p)) /* XXXKSE should be P_TRACED? */
81 error = EBUSY;
82 else
83 /* XXXKSE: */
120 PROC_LOCK(p);
121 }
122 if (error == 0 && uio->uio_rw == UIO_WRITE) {
123 if (!P_SHOULDSTOP(p)) /* XXXKSE should be P_TRACED? */
124 error = EBUSY;
125 else
126 /* XXXKSE: */
84 error = proc_write_dbregs(FIRST_THREAD_IN_PROC(p), &r);
127 error = PROC(write, dbregs, td2, &r);
85 }
86 PROC_UNLOCK(p);
87
88 uio->uio_offset = 0;
89 return (error);
90}
128 }
129 PROC_UNLOCK(p);
130
131 uio->uio_offset = 0;
132 return (error);
133}