Index: stable/4/lib/libc/sys/ptrace.2 =================================================================== --- stable/4/lib/libc/sys/ptrace.2 (revision 84404) +++ stable/4/lib/libc/sys/ptrace.2 (revision 84405) @@ -1,330 +1,285 @@ .\" $FreeBSD$ .\" $NetBSD: ptrace.2,v 1.2 1995/02/27 12:35:37 cgd Exp $ .\" .\" This file is in the public domain. .Dd January 20, 1996 .Dt PTRACE 2 .Os .Sh NAME .Nm ptrace .Nd process tracing and debugging .Sh LIBRARY .Lb libc .Sh SYNOPSIS .Fd #include .Fd #include .Ft int .Fn ptrace "int request" "pid_t pid" "caddr_t addr" "int data" .Sh DESCRIPTION .Fn ptrace provides tracing and debugging facilities. It allows one process (the .Em tracing process) to control another (the .Em traced process). Most of the time, the traced process runs normally, but when it receives a signal (see .Xr sigaction 2 ) , it stops. The tracing process is expected to notice this via .Xr wait 2 or the delivery of a .Dv SIGCHLD signal, examine the state of the stopped process, and cause it to terminate or continue as appropriate. .Fn ptrace is the mechanism by which all this happens. .Pp The .Fa request argument specifies what operation is being performed; the meaning of the rest of the arguments depends on the operation, but except for one special case noted below, all .Fn ptrace calls are made by the tracing process, and the .Fa pid argument specifies the process ID of the traced process. .Fa request can be: .Bl -tag -width 12n .It Dv PT_TRACE_ME This request is the only one used by the traced process; it declares that the process expects to be traced by its parent. All the other arguments are ignored. (If the parent process does not expect to trace the child, it will probably be rather confused by the results; once the traced process stops, it cannot be made to continue except via .Fn ptrace . ) When a process has used this request and calls .Xr execve 2 or any of the routines built on it (such as .Xr execv 3 ) , it will stop before executing the first instruction of the new image. Also, any setuid or setgid bits on the executable being executed will be ignored. .It Dv PT_READ_I , Dv PT_READ_D These requests read a single .Vt int of data from the traced process' address space. Traditionally, .Fn ptrace has allowed for machines with distinct address spaces for instruction and data, which is why there are two requests: conceptually, .Dv PT_READ_I reads from the instruction space and .Dv PT_READ_D reads from the data space. In the current .Fx implementation, these two requests are completely identical. The .Fa addr argument specifies the address (in the traced process' virtual address space) at which the read is to be done. This address does not have to meet any alignment constraints. The value read is returned as the return value from .Eo \& .Fn ptrace .Ec . .It Dv PT_WRITE_I , Dv PT_WRITE_D These requests parallel .Dv PT_READ_I and .Dv PT_READ_D , except that they write rather than read. The .Fa data argument supplies the value to be written. -.It Dv PT_READ_U -This request reads an -.Vt int -from the traced process' user structure. The -.Fa addr -argument specifies the location of the int relative to the base of the -user structure; it will usually be an integer value cast to -.Vt caddr_t -either explicitly or via the presence of a prototype for -.Eo \& -.Fn ptrace -.Ec . -Unlike -.Dv PT_READ_I -and -.Dv PT_READ_D , -.Fa addr -must be aligned on an -.Vt int -boundary. The value read is returned as the return value from -.Eo \& -.Fn ptrace -.Ec . -.It Dv PT_WRITE_U -This request writes an -.Vt int -into the traced process' user structure. -.Fa addr -specifies the offset, just as for -.Dv PT_READ_U , -and -.Fa data -specifies the value to be written, just as for -.Dv PT_WRITE_I -and -.Dv PT_WRITE_D . .It Dv PT_CONTINUE The traced process continues execution. .Fa addr is an address specifying the place where execution is to be resumed (a new value for the program counter), or .Po Vt caddr_t Pc Ns 1 to indicate that execution is to pick up where it left off. .Fa data provides a signal number to be delivered to the traced process as it resumes execution, or 0 if no signal is to be sent. .It Dv PT_STEP The traced process is single stepped one instruction. .Fa addr should be passed .Po Vt caddr_t Pc Ns 1 . .Fa data is not used. .It Dv PT_KILL The traced process terminates, as if .Dv PT_CONTINUE had been used with .Dv SIGKILL given as the signal to be delivered. .It Dv PT_ATTACH This request allows a process to gain control of an otherwise unrelated process and begin tracing it. It does not need any cooperation from the to-be-traced process. In this case, .Fa pid specifies the process ID of the to-be-traced process, and the other two arguments are ignored. This request requires that the target process must have the same real UID as the tracing process, and that it must not be executing a setuid or setgid executable. (If the tracing process is running as root, these restrictions do not apply.) The tracing process will see the newly-traced process stop and may then control it as if it had been traced all along. .It Dv PT_DETACH This request is like PT_CONTINUE, except that it does not allow specifying an alternate place to continue execution, and after it succeeds, the traced process is no longer traced and continues execution normally. .El .Pp Additionally, machine-specific requests can exist. On the i386, these are: .Bl -tag -width 12n .It Dv PT_GETREGS This request reads the traced process' machine registers into the .Do .Vt "struct reg" .Dc (defined in .Aq Pa machine/reg.h ) pointed to by .Fa addr . .It Dv PT_SETREGS This request is the converse of .Dv PT_GETREGS ; it loads the traced process' machine registers from the .Do .Vt "struct reg" .Dc (defined in .Aq Pa machine/reg.h ) pointed to by .Fa addr . .It Dv PT_GETFPREGS This request reads the traced process' floating-point registers into the .Do .Vt "struct fpreg" .Dc (defined in .Aq Pa machine/reg.h ) pointed to by .Fa addr . .It Dv PT_SETFPREGS This request is the converse of .Dv PT_GETFPREGS ; it loads the traced process' floating-point registers from the .Do .Vt "struct fpreg" .Dc (defined in .Aq Pa machine/reg.h ) pointed to by .Fa addr . .It Dv PT_GETDBREGS This request reads the traced process' debug registers into the .Do .Vt "struct dbreg" .Dc (defined in .Aq Pa machine/reg.h ) pointed to by .Fa addr . .It Dv PT_SETDBREGS This request is the converse of .Dv PT_GETDBREGS ; it loads the traced process' debug registers from the .Do .Vt "struct dbreg" .Dc (defined in .Aq Pa machine/reg.h ) pointed to by .Fa addr . .El .Sh RETURN VALUES Some requests can cause .Fn ptrace to return .Li -1 as a non-error value; to disambiguate, .Va errno can be set to 0 before the call and checked afterwards. .Sh ERRORS The .Fn ptrace function may fail if: .Bl -tag -width Er .It Bq Er ESRCH .Bl -bullet -compact .It No process having the specified process ID exists. .El .It Bq Er EINVAL .Bl -bullet -compact .It A process attempted to use .Dv PT_ATTACH on itself. .It The .Fa request was not one of the legal requests. -.It -The -.Fa addr -to -.Dv PT_READ_U -or -.Dv PT_WRITE_U -was not -.Vt int Ns \-aligned . .It The signal number (in .Fa data ) to .Dv PT_CONTINUE was neither 0 nor a legal signal number. .It .Dv PT_GETREGS , .Dv PT_SETREGS , .Dv PT_GETFPREGS , .Dv PT_SETFPREGS , .Dv PT_GETDBREGS , or .Dv PT_SETDBREGS was attempted on a process with no valid register set. (This is normally true only of system processes.) .El .It Bq Er EBUSY .Bl -bullet -compact .It .Dv PT_ATTACH was attempted on a process that was already being traced. .It A request attempted to manipulate a process that was being traced by some process other than the one making the request. .It A request (other than .Dv PT_ATTACH ) specified a process that wasn't stopped. .El .It Bq Er EPERM .Bl -bullet -compact .It A request (other than .Dv PT_ATTACH ) attempted to manipulate a process that wasn't being traced at all. .It An attempt was made to use .Dv PT_ATTACH on a process in violation of the requirements listed under .Dv PT_ATTACH above. .El .El .Sh SEE ALSO .Xr execve 2 , .Xr sigaction 2 , .Xr wait 2 , .Xr execv 3 , .Xr i386_clr_watch 3 , .Xr i386_set_watch 3 .Sh HISTORY A .Fn ptrace function call appeared in .At v7 . Index: stable/4/sys/kern/sys_process.c =================================================================== --- stable/4/sys/kern/sys_process.c (revision 84404) +++ stable/4/sys/kern/sys_process.c (revision 84405) @@ -1,565 +1,525 @@ /* * Copyright (c) 1994, Sean Eric Fagan * All rights reserved. * * 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 Sean Eric Fagan. * 4. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* use the equivalent procfs code */ #if 0 static int pread (struct proc *procp, unsigned int addr, unsigned int *retval) { int rv; vm_map_t map, tmap; vm_object_t object; vm_offset_t kva = 0; int page_offset; /* offset into page */ vm_offset_t pageno; /* page number */ vm_map_entry_t out_entry; vm_prot_t out_prot; boolean_t wired; vm_pindex_t pindex; /* Map page into kernel space */ map = &procp->p_vmspace->vm_map; page_offset = addr - trunc_page(addr); pageno = trunc_page(addr); tmap = map; rv = vm_map_lookup (&tmap, pageno, VM_PROT_READ, &out_entry, &object, &pindex, &out_prot, &wired); if (rv != KERN_SUCCESS) return EINVAL; vm_map_lookup_done (tmap, out_entry); /* Find space in kernel_map for the page we're interested in */ rv = vm_map_find (kernel_map, object, IDX_TO_OFF(pindex), &kva, PAGE_SIZE, 0, VM_PROT_ALL, VM_PROT_ALL, 0); if (!rv) { vm_object_reference (object); rv = vm_map_pageable (kernel_map, kva, kva + PAGE_SIZE, 0); if (!rv) { *retval = 0; bcopy ((caddr_t)kva + page_offset, retval, sizeof *retval); } vm_map_remove (kernel_map, kva, kva + PAGE_SIZE); } return rv; } static int pwrite (struct proc *procp, unsigned int addr, unsigned int datum) { int rv; vm_map_t map, tmap; vm_object_t object; vm_offset_t kva = 0; int page_offset; /* offset into page */ vm_offset_t pageno; /* page number */ vm_map_entry_t out_entry; vm_prot_t out_prot; boolean_t wired; vm_pindex_t pindex; boolean_t fix_prot = 0; /* Map page into kernel space */ map = &procp->p_vmspace->vm_map; page_offset = addr - trunc_page(addr); pageno = trunc_page(addr); /* * Check the permissions for the area we're interested in. */ if (vm_map_check_protection (map, pageno, pageno + PAGE_SIZE, VM_PROT_WRITE) == FALSE) { /* * If the page was not writable, we make it so. * XXX It is possible a page may *not* be read/executable, * if a process changes that! */ fix_prot = 1; /* The page isn't writable, so let's try making it so... */ if ((rv = vm_map_protect (map, pageno, pageno + PAGE_SIZE, VM_PROT_ALL, 0)) != KERN_SUCCESS) return EFAULT; /* I guess... */ } /* * Now we need to get the page. out_entry, out_prot, wired, and * single_use aren't used. One would think the vm code would be * a *bit* nicer... We use tmap because vm_map_lookup() can * change the map argument. */ tmap = map; rv = vm_map_lookup (&tmap, pageno, VM_PROT_WRITE, &out_entry, &object, &pindex, &out_prot, &wired); if (rv != KERN_SUCCESS) { return EINVAL; } /* * Okay, we've got the page. Let's release tmap. */ vm_map_lookup_done (tmap, out_entry); /* * Fault the page in... */ rv = vm_fault(map, pageno, VM_PROT_WRITE|VM_PROT_READ, FALSE); if (rv != KERN_SUCCESS) return EFAULT; /* Find space in kernel_map for the page we're interested in */ rv = vm_map_find (kernel_map, object, IDX_TO_OFF(pindex), &kva, PAGE_SIZE, 0, VM_PROT_ALL, VM_PROT_ALL, 0); if (!rv) { vm_object_reference (object); rv = vm_map_pageable (kernel_map, kva, kva + PAGE_SIZE, 0); if (!rv) { bcopy (&datum, (caddr_t)kva + page_offset, sizeof datum); } vm_map_remove (kernel_map, kva, kva + PAGE_SIZE); } if (fix_prot) vm_map_protect (map, pageno, pageno + PAGE_SIZE, VM_PROT_READ|VM_PROT_EXECUTE, 0); return rv; } #endif /* * Process debugging system call. */ #ifndef _SYS_SYSPROTO_H_ struct ptrace_args { int req; pid_t pid; caddr_t addr; int data; }; #endif int ptrace(curp, uap) struct proc *curp; struct ptrace_args *uap; { struct proc *p; struct iovec iov; struct uio uio; int error = 0; int write; int s; write = 0; if (uap->req == PT_TRACE_ME) p = curp; else { if ((p = pfind(uap->pid)) == NULL) return ESRCH; } if (!PRISON_CHECK(curp, p)) return (ESRCH); /* * Permissions check */ switch (uap->req) { case PT_TRACE_ME: /* Always legal. */ break; case PT_ATTACH: /* Self */ if (p->p_pid == curp->p_pid) return EINVAL; /* Already traced */ if (p->p_flag & P_TRACED) return EBUSY; /* not owned by you, has done setuid (unless you're root) */ if ((p->p_cred->p_ruid != curp->p_cred->p_ruid) || (p->p_flag & P_SUGID)) { if ((error = suser(curp)) != 0) return error; } /* can't trace init when securelevel > 0 */ if (securelevel > 0 && p->p_pid == 1) return EPERM; /* OK */ break; case PT_READ_I: case PT_READ_D: - case PT_READ_U: case PT_WRITE_I: case PT_WRITE_D: - case PT_WRITE_U: case PT_CONTINUE: case PT_KILL: case PT_STEP: case PT_DETACH: #ifdef PT_GETREGS case PT_GETREGS: #endif #ifdef PT_SETREGS case PT_SETREGS: #endif #ifdef PT_GETFPREGS case PT_GETFPREGS: #endif #ifdef PT_SETFPREGS case PT_SETFPREGS: #endif #ifdef PT_GETDBREGS case PT_GETDBREGS: #endif #ifdef PT_SETDBREGS case PT_SETDBREGS: #endif /* not being traced... */ if ((p->p_flag & P_TRACED) == 0) return EPERM; /* not being traced by YOU */ if (p->p_pptr != curp) return EBUSY; /* not currently stopped */ if (p->p_stat != SSTOP || (p->p_flag & P_WAITED) == 0) return EBUSY; /* OK */ break; default: return EINVAL; } #ifdef FIX_SSTEP /* * Single step fixup ala procfs */ FIX_SSTEP(p); #endif /* * Actually do the requests */ curp->p_retval[0] = 0; switch (uap->req) { case PT_TRACE_ME: /* set my trace flag and "owner" so it can read/write me */ p->p_flag |= P_TRACED; p->p_oppid = p->p_pptr->p_pid; return 0; case PT_ATTACH: /* security check done above */ p->p_flag |= P_TRACED; p->p_oppid = p->p_pptr->p_pid; if (p->p_pptr != curp) proc_reparent(p, curp); uap->data = SIGSTOP; goto sendsig; /* in PT_CONTINUE below */ case PT_STEP: case PT_CONTINUE: case PT_DETACH: if ((uap->req != PT_STEP) && ((unsigned)uap->data >= NSIG)) return EINVAL; PHOLD(p); if (uap->req == PT_STEP) { if ((error = ptrace_single_step (p))) { PRELE(p); return error; } } if (uap->addr != (caddr_t)1) { - fill_eproc (p, &p->p_addr->u_kproc.kp_eproc); if ((error = ptrace_set_pc (p, (u_long)(uintfptr_t)uap->addr))) { PRELE(p); return error; } } PRELE(p); if (uap->req == PT_DETACH) { /* reset process parent */ if (p->p_oppid != p->p_pptr->p_pid) { struct proc *pp; pp = pfind(p->p_oppid); proc_reparent(p, pp ? pp : initproc); } p->p_flag &= ~(P_TRACED | P_WAITED); p->p_oppid = 0; /* should we send SIGCHLD? */ } sendsig: /* deliver or queue signal */ s = splhigh(); if (p->p_stat == SSTOP) { p->p_xstat = uap->data; setrunnable(p); } else if (uap->data) { psignal(p, uap->data); } splx(s); return 0; case PT_WRITE_I: case PT_WRITE_D: write = 1; /* fallthrough */ case PT_READ_I: case PT_READ_D: /* write = 0 set above */ iov.iov_base = write ? (caddr_t)&uap->data : (caddr_t)curp->p_retval; iov.iov_len = sizeof(int); uio.uio_iov = &iov; uio.uio_iovcnt = 1; uio.uio_offset = (off_t)(uintptr_t)uap->addr; uio.uio_resid = sizeof(int); uio.uio_segflg = UIO_SYSSPACE; /* ie: the uap */ uio.uio_rw = write ? UIO_WRITE : UIO_READ; uio.uio_procp = p; error = procfs_domem(curp, p, NULL, &uio); if (uio.uio_resid != 0) { /* * XXX procfs_domem() doesn't currently return ENOSPC, * so I think write() can bogusly return 0. * XXX what happens for short writes? We don't want * to write partial data. * XXX procfs_domem() returns EPERM for other invalid * addresses. Convert this to EINVAL. Does this * clobber returns of EPERM for other reasons? */ if (error == 0 || error == ENOSPC || error == EPERM) error = EINVAL; /* EOF */ } return (error); - - case PT_READ_U: - if ((uintptr_t)uap->addr > UPAGES * PAGE_SIZE - sizeof(int)) { - return EFAULT; - } - if ((uintptr_t)uap->addr & (sizeof(int) - 1)) { - return EFAULT; - } - if (ptrace_read_u_check(p,(vm_offset_t) uap->addr, - sizeof(int))) { - return EFAULT; - } - error = 0; - PHOLD(p); /* user had damn well better be incore! */ - if (p->p_flag & P_INMEM) { - p->p_addr->u_kproc.kp_proc = *p; - fill_eproc (p, &p->p_addr->u_kproc.kp_eproc); - curp->p_retval[0] = *(int *) - ((uintptr_t)p->p_addr + (uintptr_t)uap->addr); - } else { - curp->p_retval[0] = 0; - error = EFAULT; - } - PRELE(p); - return error; - - case PT_WRITE_U: - PHOLD(p); /* user had damn well better be incore! */ - if (p->p_flag & P_INMEM) { - p->p_addr->u_kproc.kp_proc = *p; - fill_eproc (p, &p->p_addr->u_kproc.kp_eproc); - error = ptrace_write_u(p, (vm_offset_t)uap->addr, uap->data); - } else { - error = EFAULT; - } - PRELE(p); - return error; case PT_KILL: uap->data = SIGKILL; goto sendsig; /* in PT_CONTINUE above */ #ifdef PT_SETREGS case PT_SETREGS: write = 1; /* fallthrough */ #endif /* PT_SETREGS */ #ifdef PT_GETREGS case PT_GETREGS: /* write = 0 above */ #endif /* PT_SETREGS */ #if defined(PT_SETREGS) || defined(PT_GETREGS) if (!procfs_validregs(p)) /* no P_SYSTEM procs please */ return EINVAL; else { iov.iov_base = uap->addr; iov.iov_len = sizeof(struct reg); uio.uio_iov = &iov; uio.uio_iovcnt = 1; uio.uio_offset = 0; uio.uio_resid = sizeof(struct reg); uio.uio_segflg = UIO_USERSPACE; uio.uio_rw = write ? UIO_WRITE : UIO_READ; uio.uio_procp = curp; return (procfs_doregs(curp, p, NULL, &uio)); } #endif /* defined(PT_SETREGS) || defined(PT_GETREGS) */ #ifdef PT_SETFPREGS case PT_SETFPREGS: write = 1; /* fallthrough */ #endif /* PT_SETFPREGS */ #ifdef PT_GETFPREGS case PT_GETFPREGS: /* write = 0 above */ #endif /* PT_SETFPREGS */ #if defined(PT_SETFPREGS) || defined(PT_GETFPREGS) if (!procfs_validfpregs(p)) /* no P_SYSTEM procs please */ return EINVAL; else { iov.iov_base = uap->addr; iov.iov_len = sizeof(struct fpreg); uio.uio_iov = &iov; uio.uio_iovcnt = 1; uio.uio_offset = 0; uio.uio_resid = sizeof(struct fpreg); uio.uio_segflg = UIO_USERSPACE; uio.uio_rw = write ? UIO_WRITE : UIO_READ; uio.uio_procp = curp; return (procfs_dofpregs(curp, p, NULL, &uio)); } #endif /* defined(PT_SETFPREGS) || defined(PT_GETFPREGS) */ #ifdef PT_SETDBREGS case PT_SETDBREGS: write = 1; /* fallthrough */ #endif /* PT_SETDBREGS */ #ifdef PT_GETDBREGS case PT_GETDBREGS: /* write = 0 above */ #endif /* PT_SETDBREGS */ #if defined(PT_SETDBREGS) || defined(PT_GETDBREGS) if (!procfs_validdbregs(p)) /* no P_SYSTEM procs please */ return EINVAL; else { iov.iov_base = uap->addr; iov.iov_len = sizeof(struct dbreg); uio.uio_iov = &iov; uio.uio_iovcnt = 1; uio.uio_offset = 0; uio.uio_resid = sizeof(struct dbreg); uio.uio_segflg = UIO_USERSPACE; uio.uio_rw = write ? UIO_WRITE : UIO_READ; uio.uio_procp = curp; return (procfs_dodbregs(curp, p, NULL, &uio)); } #endif /* defined(PT_SETDBREGS) || defined(PT_GETDBREGS) */ default: break; } return 0; } int trace_req(p) struct proc *p; { return 1; } /* * stopevent() * Stop a process because of a procfs event; * stay stopped until p->p_step is cleared * (cleared by PIOCCONT in procfs). */ void stopevent(struct proc *p, unsigned int event, unsigned int val) { p->p_step = 1; do { p->p_xstat = val; p->p_stype = event; /* Which event caused the stop? */ wakeup(&p->p_stype); /* Wake up any PIOCWAIT'ing procs */ tsleep(&p->p_step, PWAIT, "stopevent", 0); } while (p->p_step); } Index: stable/4/sys/sys/ptrace.h =================================================================== --- stable/4/sys/sys/ptrace.h (revision 84404) +++ stable/4/sys/sys/ptrace.h (revision 84405) @@ -1,72 +1,72 @@ /*- * Copyright (c) 1984, 1993 * The Regents of the University of California. All rights reserved. * * 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. * * @(#)ptrace.h 8.2 (Berkeley) 1/4/94 * $FreeBSD$ */ #ifndef _SYS_PTRACE_H_ #define _SYS_PTRACE_H_ #define PT_TRACE_ME 0 /* child declares it's being traced */ #define PT_READ_I 1 /* read word in child's I space */ #define PT_READ_D 2 /* read word in child's D space */ -#define PT_READ_U 3 /* read word in child's user structure */ +/* was PT_READ_U 3 * read word in child's user structure */ #define PT_WRITE_I 4 /* write word in child's I space */ #define PT_WRITE_D 5 /* write word in child's D space */ -#define PT_WRITE_U 6 /* write word in child's user structure */ +/* was PT_WRITE_U 6 * write word in child's user structure */ #define PT_CONTINUE 7 /* continue the child */ #define PT_KILL 8 /* kill the child process */ #define PT_STEP 9 /* single step the child */ #define PT_ATTACH 10 /* trace some running process */ #define PT_DETACH 11 /* stop tracing a process */ #define PT_FIRSTMACH 32 /* for machine-specific requests */ #include /* machine-specific requests, if any */ #ifdef _KERNEL void proc_reparent __P((struct proc *child, struct proc *newparent)); int ptrace_set_pc __P((struct proc *p, unsigned long addr)); int ptrace_single_step __P((struct proc *p)); int ptrace_write_u __P((struct proc *p, vm_offset_t off, long data)); #else /* !_KERNEL */ #include __BEGIN_DECLS int ptrace __P((int _request, pid_t _pid, caddr_t _addr, int _data)); __END_DECLS #endif /* !_KERNEL */ #endif /* !_SYS_PTRACE_H_ */