summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/alpha/alpha/process_machdep.c44
-rw-r--r--sys/arch/hppa/hppa/process_machdep.c17
-rw-r--r--sys/arch/i386/i386/process_machdep.c6
-rw-r--r--sys/arch/m68k/m68k/process_machdep.c29
-rw-r--r--sys/arch/mvme88k/mvme88k/process_machdep.c41
-rw-r--r--sys/arch/powerpc/powerpc/process_machdep.c50
-rw-r--r--sys/arch/sparc/sparc/process_machdep.c47
-rw-r--r--sys/arch/sparc64/sparc64/process_machdep.c64
-rw-r--r--sys/arch/vax/vax/machdep.c6
-rw-r--r--sys/compat/bsdos/syscalls.master6
-rw-r--r--sys/compat/freebsd/files.freebsd4
-rw-r--r--sys/compat/freebsd/syscalls.master6
-rw-r--r--sys/compat/hpux/hpux_compat.c6
-rw-r--r--sys/compat/hpux/syscalls.master6
-rw-r--r--sys/compat/linux/linux_dummy.c4
-rw-r--r--sys/compat/linux/syscalls.master6
-rw-r--r--sys/compat/netbsd/syscalls.master6
-rw-r--r--sys/compat/sunos/sunos_misc.c12
-rw-r--r--sys/compat/sunos/syscalls.master6
-rw-r--r--sys/conf/GENERIC3
-rw-r--r--sys/conf/files8
-rw-r--r--sys/kern/syscalls.master6
-rw-r--r--sys/miscfs/procfs/README11
-rw-r--r--sys/miscfs/procfs/procfs_ctl.c15
-rw-r--r--sys/miscfs/procfs/procfs_subr.c4
-rw-r--r--sys/miscfs/procfs/procfs_vnops.c15
26 files changed, 256 insertions, 172 deletions
diff --git a/sys/arch/alpha/alpha/process_machdep.c b/sys/arch/alpha/alpha/process_machdep.c
index 4e15522218f..5de30a17b88 100644
--- a/sys/arch/alpha/alpha/process_machdep.c
+++ b/sys/arch/alpha/alpha/process_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: process_machdep.c,v 1.6 2002/03/12 11:58:14 art Exp $ */
+/* $OpenBSD: process_machdep.c,v 1.7 2002/03/14 00:42:20 miod Exp $ */
/* $NetBSD: process_machdep.c,v 1.7 1996/07/11 20:14:21 cgd Exp $ */
/*-
@@ -108,6 +108,24 @@ process_read_regs(p, regs)
}
int
+process_read_fpregs(p, regs)
+ struct proc *p;
+ struct fpreg *regs;
+{
+
+ if (p == fpcurproc) {
+ alpha_pal_wrfen(1);
+ savefpstate(process_fpframe(p));
+ alpha_pal_wrfen(0);
+ }
+
+ bcopy(process_fpframe(p), regs, sizeof(struct fpreg));
+ return (0);
+}
+
+#ifdef PTRACE
+
+int
process_write_regs(p, regs)
struct proc *p;
struct reg *regs;
@@ -120,29 +138,25 @@ process_write_regs(p, regs)
}
int
-process_set_pc(p, addr)
+process_sstep(p, sstep)
struct proc *p;
- caddr_t addr;
+ int sstep;
{
- struct trapframe *frame = process_frame(p);
- frame->tf_regs[FRAME_PC] = (u_int64_t)addr;
+ if (sstep)
+ return (EINVAL);
+
return (0);
}
int
-process_read_fpregs(p, regs)
+process_set_pc(p, addr)
struct proc *p;
- struct fpreg *regs;
+ caddr_t addr;
{
+ struct trapframe *frame = process_frame(p);
- if (p == fpcurproc) {
- alpha_pal_wrfen(1);
- savefpstate(process_fpframe(p));
- alpha_pal_wrfen(0);
- }
-
- bcopy(process_fpframe(p), regs, sizeof(struct fpreg));
+ frame->tf_regs[FRAME_PC] = (u_int64_t)addr;
return (0);
}
@@ -348,3 +362,5 @@ process_sstep(struct proc *p, int sstep)
return (0);
}
+
+#endif /* PTRACE */
diff --git a/sys/arch/hppa/hppa/process_machdep.c b/sys/arch/hppa/hppa/process_machdep.c
index afe2e97dcc4..324f5fec427 100644
--- a/sys/arch/hppa/hppa/process_machdep.c
+++ b/sys/arch/hppa/hppa/process_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: process_machdep.c,v 1.3 1999/06/18 05:19:52 mickey Exp $ */
+/* $OpenBSD: process_machdep.c,v 1.4 2002/03/14 00:42:24 miod Exp $ */
/*
* Copyright (c) 1999 Michael Shalayeff
@@ -48,20 +48,22 @@ process_read_regs(p, regs)
}
int
-process_write_regs(p, regs)
+process_read_fpregs(p, fpregs)
struct proc *p;
- struct reg *regs;
+ struct fpreg *fpregs;
{
- bcopy (&regs[1], &p->p_md.md_regs->tf_r1, sizeof(*regs) - sizeof(*regs));
+ bcopy (p->p_addr->u_pcb.pcb_fpregs, fpregs, sizeof(*fpregs));
return 0;
}
+#ifdef PTRACE
+
int
-process_read_fpregs(p, fpregs)
+process_write_regs(p, regs)
struct proc *p;
- struct fpreg *fpregs;
+ struct reg *regs;
{
- bcopy (p->p_addr->u_pcb.pcb_fpregs, fpregs, sizeof(*fpregs));
+ bcopy (&regs[1], &p->p_md.md_regs->tf_r1, sizeof(*regs) - sizeof(*regs));
return 0;
}
@@ -94,3 +96,4 @@ process_set_pc(p, addr)
return 0;
}
+#endif /* PTRACE */
diff --git a/sys/arch/i386/i386/process_machdep.c b/sys/arch/i386/i386/process_machdep.c
index 26c441dc8d3..7897ee4bf8c 100644
--- a/sys/arch/i386/i386/process_machdep.c
+++ b/sys/arch/i386/i386/process_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: process_machdep.c,v 1.8 2002/02/18 23:26:18 mickey Exp $ */
+/* $OpenBSD: process_machdep.c,v 1.9 2002/03/14 00:42:24 miod Exp $ */
/* $NetBSD: process_machdep.c,v 1.22 1996/05/03 19:42:25 christos Exp $ */
/*
@@ -160,6 +160,8 @@ process_read_fpregs(p, regs)
return (0);
}
+#ifdef PTRACE
+
int
process_write_regs(p, regs)
struct proc *p;
@@ -271,3 +273,5 @@ process_set_pc(p, addr)
return (0);
}
+
+#endif /* PTRACE */
diff --git a/sys/arch/m68k/m68k/process_machdep.c b/sys/arch/m68k/m68k/process_machdep.c
index e5ab757693b..172df418e0b 100644
--- a/sys/arch/m68k/m68k/process_machdep.c
+++ b/sys/arch/m68k/m68k/process_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: process_machdep.c,v 1.4 2001/06/23 05:40:57 art Exp $ */
+/* $OpenBSD: process_machdep.c,v 1.5 2002/03/14 00:42:24 miod Exp $ */
/* $NetBSD: process_machdep.c,v 1.17 1996/05/06 20:05:24 gwr Exp $ */
/*
@@ -63,27 +63,8 @@
#include <machine/psl.h>
#include <machine/reg.h>
-static __inline struct frame *process_frame __P((struct proc *p));
-static __inline struct fpframe *process_fpframe __P((struct proc *p));
-
-static __inline struct frame *
-process_frame(p)
- struct proc *p;
-{
- void *ptr;
-
- ptr = p->p_md.md_regs;
-
- return (ptr);
-}
-
-static __inline struct fpframe *
-process_fpframe(p)
- struct proc *p;
-{
-
- return (&p->p_addr->u_pcb.pcb_fpregs);
-}
+#define process_frame(p) (struct frame *)&((p)->p_md.md_regs)
+#define process_fpframe(p) &((p)->p_addr->u_pcb.pcb_fpregs)
int
process_read_regs(p, regs)
@@ -114,6 +95,8 @@ process_read_fpregs(p, regs)
return (0);
}
+#ifdef PTRACE
+
int
process_write_regs(p, regs)
struct proc *p;
@@ -197,3 +180,5 @@ process_set_pc(p, addr)
return (0);
}
+
+#endif /* PTRACE */
diff --git a/sys/arch/mvme88k/mvme88k/process_machdep.c b/sys/arch/mvme88k/mvme88k/process_machdep.c
index 0afc9abedc2..9866e9e55b2 100644
--- a/sys/arch/mvme88k/mvme88k/process_machdep.c
+++ b/sys/arch/mvme88k/mvme88k/process_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: process_machdep.c,v 1.9 2001/03/09 05:44:42 smurph Exp $ */
+/* $OpenBSD: process_machdep.c,v 1.10 2002/03/14 00:42:24 miod Exp $ */
/*
* Copyright (c) 1993 The Regents of the University of California.
@@ -82,12 +82,30 @@ process_read_regs(p, regs)
struct proc *p;
struct reg *regs;
{
-
bcopy((caddr_t)USER_REGS(p), (caddr_t)regs, sizeof(struct reg));
return (0);
}
int
+process_read_fpregs(p, regs)
+ struct proc *p;
+ struct fpreg *regs;
+{
+#if 0
+ extern struct fpstate initfpstate;
+ struct fpstate *statep = &initfpstate;
+
+ /* NOTE: struct fpreg == struct fpstate */
+ if (p->p_md.md_fpstate)
+ statep = p->p_md.md_fpstate;
+ bcopy(statep, regs, sizeof(struct fpreg));
+#endif
+ return 0;
+}
+
+#ifdef PTRACE
+
+int
process_write_regs(p, regs)
struct proc *p;
struct reg *regs;
@@ -124,23 +142,6 @@ process_set_pc(p, addr)
}
int
-process_read_fpregs(p, regs)
- struct proc *p;
- struct fpreg *regs;
-{
-#if 0
- extern struct fpstate initfpstate;
- struct fpstate *statep = &initfpstate;
-
- /* NOTE: struct fpreg == struct fpstate */
- if (p->p_md.md_fpstate)
- statep = p->p_md.md_fpstate;
- bcopy(statep, regs, sizeof(struct fpreg));
-#endif
- return 0;
-}
-
-int
process_write_fpregs(p, regs)
struct proc *p;
struct fpreg *regs;
@@ -153,3 +154,5 @@ process_write_fpregs(p, regs)
#endif
return 0;
}
+
+#endif /* PTRACE */
diff --git a/sys/arch/powerpc/powerpc/process_machdep.c b/sys/arch/powerpc/powerpc/process_machdep.c
index 994cd40ff3d..2bda245f97c 100644
--- a/sys/arch/powerpc/powerpc/process_machdep.c
+++ b/sys/arch/powerpc/powerpc/process_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: process_machdep.c,v 1.4 2001/07/09 01:11:09 mickey Exp $ */
+/* $OpenBSD: process_machdep.c,v 1.5 2002/03/14 00:42:24 miod Exp $ */
/* $NetBSD: process_machdep.c,v 1.1 1996/09/30 16:34:53 ws Exp $ */
/*
@@ -37,6 +37,31 @@
#include <sys/ptrace.h>
#include <machine/reg.h>
+int
+process_read_regs(p, regs)
+ struct proc *p;
+ struct reg *regs;
+{
+ struct trapframe *tf = trapframe(p);
+
+ bcopy(&(tf->fixreg[0]), &(regs->gpr[0]), sizeof(regs->gpr));
+ bzero(&(regs->fpr[0]), sizeof(regs->fpr));
+ /*
+ * need to do floating point here
+ */
+ regs->pc = tf->srr0;
+ regs->ps = tf->srr1; /* is this the correct value for this ? */
+ regs->cnd = tf->cr;
+ regs->lr = tf->lr;
+ regs->cnt = tf->ctr;
+ regs->xer = tf->xer;
+ regs->mq = 0; /* what should this really be? */
+
+ return (0);
+}
+
+#ifdef PTRACE
+
/*
* Set the process's program counter.
*/
@@ -64,28 +89,7 @@ process_sstep(p, sstep)
tf->srr1 &= ~PSL_SE;
return 0;
}
-int
-process_read_regs(p, regs)
- struct proc *p;
- struct reg *regs;
-{
- struct trapframe *tf = trapframe(p);
- bcopy(&(tf->fixreg[0]), &(regs->gpr[0]), sizeof(regs->gpr));
- bzero(&(regs->fpr[0]), sizeof(regs->fpr));
- /*
- * need to do floating point here
- */
- regs->pc = tf->srr0;
- regs->ps = tf->srr1; /* is this the correct value for this ? */
- regs->cnd = tf->cr;
- regs->lr = tf->lr;
- regs->cnt = tf->ctr;
- regs->xer = tf->xer;
- regs->mq = 0; /* what should this really be? */
-
- return (0);
-}
int
process_write_regs(p, regs)
struct proc *p;
@@ -107,3 +111,5 @@ process_write_regs(p, regs)
return (0);
}
+
+#endif /* PTRACE */
diff --git a/sys/arch/sparc/sparc/process_machdep.c b/sys/arch/sparc/sparc/process_machdep.c
index f5354856add..9fde6799301 100644
--- a/sys/arch/sparc/sparc/process_machdep.c
+++ b/sys/arch/sparc/sparc/process_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: process_machdep.c,v 1.4 2002/02/20 22:28:23 deraadt Exp $ */
+/* $OpenBSD: process_machdep.c,v 1.5 2002/03/14 00:42:24 miod Exp $ */
/* $NetBSD: process_machdep.c,v 1.6 1996/03/14 21:09:26 christos Exp $ */
/*
@@ -74,8 +74,6 @@
#include <machine/frame.h>
#include <sys/ptrace.h>
-u_int32_t process_get_wcookie(struct proc *p);
-
int
process_read_regs(p, regs)
struct proc *p;
@@ -87,6 +85,23 @@ process_read_regs(p, regs)
}
int
+process_read_fpregs(p, regs)
+ struct proc *p;
+ struct fpreg *regs;
+{
+ extern struct fpstate initfpstate;
+ struct fpstate *statep = &initfpstate;
+
+ /* NOTE: struct fpreg == struct fpstate */
+ if (p->p_md.md_fpstate)
+ statep = p->p_md.md_fpstate;
+ bcopy(statep, regs, sizeof(struct fpreg));
+ return 0;
+}
+
+#ifdef PTRACE
+
+int
process_write_regs(p, regs)
struct proc *p;
struct reg *regs;
@@ -118,24 +133,9 @@ process_set_pc(p, addr)
}
int
-process_read_fpregs(p, regs)
-struct proc *p;
-struct fpreg *regs;
-{
- extern struct fpstate initfpstate;
- struct fpstate *statep = &initfpstate;
-
- /* NOTE: struct fpreg == struct fpstate */
- if (p->p_md.md_fpstate)
- statep = p->p_md.md_fpstate;
- bcopy(statep, regs, sizeof(struct fpreg));
- return 0;
-}
-
-int
process_write_fpregs(p, regs)
-struct proc *p;
-struct fpreg *regs;
+ struct proc *p;
+ struct fpreg *regs;
{
if (p->p_md.md_fpstate == NULL)
return EINVAL;
@@ -144,9 +144,4 @@ struct fpreg *regs;
return 0;
}
-u_int32_t
-process_get_wcookie(p)
- struct proc *p;
-{
- return p->p_addr->u_pcb.pcb_wcookie;
-}
+#endif /* PTRACE */
diff --git a/sys/arch/sparc64/sparc64/process_machdep.c b/sys/arch/sparc64/sparc64/process_machdep.c
index adb7b98a089..0efd1c967a9 100644
--- a/sys/arch/sparc64/sparc64/process_machdep.c
+++ b/sys/arch/sparc64/sparc64/process_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: process_machdep.c,v 1.2 2001/08/20 20:23:53 jason Exp $ */
+/* $OpenBSD: process_machdep.c,v 1.3 2002/03/14 00:42:24 miod Exp $ */
/* $NetBSD: process_machdep.c,v 1.10 2000/09/26 22:05:50 eeh Exp $ */
/*
@@ -115,6 +115,35 @@ process_read_regs(p, regs)
}
int
+process_read_fpregs(p, regs)
+ struct proc *p;
+ struct fpreg *regs;
+{
+ extern struct fpstate64 initfpstate;
+ struct fpstate64 *statep = &initfpstate;
+ struct fpreg32 *regp = (struct fpreg32 *)regs;
+ int i;
+
+ if (!(curproc->p_flag & P_32)) {
+ /* 64-bit mode -- copy in fregs */
+ /* NOTE: struct fpreg == struct fpstate */
+ if (p->p_md.md_fpstate)
+ statep = p->p_md.md_fpstate;
+ bcopy(statep, regs, sizeof(struct fpreg64));
+ return 0;
+ }
+ /* 32-bit mode -- copy out & convert 32-bit fregs */
+ if (p->p_md.md_fpstate)
+ statep = p->p_md.md_fpstate;
+ for (i=0; i<32; i++)
+ regp->fr_regs[i] = statep->fs_regs[i];
+
+ return 0;
+}
+
+#ifdef PTRACE
+
+int
process_write_regs(p, regs)
struct proc *p;
struct reg *regs;
@@ -174,36 +203,9 @@ process_set_pc(p, addr)
}
int
-process_read_fpregs(p, regs)
-struct proc *p;
-struct fpreg *regs;
-{
- extern struct fpstate64 initfpstate;
- struct fpstate64 *statep = &initfpstate;
- struct fpreg32 *regp = (struct fpreg32 *)regs;
- int i;
-
- if (!(curproc->p_flag & P_32)) {
- /* 64-bit mode -- copy in fregs */
- /* NOTE: struct fpreg == struct fpstate */
- if (p->p_md.md_fpstate)
- statep = p->p_md.md_fpstate;
- bcopy(statep, regs, sizeof(struct fpreg64));
- return 0;
- }
- /* 32-bit mode -- copy out & convert 32-bit fregs */
- if (p->p_md.md_fpstate)
- statep = p->p_md.md_fpstate;
- for (i=0; i<32; i++)
- regp->fr_regs[i] = statep->fs_regs[i];
-
- return 0;
-}
-
-int
process_write_fpregs(p, regs)
-struct proc *p;
-struct fpreg *regs;
+ struct proc *p;
+ struct fpreg *regs;
{
extern struct fpstate64 initfpstate;
@@ -232,3 +234,5 @@ struct fpreg *regs;
return 0;
}
+
+#endif /* PTRACE */
diff --git a/sys/arch/vax/vax/machdep.c b/sys/arch/vax/vax/machdep.c
index 3c5ef44b619..5ba63f36e73 100644
--- a/sys/arch/vax/vax/machdep.c
+++ b/sys/arch/vax/vax/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.53 2002/02/17 22:59:53 maja Exp $ */
+/* $OpenBSD: machdep.c,v 1.54 2002/03/14 00:42:24 miod Exp $ */
/* $NetBSD: machdep.c,v 1.108 2000/09/13 15:00:23 thorpej Exp $ */
/*
@@ -643,6 +643,8 @@ process_read_regs(p, regs)
return 0;
}
+#ifdef PTRACE
+
int
process_write_regs(p, regs)
struct proc *p;
@@ -700,6 +702,8 @@ process_sstep(p, sstep)
return (0);
}
+#endif /* PTRACE */
+
#undef PHYSMEMDEBUG
/*
* Allocates a virtual range suitable for mapping in physical memory.
diff --git a/sys/compat/bsdos/syscalls.master b/sys/compat/bsdos/syscalls.master
index a5330202bb1..5c24913ca64 100644
--- a/sys/compat/bsdos/syscalls.master
+++ b/sys/compat/bsdos/syscalls.master
@@ -1,4 +1,4 @@
- $OpenBSD: syscalls.master,v 1.8 2001/05/16 17:14:37 millert Exp $
+ $OpenBSD: syscalls.master,v 1.9 2002/03/14 00:42:24 miod Exp $
; OpenBSD COMPAT_BSDOS system call name/number "master" file.
; (See syscalls.conf to see what it is processed into.)
@@ -74,8 +74,12 @@
23 NOARGS { int sys_setuid(uid_t uid); }
24 NOARGS { uid_t sys_getuid(void); }
25 NOARGS { uid_t sys_geteuid(void); }
+#ifdef PTRACE
26 NOARGS { int sys_ptrace(int req, pid_t pid, \
caddr_t addr, int data); }
+#else
+26 UNIMPL ptrace
+#endif
27 NOARGS { int sys_recvmsg(int s, struct msghdr *msg, \
int flags); }
28 NOARGS { int sys_sendmsg(int s, caddr_t msg, int flags); }
diff --git a/sys/compat/freebsd/files.freebsd b/sys/compat/freebsd/files.freebsd
index 1382efaddfa..74f4a56a627 100644
--- a/sys/compat/freebsd/files.freebsd
+++ b/sys/compat/freebsd/files.freebsd
@@ -1,4 +1,4 @@
-# $OpenBSD: files.freebsd,v 1.4 2001/02/02 19:48:07 tholo Exp $
+# $OpenBSD: files.freebsd,v 1.5 2002/03/14 00:42:25 miod Exp $
# $NetBSD: files.freebsd,v 1.1 1995/10/10 01:19:26 mycroft Exp $
#
# Config.new file description for machine-independent FreeBSD compat code.
@@ -11,7 +11,7 @@ file compat/freebsd/freebsd_exec.c compat_freebsd
file compat/freebsd/freebsd_file.c compat_freebsd
file compat/freebsd/freebsd_ioctl.c compat_freebsd
file compat/freebsd/freebsd_misc.c compat_freebsd
-file compat/freebsd/freebsd_ptrace.c compat_freebsd
+file compat/freebsd/freebsd_ptrace.c compat_freebsd & ptrace
file compat/freebsd/freebsd_signal.c compat_freebsd
file compat/freebsd/freebsd_sysent.c compat_freebsd
file compat/freebsd/freebsd_syscalls.c compat_freebsd & syscall_debug
diff --git a/sys/compat/freebsd/syscalls.master b/sys/compat/freebsd/syscalls.master
index d85b265c851..141cb998d52 100644
--- a/sys/compat/freebsd/syscalls.master
+++ b/sys/compat/freebsd/syscalls.master
@@ -1,4 +1,4 @@
- $OpenBSD: syscalls.master,v 1.16 2001/11/27 19:34:20 maja Exp $
+ $OpenBSD: syscalls.master,v 1.17 2002/03/14 00:42:25 miod Exp $
; $NetBSD: syscalls.master,v 1.3 1995/10/10 18:28:40 mycroft Exp $
; from: @(#)syscalls.master 8.2 (Berkeley) 1/13/94
@@ -82,8 +82,12 @@
23 NOARGS { int sys_setuid(uid_t uid); }
24 NOARGS { uid_t sys_getuid(void); }
25 NOARGS { uid_t sys_geteuid(void); }
+#ifdef PTRACE
26 STD { int freebsd_sys_ptrace(int req, pid_t pid, \
caddr_t addr, int data); }
+#else
+26 UNIMPL ptrace
+#endif
27 NOARGS { int sys_recvmsg(int s, struct msghdr *msg, \
int flags); }
28 NOARGS { int sys_sendmsg(int s, caddr_t msg, int flags); }
diff --git a/sys/compat/hpux/hpux_compat.c b/sys/compat/hpux/hpux_compat.c
index 38ea2345357..62829642fd7 100644
--- a/sys/compat/hpux/hpux_compat.c
+++ b/sys/compat/hpux/hpux_compat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hpux_compat.c,v 1.16 2002/02/13 19:08:06 art Exp $ */
+/* $OpenBSD: hpux_compat.c,v 1.17 2002/03/14 00:42:25 miod Exp $ */
/* $NetBSD: hpux_compat.c,v 1.35 1997/05/08 16:19:48 mycroft Exp $ */
/*
@@ -553,6 +553,8 @@ hpux_sys_rtprio(cp, v, retval)
/* hpux_sys_advise() is found in hpux_machdep.c */
+#ifdef PTRACE
+
int
hpux_sys_ptrace(p, v, retval)
struct proc *p;
@@ -630,6 +632,8 @@ hpux_sys_ptrace(p, v, retval)
return (error);
}
+#endif /* PTRACE */
+
#ifdef SYSVSHM
#include <sys/shm.h>
diff --git a/sys/compat/hpux/syscalls.master b/sys/compat/hpux/syscalls.master
index cee4bdeb548..89c44c345b9 100644
--- a/sys/compat/hpux/syscalls.master
+++ b/sys/compat/hpux/syscalls.master
@@ -1,4 +1,4 @@
- $OpenBSD: syscalls.master,v 1.7 2001/10/10 23:43:44 art Exp $
+ $OpenBSD: syscalls.master,v 1.8 2002/03/14 00:42:25 miod Exp $
; $NetBSD: syscalls.master,v 1.13 1997/03/16 03:48:04 thorpej Exp $
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
@@ -72,8 +72,12 @@
23 NOARGS { int sys_setuid(uid_t uid); }
24 NOARGS { uid_t sys_getuid(void); }
25 STD { int hpux_sys_stime_6x(int time); }
+#ifdef PTRACE
26 STD { int hpux_sys_ptrace(int req, int pid, int *addr, \
int data); }
+#else
+26 UNIMPL ptrace
+#endif
27 STD { int hpux_sys_alarm_6x(int deltat); }
28 STD { int hpux_sys_fstat_6x(int fd, \
struct hpux_ostat *sb); }
diff --git a/sys/compat/linux/linux_dummy.c b/sys/compat/linux/linux_dummy.c
index 1e3d7c6247a..5f91d36b9c4 100644
--- a/sys/compat/linux/linux_dummy.c
+++ b/sys/compat/linux/linux_dummy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: linux_dummy.c,v 1.6 2002/02/04 20:04:52 provos Exp $ */
+/* $OpenBSD: linux_dummy.c,v 1.7 2002/03/14 00:42:25 miod Exp $ */
/*-
* Copyright (c) 1994-1995 Søren Schmidt
@@ -57,7 +57,9 @@ unsupported_msg(struct proc *p, const char *fname)
}
DUMMY(ostat); /* #18 */
+#ifdef PTRACE
DUMMY(ptrace); /* #26 */
+#endif
DUMMY(ofstat); /* #28 */
DUMMY(stty); /* #31 */
DUMMY(gtty); /* #32 */
diff --git a/sys/compat/linux/syscalls.master b/sys/compat/linux/syscalls.master
index 4f82d6dffd6..14983087f82 100644
--- a/sys/compat/linux/syscalls.master
+++ b/sys/compat/linux/syscalls.master
@@ -1,4 +1,4 @@
- $OpenBSD: syscalls.master,v 1.32 2002/02/04 20:04:52 provos Exp $
+ $OpenBSD: syscalls.master,v 1.33 2002/03/14 00:42:25 miod Exp $
; $NetBSD: syscalls.master,v 1.15 1995/12/18 14:35:10 fvdl Exp $
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
@@ -75,7 +75,11 @@
23 NOARGS linux_setuid16 { int sys_setuid(uid_t uid); }
24 NOARGS linux_getuid16 { uid_t sys_getuid(void); }
25 STD { int linux_sys_stime(linux_time_t *t); }
+#ifdef PTRACE
26 STD { int linux_sys_ptrace(void); }
+#else
+26 UNIMPL ptrace
+#endif
27 STD { int linux_sys_alarm(unsigned int secs); }
28 STD { int linux_sys_ofstat(void); }
29 STD { int linux_sys_pause(void); }
diff --git a/sys/compat/netbsd/syscalls.master b/sys/compat/netbsd/syscalls.master
index abcd8685088..23e58808cb2 100644
--- a/sys/compat/netbsd/syscalls.master
+++ b/sys/compat/netbsd/syscalls.master
@@ -1,4 +1,4 @@
-; $OpenBSD: syscalls.master,v 1.15 2001/09/21 15:31:59 art Exp $
+; $OpenBSD: syscalls.master,v 1.16 2002/03/14 00:42:25 miod Exp $
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
@@ -92,8 +92,12 @@
23 NOARGS { int sys_setuid(uid_t uid); }
24 NOARGS { uid_t sys_getuid(void); }
25 NOARGS { uid_t sys_geteuid(void); }
+#ifdef PTRACE
26 NOARGS { int sys_ptrace(int req, pid_t pid, caddr_t addr, \
int data); }
+#else
+26 UNIMPL ptrace
+#endif
27 NOARGS { ssize_t sys_recvmsg(int s, struct msghdr *msg, \
int flags); }
28 NOARGS { ssize_t sys_sendmsg(int s, \
diff --git a/sys/compat/sunos/sunos_misc.c b/sys/compat/sunos/sunos_misc.c
index 4efd5a60136..424802ab271 100644
--- a/sys/compat/sunos/sunos_misc.c
+++ b/sys/compat/sunos/sunos_misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sunos_misc.c,v 1.34 2002/02/13 19:08:06 art Exp $ */
+/* $OpenBSD: sunos_misc.c,v 1.35 2002/03/14 00:42:25 miod Exp $ */
/* $NetBSD: sunos_misc.c,v 1.65 1996/04/22 01:44:31 christos Exp $ */
/*
@@ -994,13 +994,7 @@ sunos_sys_setrlimit(p, v, retval)
return compat_43_sys_setrlimit(p, uap, retval);
}
-/* for the m68k machines */
-#ifndef PT_GETFPREGS
-#define PT_GETFPREGS -1
-#endif
-#ifndef PT_SETFPREGS
-#define PT_SETFPREGS -1
-#endif
+#ifdef PTRACE
static int sreq2breq[] = {
PT_TRACE_ME, PT_READ_I, PT_READ_D, -1,
@@ -1037,6 +1031,8 @@ sunos_sys_ptrace(p, v, retval)
return sys_ptrace(p, &pa, retval);
}
+#endif /* PTRACE */
+
/*
* SunOS reboot system call (for compatibility).
* Sun lets you pass in a boot string which the PROM
diff --git a/sys/compat/sunos/syscalls.master b/sys/compat/sunos/syscalls.master
index fe1fe06e37c..fa7f6bc731c 100644
--- a/sys/compat/sunos/syscalls.master
+++ b/sys/compat/sunos/syscalls.master
@@ -1,4 +1,4 @@
- $OpenBSD: syscalls.master,v 1.11 1999/06/07 07:17:48 deraadt Exp $
+ $OpenBSD: syscalls.master,v 1.12 2002/03/14 00:42:25 miod Exp $
; $NetBSD: syscalls.master,v 1.33 1996/02/28 16:05:43 pk Exp $
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
@@ -69,8 +69,12 @@
23 NOARGS { int sys_setuid(uid_t uid); }
24 NOARGS { uid_t sys_getuid(void); }
25 STD { int sunos_sys_ostime(int time); }
+#ifdef PTRACE
26 STD { long sunos_sys_ptrace(int req, pid_t pid, \
caddr_t addr, int data, char *addr2); }
+#else
+26 UNIMPL sunos_ptrace
+#endif
27 UNIMPL sunos_alarm
28 UNIMPL sunos_fstat
29 UNIMPL sunos_pause
diff --git a/sys/conf/GENERIC b/sys/conf/GENERIC
index ce0242f6e7f..60efe6348da 100644
--- a/sys/conf/GENERIC
+++ b/sys/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.85 2001/09/17 17:04:27 art Exp $
+# $OpenBSD: GENERIC,v 1.86 2002/03/14 00:42:25 miod Exp $
#
# Machine-independent option; used by all architectures for their
# GENERIC kernel
@@ -15,6 +15,7 @@ option DDB # in-kernel debugger
option DIAGNOSTIC # internal consistency checks
option KTRACE # system call tracing, a la ktrace(1)
option KMEMSTATS # collect malloc(9) statistics
+option PTRACE # ptrace(2) system call
option CRYPTO # Cryptographic framework
diff --git a/sys/conf/files b/sys/conf/files
index 7fcc9c1dbcc..3243e6ecd86 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -1,4 +1,4 @@
-# $OpenBSD: files,v 1.240 2002/02/22 20:37:45 drahn Exp $
+# $OpenBSD: files,v 1.241 2002/03/14 00:42:25 miod Exp $
# $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@@ -502,7 +502,7 @@ file kern/subr_userconf.c boot_config
file kern/subr_xxx.c
file kern/sys_generic.c
file kern/sys_pipe.c
-file kern/sys_process.c
+file kern/sys_process.c ptrace
file kern/sys_socket.c
file kern/syscalls.c syscall_debug
file kern/sysv_ipc.c sysvshm | sysvsem | sysvmsg
@@ -564,11 +564,11 @@ file miscfs/portal/portal_vfsops.c portal
file miscfs/portal/portal_vnops.c portal
file miscfs/procfs/procfs_cmdline.c procfs
file miscfs/procfs/procfs_ctl.c procfs
-file miscfs/procfs/procfs_fpregs.c
+file miscfs/procfs/procfs_fpregs.c ptrace
file miscfs/procfs/procfs_linux.c procfs
file miscfs/procfs/procfs_mem.c
file miscfs/procfs/procfs_note.c procfs
-file miscfs/procfs/procfs_regs.c
+file miscfs/procfs/procfs_regs.c ptrace
file miscfs/procfs/procfs_status.c procfs
file miscfs/procfs/procfs_subr.c procfs
file miscfs/procfs/procfs_vfsops.c procfs
diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master
index 9a9a5e90afa..b03342790bd 100644
--- a/sys/kern/syscalls.master
+++ b/sys/kern/syscalls.master
@@ -1,4 +1,4 @@
-; $OpenBSD: syscalls.master,v 1.48 2002/02/22 20:37:45 drahn Exp $
+; $OpenBSD: syscalls.master,v 1.49 2002/03/14 00:42:25 miod Exp $
; $NetBSD: syscalls.master,v 1.32 1996/04/23 10:24:21 mycroft Exp $
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
@@ -81,8 +81,12 @@
23 STD { int sys_setuid(uid_t uid); }
24 STD { uid_t sys_getuid(void); }
25 STD { uid_t sys_geteuid(void); }
+#ifdef PTRACE
26 STD { int sys_ptrace(int req, pid_t pid, caddr_t addr, \
int data); }
+#else
+26 UNIMPL ptrace
+#endif
27 STD { ssize_t sys_recvmsg(int s, struct msghdr *msg, \
int flags); }
28 STD { ssize_t sys_sendmsg(int s, \
diff --git a/sys/miscfs/procfs/README b/sys/miscfs/procfs/README
index aecb1697a61..40086e3c0f6 100644
--- a/sys/miscfs/procfs/README
+++ b/sys/miscfs/procfs/README
@@ -1,4 +1,4 @@
-/* $OpenBSD: README,v 1.5 2000/08/15 06:11:45 jasoni Exp $ */
+/* $OpenBSD: README,v 1.6 2002/03/14 00:42:25 miod Exp $ */
/* $NetBSD: README,v 1.4 1994/06/29 06:34:43 cgd Exp $ */
saute procfs lyonnais
@@ -49,9 +49,15 @@ are:
a multi-proc kernel would need to do some
synchronisation.
+ fpregs - r/w. same as regs, but for floating point registers
+ when available.
+
cmdline - r/o. process command line parameters, separated
by NULs
+Note that regs and fpregs are not available if the kernel is compiled
+without option PTRACE.
+
this then looks like:
% ls -li /proc
@@ -112,6 +118,9 @@ the basic sequence of commands written to "ctl" would be
detach - continue execution of the target process
and remove it from control by the debug process
+Note that attach, wait, step, run and detach are not available if the
+kernel is compiled without option PTRACE.
+
in a normal debugging environment, where the target is fork/exec'd by
the debugger, the debugger should fork and the child should stop itself
(with a self-inflicted SIGSTOP). the parent should do a "wait" then an
diff --git a/sys/miscfs/procfs/procfs_ctl.c b/sys/miscfs/procfs/procfs_ctl.c
index 4b09aaaae23..bac9f4e0324 100644
--- a/sys/miscfs/procfs/procfs_ctl.c
+++ b/sys/miscfs/procfs/procfs_ctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: procfs_ctl.c,v 1.8 2002/01/30 20:45:35 nordin Exp $ */
+/* $OpenBSD: procfs_ctl.c,v 1.9 2002/03/14 00:42:25 miod Exp $ */
/* $NetBSD: procfs_ctl.c,v 1.14 1996/02/09 22:40:48 christos Exp $ */
/*
@@ -63,6 +63,8 @@
(p)->p_pptr == (curp) && \
ISSET((p)->p_flag, P_TRACED))
+#ifdef PTRACE
+
#define PROCFS_CTL_ATTACH 1
#define PROCFS_CTL_DETACH 2
#define PROCFS_CTL_STEP 3
@@ -79,6 +81,8 @@ static vfs_namemap_t ctlnames[] = {
{ 0 },
};
+#endif
+
static vfs_namemap_t signames[] = {
/* regular signal names */
{ "hup", SIGHUP }, { "int", SIGINT },
@@ -100,6 +104,7 @@ static vfs_namemap_t signames[] = {
{ 0 },
};
+#ifdef PTRACE
static int procfs_control __P((struct proc *, struct proc *, int));
static int
@@ -243,14 +248,17 @@ procfs_control(curp, p, op)
}
return (error);
+#ifdef DIAGNOSTIC
default:
panic("procfs_control");
+#endif
}
if (p->p_stat == SSTOP)
setrunnable(p);
return (0);
}
+#endif
int
procfs_doctl(curp, p, pfs, uio)
@@ -283,10 +291,13 @@ procfs_doctl(curp, p, pfs, uio)
*/
error = EOPNOTSUPP;
+#ifdef PTRACE
nm = vfs_findname(ctlnames, msg, xlen);
if (nm) {
error = procfs_control(curp, p, nm->nm_val);
- } else {
+ } else
+#endif
+ {
nm = vfs_findname(signames, msg, xlen);
if (nm) {
if (TRACE_WAIT_P(curp, p)) {
diff --git a/sys/miscfs/procfs/procfs_subr.c b/sys/miscfs/procfs/procfs_subr.c
index 9d0f1c9fb5a..0ec024a1698 100644
--- a/sys/miscfs/procfs/procfs_subr.c
+++ b/sys/miscfs/procfs/procfs_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: procfs_subr.c,v 1.16 2002/01/30 20:29:44 nordin Exp $ */
+/* $OpenBSD: procfs_subr.c,v 1.17 2002/03/14 00:42:25 miod Exp $ */
/* $NetBSD: procfs_subr.c,v 1.15 1996/02/12 15:01:42 christos Exp $ */
/*
@@ -223,11 +223,13 @@ procfs_rw(v)
case Pnotepg:
return (procfs_donote(curp, p, pfs, uio));
+#ifdef PTRACE
case Pregs:
return (procfs_doregs(curp, p, pfs, uio));
case Pfpregs:
return (procfs_dofpregs(curp, p, pfs, uio));
+#endif
case Pctl:
return (procfs_doctl(curp, p, pfs, uio));
diff --git a/sys/miscfs/procfs/procfs_vnops.c b/sys/miscfs/procfs/procfs_vnops.c
index efc9a88b5fa..0b616b571d8 100644
--- a/sys/miscfs/procfs/procfs_vnops.c
+++ b/sys/miscfs/procfs/procfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: procfs_vnops.c,v 1.23 2002/03/11 15:39:27 art Exp $ */
+/* $OpenBSD: procfs_vnops.c,v 1.24 2002/03/14 00:42:25 miod Exp $ */
/* $NetBSD: procfs_vnops.c,v 1.40 1996/03/16 23:52:55 christos Exp $ */
/*
@@ -89,8 +89,10 @@ struct proc_target {
{ DT_DIR, N(".."), Proot, NULL },
{ DT_REG, N("file"), Pfile, procfs_validfile },
{ DT_REG, N("mem"), Pmem, NULL },
+#ifdef PTRACE
{ DT_REG, N("regs"), Pregs, procfs_validregs },
{ DT_REG, N("fpregs"), Pfpregs, procfs_validfpregs },
+#endif
{ DT_REG, N("ctl"), Pctl, NULL },
{ DT_REG, N("status"), Pstatus, NULL },
{ DT_REG, N("note"), Pnote, NULL },
@@ -550,9 +552,12 @@ procfs_getattr(v)
vap->va_atime = vap->va_mtime = vap->va_ctime;
switch (pfs->pfs_type) {
- case Pmem:
case Pregs:
case Pfpregs:
+#ifndef PTRACE
+ break;
+#endif
+ case Pmem:
/*
* If the process has exercised some setuid or setgid
* privilege, then rip away read/write permission so
@@ -640,12 +645,16 @@ procfs_getattr(v)
break;
case Pregs:
+#ifdef PTRACE
vap->va_bytes = vap->va_size = sizeof(struct reg);
+#endif
break;
#if defined(PT_GETFPREGS) || defined(PT_SETFPREGS)
case Pfpregs:
+#ifdef PTRACE
vap->va_bytes = vap->va_size = sizeof(struct fpreg);
+#endif
break;
#endif
@@ -659,8 +668,10 @@ procfs_getattr(v)
vap->va_bytes = vap->va_size = 0;
break;
+#ifdef DIAGNOSTIC
default:
panic("procfs_getattr");
+#endif
}
return (error);