The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/ptrace.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1984, 1993
    3  *      The Regents of the University of California.  All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  * 4. Neither the name of the University nor the names of its contributors
   14  *    may be used to endorse or promote products derived from this software
   15  *    without specific prior written permission.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  *
   29  *      @(#)ptrace.h    8.2 (Berkeley) 1/4/94
   30  * $FreeBSD: releng/11.1/sys/sys/ptrace.h 304499 2016-08-19 20:17:57Z jhb $
   31  */
   32 
   33 #ifndef _SYS_PTRACE_H_
   34 #define _SYS_PTRACE_H_
   35 
   36 #include <sys/signal.h>
   37 #include <sys/param.h>
   38 #include <machine/reg.h>
   39 
   40 #define PT_TRACE_ME     0       /* child declares it's being traced */
   41 #define PT_READ_I       1       /* read word in child's I space */
   42 #define PT_READ_D       2       /* read word in child's D space */
   43 /* was  PT_READ_U       3        * read word in child's user structure */
   44 #define PT_WRITE_I      4       /* write word in child's I space */
   45 #define PT_WRITE_D      5       /* write word in child's D space */
   46 /* was  PT_WRITE_U      6        * write word in child's user structure */
   47 #define PT_CONTINUE     7       /* continue the child */
   48 #define PT_KILL         8       /* kill the child process */
   49 #define PT_STEP         9       /* single step the child */
   50 
   51 #define PT_ATTACH       10      /* trace some running process */
   52 #define PT_DETACH       11      /* stop tracing a process */
   53 #define PT_IO           12      /* do I/O to/from stopped process. */
   54 #define PT_LWPINFO      13      /* Info about the LWP that stopped. */
   55 #define PT_GETNUMLWPS   14      /* get total number of threads */
   56 #define PT_GETLWPLIST   15      /* get thread list */
   57 #define PT_CLEARSTEP    16      /* turn off single step */
   58 #define PT_SETSTEP      17      /* turn on single step */
   59 #define PT_SUSPEND      18      /* suspend a thread */
   60 #define PT_RESUME       19      /* resume a thread */
   61 
   62 #define PT_TO_SCE       20
   63 #define PT_TO_SCX       21
   64 #define PT_SYSCALL      22
   65 
   66 #define PT_FOLLOW_FORK  23
   67 #define PT_LWP_EVENTS   24      /* report LWP birth and exit */
   68 
   69 #define PT_GET_EVENT_MASK 25    /* get mask of optional events */
   70 #define PT_SET_EVENT_MASK 26    /* set mask of optional events */
   71 
   72 #define PT_GETREGS      33      /* get general-purpose registers */
   73 #define PT_SETREGS      34      /* set general-purpose registers */
   74 #define PT_GETFPREGS    35      /* get floating-point registers */
   75 #define PT_SETFPREGS    36      /* set floating-point registers */
   76 #define PT_GETDBREGS    37      /* get debugging registers */
   77 #define PT_SETDBREGS    38      /* set debugging registers */
   78 
   79 #define PT_VM_TIMESTAMP 40      /* Get VM version (timestamp) */
   80 #define PT_VM_ENTRY     41      /* Get VM map (entry) */
   81 
   82 #define PT_FIRSTMACH    64      /* for machine-specific requests */
   83 #include <machine/ptrace.h>     /* machine-specific requests, if any */
   84 
   85 /* Events used with PT_GET_EVENT_MASK and PT_SET_EVENT_MASK */
   86 #define PTRACE_EXEC     0x0001
   87 #define PTRACE_SCE      0x0002
   88 #define PTRACE_SCX      0x0004
   89 #define PTRACE_SYSCALL  (PTRACE_SCE | PTRACE_SCX)
   90 #define PTRACE_FORK     0x0008
   91 #define PTRACE_LWP      0x0010
   92 #define PTRACE_VFORK    0x0020
   93 
   94 #define PTRACE_DEFAULT  (PTRACE_EXEC)
   95 
   96 struct ptrace_io_desc {
   97         int     piod_op;        /* I/O operation */
   98         void    *piod_offs;     /* child offset */
   99         void    *piod_addr;     /* parent offset */
  100         size_t  piod_len;       /* request length */
  101 };
  102 
  103 /*
  104  * Operations in piod_op.
  105  */
  106 #define PIOD_READ_D     1       /* Read from D space */
  107 #define PIOD_WRITE_D    2       /* Write to D space */
  108 #define PIOD_READ_I     3       /* Read from I space */
  109 #define PIOD_WRITE_I    4       /* Write to I space */
  110 
  111 /* Argument structure for PT_LWPINFO. */
  112 struct ptrace_lwpinfo {
  113         lwpid_t pl_lwpid;       /* LWP described. */
  114         int     pl_event;       /* Event that stopped the LWP. */
  115 #define PL_EVENT_NONE   0
  116 #define PL_EVENT_SIGNAL 1
  117         int     pl_flags;       /* LWP flags. */
  118 #define PL_FLAG_SA      0x01    /* M:N thread */
  119 #define PL_FLAG_BOUND   0x02    /* M:N bound thread */
  120 #define PL_FLAG_SCE     0x04    /* syscall enter point */
  121 #define PL_FLAG_SCX     0x08    /* syscall leave point */
  122 #define PL_FLAG_EXEC    0x10    /* exec(2) succeeded */
  123 #define PL_FLAG_SI      0x20    /* siginfo is valid */
  124 #define PL_FLAG_FORKED  0x40    /* new child */
  125 #define PL_FLAG_CHILD   0x80    /* I am from child */
  126 #define PL_FLAG_BORN    0x100   /* new LWP */
  127 #define PL_FLAG_EXITED  0x200   /* exiting LWP */
  128 #define PL_FLAG_VFORKED 0x400   /* new child via vfork */
  129 #define PL_FLAG_VFORK_DONE 0x800 /* vfork parent has resumed */
  130         sigset_t        pl_sigmask;     /* LWP signal mask */
  131         sigset_t        pl_siglist;     /* LWP pending signal */
  132         struct __siginfo pl_siginfo;    /* siginfo for signal */
  133         char            pl_tdname[MAXCOMLEN + 1]; /* LWP name */
  134         pid_t           pl_child_pid;   /* New child pid */
  135         u_int           pl_syscall_code;
  136         u_int           pl_syscall_narg;
  137 };
  138 
  139 /* Argument structure for PT_VM_ENTRY. */
  140 struct ptrace_vm_entry {
  141         int             pve_entry;      /* Entry number used for iteration. */
  142         int             pve_timestamp;  /* Generation number of VM map. */
  143         u_long          pve_start;      /* Start VA of range. */
  144         u_long          pve_end;        /* End VA of range (incl). */
  145         u_long          pve_offset;     /* Offset in backing object. */
  146         u_int           pve_prot;       /* Protection of memory range. */
  147         u_int           pve_pathlen;    /* Size of path. */
  148         long            pve_fileid;     /* File ID. */
  149         uint32_t        pve_fsid;       /* File system ID. */
  150         char            *pve_path;      /* Path name of object. */
  151 };
  152 
  153 #ifdef _KERNEL
  154 
  155 int     ptrace_set_pc(struct thread *_td, unsigned long _addr);
  156 int     ptrace_single_step(struct thread *_td);
  157 int     ptrace_clear_single_step(struct thread *_td);
  158 
  159 #ifdef __HAVE_PTRACE_MACHDEP
  160 int     cpu_ptrace(struct thread *_td, int _req, void *_addr, int _data);
  161 #endif
  162 
  163 /*
  164  * These are prototypes for functions that implement some of the
  165  * debugging functionality exported by procfs / linprocfs and by the
  166  * ptrace(2) syscall.  They used to be part of procfs, but they don't
  167  * really belong there.
  168  */
  169 struct reg;
  170 struct fpreg;
  171 struct dbreg;
  172 struct uio;
  173 int     proc_read_regs(struct thread *_td, struct reg *_reg);
  174 int     proc_write_regs(struct thread *_td, struct reg *_reg);
  175 int     proc_read_fpregs(struct thread *_td, struct fpreg *_fpreg);
  176 int     proc_write_fpregs(struct thread *_td, struct fpreg *_fpreg);
  177 int     proc_read_dbregs(struct thread *_td, struct dbreg *_dbreg);
  178 int     proc_write_dbregs(struct thread *_td, struct dbreg *_dbreg);
  179 int     proc_sstep(struct thread *_td);
  180 int     proc_rwmem(struct proc *_p, struct uio *_uio);
  181 ssize_t proc_readmem(struct thread *_td, struct proc *_p, vm_offset_t _va,
  182             void *_buf, size_t _len);
  183 ssize_t proc_writemem(struct thread *_td, struct proc *_p, vm_offset_t _va,
  184             void *_buf, size_t _len);
  185 #ifdef COMPAT_FREEBSD32
  186 struct reg32;
  187 struct fpreg32;
  188 struct dbreg32;
  189 int     proc_read_regs32(struct thread *_td, struct reg32 *_reg32);
  190 int     proc_write_regs32(struct thread *_td, struct reg32 *_reg32);
  191 int     proc_read_fpregs32(struct thread *_td, struct fpreg32 *_fpreg32);
  192 int     proc_write_fpregs32(struct thread *_td, struct fpreg32 *_fpreg32);
  193 int     proc_read_dbregs32(struct thread *_td, struct dbreg32 *_dbreg32);
  194 int     proc_write_dbregs32(struct thread *_td, struct dbreg32 *_dbreg32);
  195 #endif
  196 #else /* !_KERNEL */
  197 
  198 #include <sys/cdefs.h>
  199 
  200 __BEGIN_DECLS
  201 int     ptrace(int _request, pid_t _pid, caddr_t _addr, int _data);
  202 __END_DECLS
  203 
  204 #endif /* !_KERNEL */
  205 
  206 #endif  /* !_SYS_PTRACE_H_ */

Cache object: db609a290a82fff5d95439b6dd6df4a4


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.