Date: Sat, 7 Dec 1996 20:33:11 -0800 From: Sean Eric Fagan <sef@Kithrup.COM> To: avalon@coombs.anu.edu.au Cc: freebsd-hackers@freebsd.org, joerg_wunsch@uriah.heep.sax.de Subject: Re: truss, trace ?? Message-ID: <199612080433.UAA11953@kithrup.com>
next in thread | raw e-mail | index | archive | help
Here, by the way, are my old diffs. I haven't touched them in a while, but they did work, to a degree anyway ;). I'm not completely happy with the interface, which is why I hadn't released them before. I recently posted the main part of my EP truss program to the net, to show what it would look like. diff -r -u -N --exclude=GARTH --exclude=*.~* --exclude=*.orig /usr/src/sys/i386/i386/procfs_machdep.c ./i386/i386/procfs_machdep.c --- /usr/src/sys/i386/i386/procfs_machdep.c Thu Mar 16 10:11:29 1995 +++ ./i386/i386/procfs_machdep.c Mon Jul 17 17:46:30 1995 @@ -78,7 +78,7 @@ #include <machine/reg.h> #include <machine/frame.h> #include <machine/md_var.h> -#include <miscfs/procfs/procfs.h> +#include <miscfs/procfs/procfsvar.h> int procfs_read_regs(p, regs) diff -r -u -N --exclude=GARTH --exclude=*.~* --exclude=*.orig /usr/src/sys/i386/i386/trap.c ./i386/i386/trap.c --- /usr/src/sys/i386/i386/trap.c Sun Jun 4 17:22:04 1995 +++ ./i386/i386/trap.c Fri May 26 10:54:41 1995 @@ -825,6 +825,8 @@ rval[0] = 0; rval[1] = frame.tf_edx; + STOPEVENT (p, S_SCE, callp->sy_narg); + error = (*callp->sy_call)(p, args, rval); switch (error) { @@ -860,6 +862,8 @@ } userret(p, &frame, sticks); + + STOPEVENT (p, S_SCX, error); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) diff -r -u -N --exclude=GARTH --exclude=*.~* --exclude=*.orig /usr/src/sys/kern/kern_exec.c ./kern/kern_exec.c --- /usr/src/sys/kern/kern_exec.c Tue May 30 01:05:24 1995 +++ ./kern/kern_exec.c Fri May 26 10:54:42 1995 @@ -286,6 +286,8 @@ * If tracing the process, trap to debugger so breakpoints * can be set before the program executes. */ + STOPEVENT(p, S_EXEC, 0); + if (p->p_flag & P_TRACED) psignal(p, SIGTRAP); diff -r -u -N --exclude=GARTH --exclude=*.~* --exclude=*.orig /usr/src/sys/kern/kern_exit.c ./kern/kern_exit.c --- /usr/src/sys/kern/kern_exit.c Tue May 30 01:05:25 1995 +++ ./kern/kern_exit.c Thu Jul 20 15:18:57 1995 @@ -191,6 +191,9 @@ if (p->p_tracep) vrele(p->p_tracep); #endif + + STOPEVENT(p, S_EXIT, rv); + /* * Remove proc from allproc queue and pidhash chain. * Place onto zombproc. Unlink from parent's child list. diff -r -u -N --exclude=GARTH --exclude=*.~* --exclude=*.orig /usr/src/sys/kern/kern_fork.c ./kern/kern_fork.c --- /usr/src/sys/kern/kern_fork.c Tue May 30 01:05:27 1995 +++ ./kern/kern_fork.c Mon Jul 17 16:48:56 1995 @@ -205,6 +205,8 @@ bcopy(&p1->p_startcopy, &p2->p_startcopy, (unsigned) ((caddr_t)&p2->p_endcopy - (caddr_t)&p2->p_startcopy)); + p2->p_stops = p2->p_step = 0; /* By default, no stops */ + /* * Duplicate sub-structures as needed. * Increase reference counts on shared objects. diff -r -u -N --exclude=GARTH --exclude=*.~* --exclude=*.orig /usr/src/sys/kern/sys_generic.c ./kern/sys_generic.c --- /usr/src/sys/kern/sys_generic.c Tue May 30 01:05:56 1995 +++ ./kern/sys_generic.c Wed Jul 19 19:33:58 1995 @@ -405,8 +405,10 @@ * copied to/from the user's address space. */ size = IOCPARM_LEN(com); - if (size > IOCPARM_MAX) + if (size > IOCPARM_MAX) { +printf ("%s(%d): size = %d, IOCPARM_MAX = %d\n", __FILE__, __LINE__, size, IOCPARM_MAX); return (ENOTTY); + } memp = NULL; #ifdef COMPAT_IBCS2 if (size + IBCS2_RETVAL_SIZE > sizeof (stkbuf)) { diff -r -u -N --exclude=GARTH --exclude=*.~* --exclude=*.orig /usr/src/sys/kern/sys_process.c ./kern/sys_process.c --- /usr/src/sys/kern/sys_process.c Tue May 30 01:05:58 1995 +++ ./kern/sys_process.c Thu Jul 20 10:13:54 1995 @@ -356,3 +356,20 @@ { return 1; } + +void +stopevent(p, event, val) + struct proc *p; + int event; + int val; +{ + + p->p_step = 1; + do { + p->p_xstat = val; + p->p_stype = event; /* Why we stopped */ + p->p_stat = SSTOP; + wakeup(&p->p_stat); + mi_switch(); + } while ((p->p_stops & event) && p->p_step); +} diff -r -u -N --exclude=GARTH --exclude=*.~* --exclude=*.orig /usr/src/sys/kern/vfs_vnops.c ./kern/vfs_vnops.c --- /usr/src/sys/kern/vfs_vnops.c Tue May 30 01:06:35 1995 +++ ./kern/vfs_vnops.c Wed Jul 19 20:05:37 1995 @@ -445,7 +445,9 @@ /* fall into ... */ default: +#if 0 return (ENOTTY); +#endif case VFIFO: case VCHR: diff -r -u -N --exclude=GARTH --exclude=*.~* --exclude=*.orig /usr/src/sys/miscfs/procfs/procfs.h ./miscfs/procfs/procfs.h --- /usr/src/sys/miscfs/procfs/procfs.h Wed May 24 18:35:22 1995 +++ ./miscfs/procfs/procfs.h Wed Dec 31 16:00:00 1969 @@ -1,188 +0,0 @@ -/* - * Copyright (c) 1993 Jan-Simon Pendry - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Jan-Simon Pendry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)procfs.h 8.6 (Berkeley) 2/3/94 - * - * procfs.h,v 1.5 1995/05/25 01:35:22 davidg Exp - */ - -/* - * The different types of node in a procfs filesystem - */ -typedef enum { - Proot, /* the filesystem root */ - Pproc, /* a process-specific sub-directory */ - Pfile, /* the executable file */ - Pmem, /* the process's memory image */ - Pregs, /* the process's register set */ - Pfpregs, /* the process's FP register set */ - Pctl, /* process control */ - Pstatus, /* process status */ - Pnote, /* process notifier */ - Pnotepg /* process group notifier */ -} pfstype; - -/* - * control data for the proc file system. - */ -struct pfsnode { - struct pfsnode *pfs_next; /* next on list */ - struct vnode *pfs_vnode; /* vnode associated with this pfsnode */ - pfstype pfs_type; /* type of procfs node */ - pid_t pfs_pid; /* associated process */ - u_short pfs_mode; /* mode bits for stat() */ - u_long pfs_flags; /* open flags */ - u_long pfs_fileno; /* unique file id */ -}; - -#define PROCFS_NOTELEN 64 /* max length of a note (/proc/$pid/note) */ -#define PROCFS_CTLLEN 8 /* max length of a ctl msg (/proc/$pid/ctl */ - -/* - * Kernel stuff follows - */ -#ifdef KERNEL -#define CNEQ(cnp, s, len) \ - ((cnp)->cn_namelen == (len) && \ - (bcmp((s), (cnp)->cn_nameptr, (len)) == 0)) - -#define KMEM_GROUP 2 -/* - * Format of a directory entry in /proc, ... - * This must map onto struct dirent (see <dirent.h>) - */ -#define PROCFS_NAMELEN 8 -struct pfsdent { - u_long d_fileno; - u_short d_reclen; - u_char d_type; - u_char d_namlen; - char d_name[PROCFS_NAMELEN]; -}; -#define UIO_MX sizeof(struct pfsdent) -#define PROCFS_FILENO(pid, type) \ - (((type) == Proot) ? \ - 2 : \ - ((((pid)+1) << 3) + ((int) (type)))) - -/* - * Convert between pfsnode vnode - */ -#define VTOPFS(vp) ((struct pfsnode *)(vp)->v_data) -#define PFSTOV(pfs) ((pfs)->pfs_vnode) - -typedef struct vfs_namemap vfs_namemap_t; -struct vfs_namemap { - const char *nm_name; - int nm_val; -}; - -extern int vfs_getuserstr __P((struct uio *, char *, int *)); -extern vfs_namemap_t *vfs_findname __P((vfs_namemap_t *, char *, int)); - -/* <machine/reg.h> */ -struct reg; -struct fpreg; - -#define PFIND(pid) ((pid) ? pfind(pid) : &proc0) -extern int procfs_freevp __P((struct vnode *)); -extern int procfs_allocvp __P((struct mount *, struct vnode **, long, pfstype)); -extern struct vnode *procfs_findtextvp __P((struct proc *)); -extern int procfs_sstep __P((struct proc *)); -extern void procfs_fix_sstep __P((struct proc *)); -extern int procfs_read_regs __P((struct proc *, struct reg *)); -extern int procfs_write_regs __P((struct proc *, struct reg *)); -extern int procfs_read_fpregs __P((struct proc *, struct fpreg *)); -extern int procfs_write_fpregs __P((struct proc *, struct fpreg *)); -extern int procfs_donote __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); -extern int procfs_doregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); -extern int procfs_dofpregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); -extern int procfs_domem __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); -extern int procfs_doctl __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); -extern int procfs_dostatus __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); - -#define PROCFS_LOCKED 0x01 -#define PROCFS_WANT 0x02 - -extern int (**procfs_vnodeop_p)(); -extern struct vfsops procfs_vfsops; - -int procfs_root __P((struct mount *, struct vnode **)); - -/* - * Prototypes for procfs vnode ops - */ -int procfs_badop(); /* varargs */ -int procfs_rw __P((struct vop_read_args *)); -int procfs_lookup __P((struct vop_lookup_args *)); -#define procfs_create ((int (*) __P((struct vop_create_args *))) procfs_badop) -#define procfs_mknod ((int (*) __P((struct vop_mknod_args *))) procfs_badop) -int procfs_open __P((struct vop_open_args *)); -int procfs_close __P((struct vop_close_args *)); -int procfs_access __P((struct vop_access_args *)); -int procfs_getattr __P((struct vop_getattr_args *)); -int procfs_setattr __P((struct vop_setattr_args *)); -#define procfs_read procfs_rw -#define procfs_write procfs_rw -int procfs_ioctl __P((struct vop_ioctl_args *)); -#define procfs_select ((int (*) __P((struct vop_select_args *))) procfs_badop) -#define procfs_mmap ((int (*) __P((struct vop_mmap_args *))) procfs_badop) -#define procfs_fsync ((int (*) __P((struct vop_fsync_args *))) procfs_badop) -#define procfs_seek ((int (*) __P((struct vop_seek_args *))) procfs_badop) -#define procfs_remove ((int (*) __P((struct vop_remove_args *))) procfs_badop) -#define procfs_link ((int (*) __P((struct vop_link_args *))) procfs_badop) -#define procfs_rename ((int (*) __P((struct vop_rename_args *))) procfs_badop) -#define procfs_mkdir ((int (*) __P((struct vop_mkdir_args *))) procfs_badop) -#define procfs_rmdir ((int (*) __P((struct vop_rmdir_args *))) procfs_badop) -#define procfs_symlink ((int (*) __P((struct vop_symlink_args *))) procfs_badop) -int procfs_readdir __P((struct vop_readdir_args *)); -#define procfs_readlink ((int (*) __P((struct vop_readlink_args *))) procfs_badop) -int procfs_abortop __P((struct vop_abortop_args *)); -int procfs_inactive __P((struct vop_inactive_args *)); -int procfs_reclaim __P((struct vop_reclaim_args *)); -#define procfs_lock ((int (*) __P((struct vop_lock_args *))) nullop) -#define procfs_unlock ((int (*) __P((struct vop_unlock_args *))) nullop) -#define procfs_bmap ((int (*) __P((struct vop_bmap_args *))) procfs_badop) -#define procfs_strategy ((int (*) __P((struct vop_strategy_args *))) procfs_badop) -int procfs_print __P((struct vop_print_args *)); -#define procfs_islocked ((int (*) __P((struct vop_islocked_args *))) nullop) -#define procfs_advlock ((int (*) __P((struct vop_advlock_args *))) procfs_badop) -#define procfs_blkatoff ((int (*) __P((struct vop_blkatoff_args *))) procfs_badop) -#define procfs_valloc ((int (*) __P((struct vop_valloc_args *))) procfs_badop) -#define procfs_vfree ((int (*) __P((struct vop_vfree_args *))) nullop) -#define procfs_truncate ((int (*) __P((struct vop_truncate_args *))) procfs_badop) -#define procfs_update ((int (*) __P((struct vop_update_args *))) nullop) -#endif /* KERNEL */ diff -r -u -N --exclude=GARTH --exclude=*.~* --exclude=*.orig /usr/src/sys/miscfs/procfs/procfs_ctl.c ./miscfs/procfs/procfs_ctl.c --- /usr/src/sys/miscfs/procfs/procfs_ctl.c Thu Mar 16 10:13:46 1995 +++ ./miscfs/procfs/procfs_ctl.c Mon Jul 17 17:17:00 1995 @@ -55,7 +55,7 @@ #include <vm/vm.h> -#include <miscfs/procfs/procfs.h> +#include <miscfs/procfs/procfsvar.h> /* * True iff process (p) is in trace wait state diff -r -u -N --exclude=GARTH --exclude=*.~* --exclude=*.orig /usr/src/sys/miscfs/procfs/procfs_fpregs.c ./miscfs/procfs/procfs_fpregs.c --- /usr/src/sys/miscfs/procfs/procfs_fpregs.c Tue Aug 2 00:45:12 1994 +++ ./miscfs/procfs/procfs_fpregs.c Mon Jul 17 17:16:56 1995 @@ -46,7 +46,7 @@ #include <sys/proc.h> #include <sys/vnode.h> #include <machine/reg.h> -#include <miscfs/procfs/procfs.h> +#include <miscfs/procfs/procfsvar.h> int procfs_dofpregs(curp, p, pfs, uio) diff -r -u -N --exclude=GARTH --exclude=*.~* --exclude=*.orig /usr/src/sys/miscfs/procfs/procfs_mem.c ./miscfs/procfs/procfs_mem.c --- /usr/src/sys/miscfs/procfs/procfs_mem.c Tue May 30 01:07:09 1995 +++ ./miscfs/procfs/procfs_mem.c Mon Jul 17 17:16:52 1995 @@ -51,7 +51,7 @@ #include <sys/kernel.h> #include <sys/proc.h> #include <sys/vnode.h> -#include <miscfs/procfs/procfs.h> +#include <miscfs/procfs/procfsvar.h> #include <vm/vm.h> #include <vm/vm_kern.h> #include <vm/vm_page.h> diff -r -u -N --exclude=GARTH --exclude=*.~* --exclude=*.orig /usr/src/sys/miscfs/procfs/procfs_note.c ./miscfs/procfs/procfs_note.c --- /usr/src/sys/miscfs/procfs/procfs_note.c Tue Aug 2 00:45:16 1994 +++ ./miscfs/procfs/procfs_note.c Mon Jul 17 17:16:49 1995 @@ -46,7 +46,7 @@ #include <sys/proc.h> #include <sys/vnode.h> #include <sys/signal.h> -#include <miscfs/procfs/procfs.h> +#include <miscfs/procfs/procfsvar.h> int procfs_donote(curp, p, pfs, uio) diff -r -u -N --exclude=GARTH --exclude=*.~* --exclude=*.orig /usr/src/sys/miscfs/procfs/procfs_regs.c ./miscfs/procfs/procfs_regs.c --- /usr/src/sys/miscfs/procfs/procfs_regs.c Tue Aug 2 00:45:18 1994 +++ ./miscfs/procfs/procfs_regs.c Mon Jul 17 17:16:45 1995 @@ -46,7 +46,7 @@ #include <sys/proc.h> #include <sys/vnode.h> #include <machine/reg.h> -#include <miscfs/procfs/procfs.h> +#include <miscfs/procfs/procfsvar.h> int procfs_doregs(curp, p, pfs, uio) diff -r -u -N --exclude=GARTH --exclude=*.~* --exclude=*.orig /usr/src/sys/miscfs/procfs/procfs_status.c ./miscfs/procfs/procfs_status.c --- /usr/src/sys/miscfs/procfs/procfs_status.c Tue May 30 01:07:10 1995 +++ ./miscfs/procfs/procfs_status.c Mon Jul 17 17:16:41 1995 @@ -49,7 +49,7 @@ #include <sys/tty.h> #include <sys/resource.h> #include <sys/resourcevar.h> -#include <miscfs/procfs/procfs.h> +#include <miscfs/procfs/procfsvar.h> int procfs_dostatus(curp, p, pfs, uio) diff -r -u -N --exclude=GARTH --exclude=*.~* --exclude=*.orig /usr/src/sys/miscfs/procfs/procfs_subr.c ./miscfs/procfs/procfs_subr.c --- /usr/src/sys/miscfs/procfs/procfs_subr.c Tue May 30 01:07:11 1995 +++ ./miscfs/procfs/procfs_subr.c Mon Jul 17 17:16:34 1995 @@ -46,7 +46,7 @@ #include <sys/proc.h> #include <sys/vnode.h> #include <sys/malloc.h> -#include <miscfs/procfs/procfs.h> +#include <miscfs/procfs/procfsvar.h> static struct pfsnode *pfshead; static int pfsvplock; diff -r -u -N --exclude=GARTH --exclude=*.~* --exclude=*.orig /usr/src/sys/miscfs/procfs/procfs_vfsops.c ./miscfs/procfs/procfs_vfsops.c --- /usr/src/sys/miscfs/procfs/procfs_vfsops.c Wed May 24 18:35:23 1995 +++ ./miscfs/procfs/procfs_vfsops.c Wed Jul 19 18:17:29 1995 @@ -53,7 +53,7 @@ #include <sys/mount.h> #include <sys/signalvar.h> #include <sys/vnode.h> -#include <miscfs/procfs/procfs.h> +#include <miscfs/procfs/procfsvar.h> #include <vm/vm.h> /* for PAGE_SIZE */ int procfs_statfs __P((struct mount *, struct statfs *, struct proc *)); @@ -73,6 +73,8 @@ struct proc *p; { u_int size; + +printf ("%s(%d): procfs_mount()\n", __FILE__, __LINE__); if (UIO_MX & (UIO_MX-1)) { log(LOG_ERR, "procfs: invalid directory entry size\n"); diff -r -u -N --exclude=GARTH --exclude=*.~* --exclude=*.orig /usr/src/sys/miscfs/procfs/procfs_vnops.c ./miscfs/procfs/procfs_vnops.c --- /usr/src/sys/miscfs/procfs/procfs_vnops.c Tue May 30 01:07:13 1995 +++ ./miscfs/procfs/procfs_vnops.c Thu Jul 20 16:59:14 1995 @@ -54,7 +54,8 @@ #include <sys/malloc.h> #include <sys/dirent.h> #include <sys/resourcevar.h> -#include <miscfs/procfs/procfs.h> +#include <sys/procfs.h> /* procfs ioctl's */ +#include <miscfs/procfs/procfsvar.h> #include <vm/vm.h> /* for PAGE_SIZE */ /* @@ -109,6 +110,8 @@ { struct pfsnode *pfs = VTOPFS(ap->a_vp); +/*printf ("%s(%d)\n", __FILE__, __LINE__); */ + switch (pfs->pfs_type) { case Pmem: if (PFIND(pfs->pfs_pid) == 0) @@ -164,8 +167,52 @@ procfs_ioctl(ap) struct vop_ioctl_args *ap; { + struct pfsnode *pfs = VTOPFS(ap->a_vp); + struct proc *procp; + int error; + int signo; + struct procfs_status *psp; + + procp = pfind (pfs->pfs_pid); + if (procp == NULL) { + return ENOTTY; + } + switch (ap->a_command) { + case PIOCEVBIS: + procp->p_stops |= *(unsigned int*)ap->a_data; + break; + case PIOCEVBIC: + procp->p_stops &= *(unsigned int*)ap->a_data; + break; + case PIOCGEVFLAG: + *(int*)ap->a_data = procp->p_stops; + break; + case PIOCWAIT: + psp = (struct procfs_status *)ap->a_data; + while (procp->p_stat != SSTOP) { + error = tsleep(&procp->p_stat, PZERO + 1, "stopwait", 0); + if (error) + return error; + } + psp->state = 1; /* stopped */ + psp->why = procp->p_stype; /* why it stopped */ + psp->val = procp->p_xstat; /* any extra information */ + break; + case PIOCCONT: + signo = *(int *)ap->a_data; + if (procp->p_stat == SSTOP) { + procp->p_step = 0; + if (signo) + procp->p_xstat = signo; + setrunnable(procp); + } else + return EINVAL; + break; + default: + return EINVAL; + } + return 0; - return (ENOTTY); } /* diff -r -u -N --exclude=GARTH --exclude=*.~* --exclude=*.orig /usr/src/sys/miscfs/procfs/procfsvar.h ./miscfs/procfs/procfsvar.h --- /usr/src/sys/miscfs/procfs/procfsvar.h Wed Dec 31 16:00:00 1969 +++ ./miscfs/procfs/procfsvar.h Fri May 26 10:48:13 1995 @@ -0,0 +1,188 @@ +/* + * Copyright (c) 1993 Jan-Simon Pendry + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Jan-Simon Pendry. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)procfs.h 8.6 (Berkeley) 2/3/94 + * + * procfs.h,v 1.5 1995/05/25 01:35:22 davidg Exp + */ + +/* + * The different types of node in a procfs filesystem + */ +typedef enum { + Proot, /* the filesystem root */ + Pproc, /* a process-specific sub-directory */ + Pfile, /* the executable file */ + Pmem, /* the process's memory image */ + Pregs, /* the process's register set */ + Pfpregs, /* the process's FP register set */ + Pctl, /* process control */ + Pstatus, /* process status */ + Pnote, /* process notifier */ + Pnotepg /* process group notifier */ +} pfstype; + +/* + * control data for the proc file system. + */ +struct pfsnode { + struct pfsnode *pfs_next; /* next on list */ + struct vnode *pfs_vnode; /* vnode associated with this pfsnode */ + pfstype pfs_type; /* type of procfs node */ + pid_t pfs_pid; /* associated process */ + u_short pfs_mode; /* mode bits for stat() */ + u_long pfs_flags; /* open flags */ + u_long pfs_fileno; /* unique file id */ +}; + +#define PROCFS_NOTELEN 64 /* max length of a note (/proc/$pid/note) */ +#define PROCFS_CTLLEN 8 /* max length of a ctl msg (/proc/$pid/ctl */ + +/* + * Kernel stuff follows + */ +#ifdef KERNEL +#define CNEQ(cnp, s, len) \ + ((cnp)->cn_namelen == (len) && \ + (bcmp((s), (cnp)->cn_nameptr, (len)) == 0)) + +#define KMEM_GROUP 2 +/* + * Format of a directory entry in /proc, ... + * This must map onto struct dirent (see <dirent.h>) + */ +#define PROCFS_NAMELEN 8 +struct pfsdent { + u_long d_fileno; + u_short d_reclen; + u_char d_type; + u_char d_namlen; + char d_name[PROCFS_NAMELEN]; +}; +#define UIO_MX sizeof(struct pfsdent) +#define PROCFS_FILENO(pid, type) \ + (((type) == Proot) ? \ + 2 : \ + ((((pid)+1) << 3) + ((int) (type)))) + +/* + * Convert between pfsnode vnode + */ +#define VTOPFS(vp) ((struct pfsnode *)(vp)->v_data) +#define PFSTOV(pfs) ((pfs)->pfs_vnode) + +typedef struct vfs_namemap vfs_namemap_t; +struct vfs_namemap { + const char *nm_name; + int nm_val; +}; + +extern int vfs_getuserstr __P((struct uio *, char *, int *)); +extern vfs_namemap_t *vfs_findname __P((vfs_namemap_t *, char *, int)); + +/* <machine/reg.h> */ +struct reg; +struct fpreg; + +#define PFIND(pid) ((pid) ? pfind(pid) : &proc0) +extern int procfs_freevp __P((struct vnode *)); +extern int procfs_allocvp __P((struct mount *, struct vnode **, long, pfstype)); +extern struct vnode *procfs_findtextvp __P((struct proc *)); +extern int procfs_sstep __P((struct proc *)); +extern void procfs_fix_sstep __P((struct proc *)); +extern int procfs_read_regs __P((struct proc *, struct reg *)); +extern int procfs_write_regs __P((struct proc *, struct reg *)); +extern int procfs_read_fpregs __P((struct proc *, struct fpreg *)); +extern int procfs_write_fpregs __P((struct proc *, struct fpreg *)); +extern int procfs_donote __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); +extern int procfs_doregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); +extern int procfs_dofpregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); +extern int procfs_domem __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); +extern int procfs_doctl __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); +extern int procfs_dostatus __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); + +#define PROCFS_LOCKED 0x01 +#define PROCFS_WANT 0x02 + +extern int (**procfs_vnodeop_p)(); +extern struct vfsops procfs_vfsops; + +int procfs_root __P((struct mount *, struct vnode **)); + +/* + * Prototypes for procfs vnode ops + */ +int procfs_badop(); /* varargs */ +int procfs_rw __P((struct vop_read_args *)); +int procfs_lookup __P((struct vop_lookup_args *)); +#define procfs_create ((int (*) __P((struct vop_create_args *))) procfs_badop) +#define procfs_mknod ((int (*) __P((struct vop_mknod_args *))) procfs_badop) +int procfs_open __P((struct vop_open_args *)); +int procfs_close __P((struct vop_close_args *)); +int procfs_access __P((struct vop_access_args *)); +int procfs_getattr __P((struct vop_getattr_args *)); +int procfs_setattr __P((struct vop_setattr_args *)); +#define procfs_read procfs_rw +#define procfs_write procfs_rw +int procfs_ioctl __P((struct vop_ioctl_args *)); +#define procfs_select ((int (*) __P((struct vop_select_args *))) procfs_badop) +#define procfs_mmap ((int (*) __P((struct vop_mmap_args *))) procfs_badop) +#define procfs_fsync ((int (*) __P((struct vop_fsync_args *))) procfs_badop) +#define procfs_seek ((int (*) __P((struct vop_seek_args *))) procfs_badop) +#define procfs_remove ((int (*) __P((struct vop_remove_args *))) procfs_badop) +#define procfs_link ((int (*) __P((struct vop_link_args *))) procfs_badop) +#define procfs_rename ((int (*) __P((struct vop_rename_args *))) procfs_badop) +#define procfs_mkdir ((int (*) __P((struct vop_mkdir_args *))) procfs_badop) +#define procfs_rmdir ((int (*) __P((struct vop_rmdir_args *))) procfs_badop) +#define procfs_symlink ((int (*) __P((struct vop_symlink_args *))) procfs_badop) +int procfs_readdir __P((struct vop_readdir_args *)); +#define procfs_readlink ((int (*) __P((struct vop_readlink_args *))) procfs_badop) +int procfs_abortop __P((struct vop_abortop_args *)); +int procfs_inactive __P((struct vop_inactive_args *)); +int procfs_reclaim __P((struct vop_reclaim_args *)); +#define procfs_lock ((int (*) __P((struct vop_lock_args *))) nullop) +#define procfs_unlock ((int (*) __P((struct vop_unlock_args *))) nullop) +#define procfs_bmap ((int (*) __P((struct vop_bmap_args *))) procfs_badop) +#define procfs_strategy ((int (*) __P((struct vop_strategy_args *))) procfs_badop) +int procfs_print __P((struct vop_print_args *)); +#define procfs_islocked ((int (*) __P((struct vop_islocked_args *))) nullop) +#define procfs_advlock ((int (*) __P((struct vop_advlock_args *))) procfs_badop) +#define procfs_blkatoff ((int (*) __P((struct vop_blkatoff_args *))) procfs_badop) +#define procfs_valloc ((int (*) __P((struct vop_valloc_args *))) procfs_badop) +#define procfs_vfree ((int (*) __P((struct vop_vfree_args *))) nullop) +#define procfs_truncate ((int (*) __P((struct vop_truncate_args *))) procfs_badop) +#define procfs_update ((int (*) __P((struct vop_update_args *))) nullop) +#endif /* KERNEL */ diff -r -u -N --exclude=GARTH --exclude=*.~* --exclude=*.orig /usr/src/sys/sys/proc.h ./sys/proc.h --- /usr/src/sys/sys/proc.h Thu Mar 16 10:16:22 1995 +++ ./sys/proc.h Wed Jul 19 20:45:24 1995 @@ -137,8 +137,8 @@ struct vnode *p_textvp; /* Vnode of executable. */ char p_lock; /* Process lock count. */ - char p_pad2[3]; /* alignment */ - long p_spare[2]; /* Pad to 256, avoid shifting eproc. XXX */ + char p_pad2[1]; /* alignment XXX */ +/* long p_spare[2]; /* Pad to 256, avoid shifting eproc. XXX */ /* End area that is zeroed on creation. */ #define p_endzero p_startcopy @@ -169,6 +169,9 @@ u_short p_xstat; /* Exit status for wait; also stop signal. */ u_short p_acflag; /* Accounting flags. */ struct rusage *p_ru; /* Exit information. XXX */ + unsigned int p_stops; /* procfs event bitmask */ + unsigned int p_stype; /* procfs stop event type */ + char p_step; /* procfs stop *once* flag */ }; #define p_session p_pgrp->pg_session @@ -237,6 +240,21 @@ if (--(s)->s_count == 0) \ FREE(s, M_SESSION); \ } + +#define S_EXEC 0x0001 /* stop-on-exec */ +#define S_SIG 0x0002 /* stop-on-signal */ +#define S_SCE 0x0004 /* stop-on-syscall-entry */ +#define S_SCX 0x0008 /* stop-on-syscall-exit */ +#define S_CORE 0x0010 /* stop-on-core-dump */ +#define S_EXIT 0x0020 /* stop-on-exit */ + +#ifdef PROCFS +extern void stopevent(); +# define STOPEVENT(p,e,v) do { \ + if ((p)->p_stops & (e)) stopevent(p,e,v); } while (0) +#else +# define STOPEVENT(p,e,v) do { ; } while (0) +#endif extern struct proc *pidhash[]; /* In param.c. */ extern struct pgrp *pgrphash[]; /* In param.c. */ diff -r -u -N --exclude=GARTH --exclude=*.~* --exclude=*.orig /usr/src/sys/sys/procfs.h ./sys/procfs.h --- /usr/src/sys/sys/procfs.h Wed Dec 31 16:00:00 1969 +++ ./sys/procfs.h Thu Jul 20 16:59:15 1995 @@ -0,0 +1,13 @@ +#include <sys/ioctl.h> + +struct procfs_status { + int state; /* 0 for running, 1 for stopped */ + int why; /* what event, if any, process is stopped on */ + unsigned int val; /* Value event wishes "debugger" to know */ +}; + +#define PIOCEVBIS _IOW('p', 1, unsigned int) /* set event flag mask */ +#define PIOCEVBIC _IOW('p', 2, unsigned int) /* clear event flag mask */ +#define PIOCGEVFLAG _IOR('p', 3, unsigned int) /* get event flag mask */ +#define PIOCWAIT _IOR('p', 4, struct procfs_status) /* wait */ +#define PIOCCONT _IOW('p', 5, int) /* Continue */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199612080433.UAA11953>