Home | History | Annotate | Line # | Download | only in include
ptrace.h revision 1.13.136.3
      1  1.13.136.3     skrll /*	$NetBSD: ptrace.h,v 1.13.136.3 2017/02/05 13:40:12 skrll Exp $	*/
      2         1.7   thorpej 
      3         1.7   thorpej /*
      4         1.7   thorpej  * Copyright (c) 2001 Wasabi Systems, Inc.
      5         1.7   thorpej  * All rights reserved.
      6         1.7   thorpej  *
      7         1.7   thorpej  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
      8         1.7   thorpej  *
      9         1.7   thorpej  * Redistribution and use in source and binary forms, with or without
     10         1.7   thorpej  * modification, are permitted provided that the following conditions
     11         1.7   thorpej  * are met:
     12         1.7   thorpej  * 1. Redistributions of source code must retain the above copyright
     13         1.7   thorpej  *    notice, this list of conditions and the following disclaimer.
     14         1.7   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     15         1.7   thorpej  *    notice, this list of conditions and the following disclaimer in the
     16         1.7   thorpej  *    documentation and/or other materials provided with the distribution.
     17         1.7   thorpej  * 3. All advertising materials mentioning features or use of this software
     18         1.7   thorpej  *    must display the following acknowledgement:
     19         1.7   thorpej  *	This product includes software developed for the NetBSD Project by
     20         1.7   thorpej  *	Wasabi Systems, Inc.
     21         1.7   thorpej  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
     22         1.7   thorpej  *    or promote products derived from this software without specific prior
     23         1.7   thorpej  *    written permission.
     24         1.7   thorpej  *
     25         1.7   thorpej  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
     26         1.7   thorpej  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27         1.7   thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28         1.7   thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
     29         1.7   thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30         1.7   thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31         1.7   thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32         1.7   thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33         1.7   thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34         1.7   thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35         1.7   thorpej  * POSSIBILITY OF SUCH DAMAGE.
     36         1.7   thorpej  */
     37         1.5       cgd 
     38         1.1       cgd /*
     39         1.1       cgd  * Copyright (c) 1993 Christopher G. Demetriou
     40         1.1       cgd  * All rights reserved.
     41         1.1       cgd  *
     42         1.1       cgd  * Redistribution and use in source and binary forms, with or without
     43         1.1       cgd  * modification, are permitted provided that the following conditions
     44         1.1       cgd  * are met:
     45         1.1       cgd  * 1. Redistributions of source code must retain the above copyright
     46         1.1       cgd  *    notice, this list of conditions and the following disclaimer.
     47         1.1       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     48         1.1       cgd  *    notice, this list of conditions and the following disclaimer in the
     49         1.1       cgd  *    documentation and/or other materials provided with the distribution.
     50         1.1       cgd  * 3. All advertising materials mentioning features or use of this software
     51         1.1       cgd  *    must display the following acknowledgement:
     52         1.1       cgd  *      This product includes software developed by Christopher G. Demetriou.
     53         1.1       cgd  * 4. The name of the author may not be used to endorse or promote products
     54         1.4       jtc  *    derived from this software without specific prior written permission
     55         1.1       cgd  *
     56         1.1       cgd  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     57         1.1       cgd  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     58         1.1       cgd  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     59         1.1       cgd  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     60         1.1       cgd  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     61         1.1       cgd  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     62         1.1       cgd  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     63         1.1       cgd  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     64         1.1       cgd  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     65         1.1       cgd  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     66         1.1       cgd  */
     67         1.1       cgd 
     68         1.7   thorpej #ifndef _I386_PTRACE_H_
     69         1.7   thorpej #define	_I386_PTRACE_H_
     70         1.7   thorpej 
     71         1.1       cgd /*
     72         1.1       cgd  * i386-dependent ptrace definitions
     73         1.1       cgd  */
     74         1.2       cgd #define	PT_STEP		(PT_FIRSTMACH + 0)
     75         1.2       cgd #define	PT_GETREGS	(PT_FIRSTMACH + 1)
     76         1.2       cgd #define	PT_SETREGS	(PT_FIRSTMACH + 2)
     77         1.2       cgd #define	PT_GETFPREGS	(PT_FIRSTMACH + 3)
     78         1.2       cgd #define	PT_SETFPREGS	(PT_FIRSTMACH + 4)
     79         1.7   thorpej 
     80         1.7   thorpej /* We have machine-dependent process tracing needs. */
     81         1.7   thorpej #define	__HAVE_PTRACE_MACHDEP
     82         1.7   thorpej 
     83         1.7   thorpej /* We have machine-dependent procfs nodes. */
     84         1.7   thorpej #define	__HAVE_PROCFS_MACHDEP
     85         1.7   thorpej 
     86         1.7   thorpej /* The machine-dependent ptrace(2) requests. */
     87  1.13.136.3     skrll #define	PT_GETXMMREGS		(PT_FIRSTMACH + 5)
     88  1.13.136.3     skrll #define	PT_SETXMMREGS		(PT_FIRSTMACH + 6)
     89  1.13.136.3     skrll #define PT_READ_WATCHPOINT	(PT_FIRSTMACH + 7)
     90  1.13.136.3     skrll #define PT_WRITE_WATCHPOINT	(PT_FIRSTMACH + 8)
     91  1.13.136.3     skrll #define PT_COUNT_WATCHPOINTS	(PT_FIRSTMACH + 9)
     92         1.7   thorpej 
     93        1.13  christos #define PT_MACHDEP_STRINGS \
     94        1.13  christos 	"PT_STEP", \
     95        1.13  christos 	"PT_GETREGS", \
     96        1.13  christos 	"PT_SETREGS", \
     97        1.13  christos 	"PT_GETFPREGS", \
     98        1.13  christos 	"PT_SETFPREGS", \
     99        1.13  christos 	"PT_GETXMMREGS", \
    100  1.13.136.3     skrll 	"PT_SETXMMREGS", \
    101  1.13.136.3     skrll 	"PT_READ_WATCHPOINT", \
    102  1.13.136.3     skrll 	"PT_WRITE_WATCHPOINT", \
    103  1.13.136.3     skrll 	"PT_COUNT_WATCHPOINTS"
    104        1.13  christos 
    105  1.13.136.1     skrll #include <machine/reg.h>
    106  1.13.136.1     skrll #define PTRACE_REG_PC(r)	(r)->r_eip
    107  1.13.136.1     skrll #define PTRACE_REG_SET_PC(r, v)	(r)->r_eip = (v)
    108  1.13.136.1     skrll #define PTRACE_REG_SP(r)	(r)->r_esp
    109  1.13.136.1     skrll #define PTRACE_REG_INTRV(r)	(r)->r_eax
    110  1.13.136.1     skrll 
    111  1.13.136.2     skrll #define PTRACE_BREAKPOINT	((const uint8_t[]) { 0xcc })
    112  1.13.136.2     skrll #define PTRACE_BREAKPOINT_SIZE	1
    113  1.13.136.2     skrll #define PTRACE_BREAKPOINT_ADJ	sizeof(PTRACE_BREAKPOINT)
    114  1.13.136.2     skrll 
    115  1.13.136.3     skrll #define __HAVE_PTRACE_WATCHPOINTS
    116  1.13.136.3     skrll 
    117  1.13.136.3     skrll /*
    118  1.13.136.3     skrll  * The current list of supported hardware watchpoints
    119  1.13.136.3     skrll  */
    120  1.13.136.3     skrll #define	PTRACE_PW_TYPE_DBREGS	1
    121  1.13.136.3     skrll 
    122  1.13.136.3     skrll struct mdpw {
    123  1.13.136.3     skrll 	union {
    124  1.13.136.3     skrll 		/* Debug Registers DR0-3, DR6, DR7 */
    125  1.13.136.3     skrll 		struct {
    126  1.13.136.3     skrll 			void	*_md_address;
    127  1.13.136.3     skrll 			int	_md_condition;
    128  1.13.136.3     skrll 			int	_md_length;
    129  1.13.136.3     skrll 		} _dbregs;
    130  1.13.136.3     skrll 	} _type;
    131  1.13.136.3     skrll };
    132  1.13.136.3     skrll 
    133  1.13.136.3     skrll /*
    134  1.13.136.3     skrll  * This MD structure translates into x86_hw_watchpoint
    135  1.13.136.3     skrll  *
    136  1.13.136.3     skrll  * pw_address - 0 represents disabled hardware watchpoint
    137  1.13.136.3     skrll  *
    138  1.13.136.3     skrll  * conditions:
    139  1.13.136.3     skrll  *     0b00 - execution
    140  1.13.136.3     skrll  *     0b01 - data write
    141  1.13.136.3     skrll  *     0b10 - io read/write (not implemented)
    142  1.13.136.3     skrll  *     0b11 - data read/write
    143  1.13.136.3     skrll  *
    144  1.13.136.3     skrll  * length:
    145  1.13.136.3     skrll  *     0b00 - 1 byte
    146  1.13.136.3     skrll  *     0b01 - 2 bytes
    147  1.13.136.3     skrll  *     0b10 - undefined
    148  1.13.136.3     skrll  *     0b11 - 4 bytes
    149  1.13.136.3     skrll  *
    150  1.13.136.3     skrll  * Helper symbols for conditions and length are available in <x86/dbregs.h>
    151  1.13.136.3     skrll  *
    152  1.13.136.3     skrll  */
    153  1.13.136.3     skrll 
    154  1.13.136.3     skrll #define	md_address	_type._dbregs._md_address
    155  1.13.136.3     skrll #define	md_condition	_type._dbregs._md_condition
    156  1.13.136.3     skrll #define	md_length	_type._dbregs._md_length
    157  1.13.136.3     skrll 
    158  1.13.136.3     skrll 
    159         1.7   thorpej #ifdef _KERNEL
    160         1.7   thorpej 
    161         1.7   thorpej /*
    162         1.7   thorpej  * These are used in sys_ptrace() to find good ptrace(2) requests.
    163         1.7   thorpej  */
    164         1.7   thorpej #define	PTRACE_MACHDEP_REQUEST_CASES					\
    165         1.7   thorpej 	case PT_GETXMMREGS:						\
    166         1.7   thorpej 	case PT_SETXMMREGS:
    167         1.7   thorpej 
    168         1.7   thorpej /*
    169         1.7   thorpej  * These are used to define machine-dependent procfs node types.
    170         1.7   thorpej  */
    171         1.7   thorpej #define	PROCFS_MACHDEP_NODE_TYPES					\
    172         1.7   thorpej 	Pmachdep_xmmregs,	/* extended FP register set */
    173         1.7   thorpej 
    174         1.7   thorpej /*
    175         1.7   thorpej  * These are used in switch statements to catch machine-dependent
    176         1.7   thorpej  * procfs node types.
    177         1.7   thorpej  */
    178         1.7   thorpej #define	PROCFS_MACHDEP_NODETYPE_CASES					\
    179         1.7   thorpej 	case Pmachdep_xmmregs:
    180         1.7   thorpej 
    181         1.7   thorpej /*
    182         1.7   thorpej  * These are used to protect a privileged process's state.
    183         1.7   thorpej  */
    184         1.7   thorpej #define	PROCFS_MACHDEP_PROTECT_CASES					\
    185         1.7   thorpej 	case Pmachdep_xmmregs:
    186         1.7   thorpej 
    187         1.7   thorpej /*
    188         1.7   thorpej  * These are used to define the machine-dependent procfs nodes.
    189         1.7   thorpej  */
    190         1.7   thorpej #define	PROCFS_MACHDEP_NODETYPE_DEFNS					\
    191         1.7   thorpej 	{ DT_REG, N("xmmregs"), Pmachdep_xmmregs,			\
    192         1.7   thorpej 	  procfs_machdep_validxmmregs },
    193         1.7   thorpej 
    194         1.7   thorpej struct xmmregs;
    195         1.7   thorpej 
    196         1.8   thorpej /* Functions used by both ptrace(2) and procfs. */
    197        1.12  christos int	process_machdep_doxmmregs(struct lwp *, struct lwp *, struct uio *);
    198         1.8   thorpej int	process_machdep_validxmmregs(struct proc *);
    199         1.8   thorpej 
    200         1.8   thorpej /* Functions used by procfs. */
    201         1.7   thorpej struct mount;
    202         1.7   thorpej struct pfsnode;
    203        1.12  christos int	procfs_machdep_doxmmregs(struct lwp *, struct lwp *,
    204         1.7   thorpej 	    struct pfsnode *, struct uio *);
    205        1.12  christos int	procfs_machdep_validxmmregs(struct lwp *, struct mount *);
    206         1.7   thorpej 
    207         1.7   thorpej #endif /* _KERNEL */
    208         1.7   thorpej 
    209         1.7   thorpej #endif /* _I386_PTRACE_H_ */
    210