1 /* $OpenBSD: ptrace.h,v 1.8 2003/06/02 23:28:21 millert Exp $ */ 2 /* $NetBSD: ptrace.h,v 1.21 1996/02/09 18:25:26 christos Exp $ */ 3 4 /*- 5 * Copyright (c) 1984, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. Neither the name of the University nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * @(#)ptrace.h 8.2 (Berkeley) 1/4/94 33 */ 34 35 #ifndef _SYS_PTRACE_H_ 36 #define _SYS_PTRACE_H_ 37 38 #define PT_TRACE_ME 0 /* child declares it's being traced */ 39 #define PT_READ_I 1 /* read word in child's I space */ 40 #define PT_READ_D 2 /* read word in child's D space */ 41 #define PT_WRITE_I 4 /* write word in child's I space */ 42 #define PT_WRITE_D 5 /* write word in child's D space */ 43 #define PT_CONTINUE 7 /* continue the child */ 44 #define PT_KILL 8 /* kill the child process */ 45 #define PT_ATTACH 9 /* attach to running process */ 46 #define PT_DETACH 10 /* detach from running process */ 47 #define PT_IO 11 /* do I/O to/from the stopped process. */ 48 49 struct ptrace_io_desc { 50 int piod_op; /* I/O operation */ 51 void *piod_offs; /* child offset */ 52 void *piod_addr; /* parent offset */ 53 size_t piod_len; /* request length */ 54 }; 55 56 /* 57 * Operations in piod_op. 58 */ 59 #define PIOD_READ_D 1 /* Read from D space */ 60 #define PIOD_WRITE_D 2 /* Write to D space */ 61 #define PIOD_READ_I 3 /* Read from I space */ 62 #define PIOD_WRITE_I 4 /* Write to I space */ 63 64 #define PT_FIRSTMACH 32 /* for machine-specific requests */ 65 #include <machine/ptrace.h> /* machine-specific requests, if any */ 66 67 #ifdef _KERNEL 68 69 /* 70 * There is a bunch of PT_ requests that are machine dependent, but not 71 * optional. Check if they were defined by MD code here. 72 */ 73 #if !defined(PT_GETREGS) || !defined(PT_SETREGS) 74 #error Machine dependent ptrace not complete. 75 #endif 76 77 struct reg; 78 #if defined(PT_GETFPREGS) || defined(PT_SETFPREGS) 79 struct fpreg; 80 #endif 81 82 void proc_reparent(struct proc *child, struct proc *newparent); 83 #ifdef PT_GETFPREGS 84 int process_read_fpregs(struct proc *p, struct fpreg *regs); 85 #endif 86 int process_read_regs(struct proc *p, struct reg *regs); 87 int process_set_pc(struct proc *p, caddr_t addr); 88 int process_sstep(struct proc *p, int sstep); 89 #ifdef PT_SETFPREGS 90 int process_write_fpregs(struct proc *p, struct fpreg *regs); 91 #endif 92 int process_write_regs(struct proc *p, struct reg *regs); 93 94 #ifndef FIX_SSTEP 95 #define FIX_SSTEP(p) 96 #endif 97 98 #else /* !_KERNEL */ 99 100 #include <sys/cdefs.h> 101 102 __BEGIN_DECLS 103 int ptrace(int _request, pid_t _pid, caddr_t _addr, int _data); 104 __END_DECLS 105 106 #endif /* !_KERNEL */ 107 108 #endif /* !_SYS_PTRACE_H_ */ 109