xref: /minix3/sys/arch/i386/include/ptrace.h (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc /*	$NetBSD: ptrace.h,v 1.15 2015/09/25 16:05:17 christos Exp $	*/
29c031c9dSBen Gras 
39c031c9dSBen Gras /*
49c031c9dSBen Gras  * Copyright (c) 2001 Wasabi Systems, Inc.
59c031c9dSBen Gras  * All rights reserved.
69c031c9dSBen Gras  *
79c031c9dSBen Gras  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
89c031c9dSBen Gras  *
99c031c9dSBen Gras  * Redistribution and use in source and binary forms, with or without
109c031c9dSBen Gras  * modification, are permitted provided that the following conditions
119c031c9dSBen Gras  * are met:
129c031c9dSBen Gras  * 1. Redistributions of source code must retain the above copyright
139c031c9dSBen Gras  *    notice, this list of conditions and the following disclaimer.
149c031c9dSBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
159c031c9dSBen Gras  *    notice, this list of conditions and the following disclaimer in the
169c031c9dSBen Gras  *    documentation and/or other materials provided with the distribution.
179c031c9dSBen Gras  * 3. All advertising materials mentioning features or use of this software
189c031c9dSBen Gras  *    must display the following acknowledgement:
199c031c9dSBen Gras  *	This product includes software developed for the NetBSD Project by
209c031c9dSBen Gras  *	Wasabi Systems, Inc.
219c031c9dSBen Gras  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
229c031c9dSBen Gras  *    or promote products derived from this software without specific prior
239c031c9dSBen Gras  *    written permission.
249c031c9dSBen Gras  *
259c031c9dSBen Gras  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
269c031c9dSBen Gras  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
279c031c9dSBen Gras  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
289c031c9dSBen Gras  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
299c031c9dSBen Gras  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
309c031c9dSBen Gras  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
319c031c9dSBen Gras  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
329c031c9dSBen Gras  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
339c031c9dSBen Gras  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
349c031c9dSBen Gras  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
359c031c9dSBen Gras  * POSSIBILITY OF SUCH DAMAGE.
369c031c9dSBen Gras  */
379c031c9dSBen Gras 
389c031c9dSBen Gras /*
399c031c9dSBen Gras  * Copyright (c) 1993 Christopher G. Demetriou
409c031c9dSBen Gras  * All rights reserved.
419c031c9dSBen Gras  *
429c031c9dSBen Gras  * Redistribution and use in source and binary forms, with or without
439c031c9dSBen Gras  * modification, are permitted provided that the following conditions
449c031c9dSBen Gras  * are met:
459c031c9dSBen Gras  * 1. Redistributions of source code must retain the above copyright
469c031c9dSBen Gras  *    notice, this list of conditions and the following disclaimer.
479c031c9dSBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
489c031c9dSBen Gras  *    notice, this list of conditions and the following disclaimer in the
499c031c9dSBen Gras  *    documentation and/or other materials provided with the distribution.
509c031c9dSBen Gras  * 3. All advertising materials mentioning features or use of this software
519c031c9dSBen Gras  *    must display the following acknowledgement:
529c031c9dSBen Gras  *      This product includes software developed by Christopher G. Demetriou.
539c031c9dSBen Gras  * 4. The name of the author may not be used to endorse or promote products
549c031c9dSBen Gras  *    derived from this software without specific prior written permission
559c031c9dSBen Gras  *
569c031c9dSBen Gras  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
579c031c9dSBen Gras  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
589c031c9dSBen Gras  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
599c031c9dSBen Gras  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
609c031c9dSBen Gras  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
619c031c9dSBen Gras  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
629c031c9dSBen Gras  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
639c031c9dSBen Gras  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
649c031c9dSBen Gras  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
659c031c9dSBen Gras  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
669c031c9dSBen Gras  */
679c031c9dSBen Gras 
689c031c9dSBen Gras #ifndef _I386_PTRACE_H_
699c031c9dSBen Gras #define	_I386_PTRACE_H_
709c031c9dSBen Gras 
719c031c9dSBen Gras /*
729c031c9dSBen Gras  * i386-dependent ptrace definitions
739c031c9dSBen Gras  */
749c031c9dSBen Gras #define	PT_STEP		(PT_FIRSTMACH + 0)
759c031c9dSBen Gras #define	PT_GETREGS	(PT_FIRSTMACH + 1)
769c031c9dSBen Gras #define	PT_SETREGS	(PT_FIRSTMACH + 2)
779c031c9dSBen Gras #define	PT_GETFPREGS	(PT_FIRSTMACH + 3)
789c031c9dSBen Gras #define	PT_SETFPREGS	(PT_FIRSTMACH + 4)
799c031c9dSBen Gras 
809c031c9dSBen Gras /* We have machine-dependent process tracing needs. */
819c031c9dSBen Gras #define	__HAVE_PTRACE_MACHDEP
829c031c9dSBen Gras 
839c031c9dSBen Gras /* We have machine-dependent procfs nodes. */
849c031c9dSBen Gras #define	__HAVE_PROCFS_MACHDEP
859c031c9dSBen Gras 
869c031c9dSBen Gras /* The machine-dependent ptrace(2) requests. */
879c031c9dSBen Gras #define	PT_GETXMMREGS	(PT_FIRSTMACH + 5)
889c031c9dSBen Gras #define	PT_SETXMMREGS	(PT_FIRSTMACH + 6)
899c031c9dSBen Gras 
909c031c9dSBen Gras #define PT_MACHDEP_STRINGS \
919c031c9dSBen Gras 	"PT_STEP", \
929c031c9dSBen Gras 	"PT_GETREGS", \
939c031c9dSBen Gras 	"PT_SETREGS", \
949c031c9dSBen Gras 	"PT_GETFPREGS", \
959c031c9dSBen Gras 	"PT_SETFPREGS", \
969c031c9dSBen Gras 	"PT_GETXMMREGS", \
979c031c9dSBen Gras 	"PT_SETXMMREGS",
989c031c9dSBen Gras 
99*0a6a1f1dSLionel Sambuc #include <machine/reg.h>
100*0a6a1f1dSLionel Sambuc #define PTRACE_REG_PC(r)	(r)->r_eip
101*0a6a1f1dSLionel Sambuc #define PTRACE_REG_SET_PC(r, v)	(r)->r_eip = (v)
102*0a6a1f1dSLionel Sambuc #define PTRACE_REG_SP(r)	(r)->r_esp
103*0a6a1f1dSLionel Sambuc #define PTRACE_REG_INTRV(r)	(r)->r_eax
104*0a6a1f1dSLionel Sambuc 
105*0a6a1f1dSLionel Sambuc #define PTRACE_BREAKPOINT	((const uint8_t[]) { 0xcc })
106*0a6a1f1dSLionel Sambuc #define PTRACE_BREAKPOINT_SIZE	1
107*0a6a1f1dSLionel Sambuc #define PTRACE_BREAKPOINT_ADJ	sizeof(PTRACE_BREAKPOINT)
108*0a6a1f1dSLionel Sambuc 
1099c031c9dSBen Gras #ifdef _KERNEL
1109c031c9dSBen Gras 
1119c031c9dSBen Gras /*
1129c031c9dSBen Gras  * These are used in sys_ptrace() to find good ptrace(2) requests.
1139c031c9dSBen Gras  */
1149c031c9dSBen Gras #define	PTRACE_MACHDEP_REQUEST_CASES					\
1159c031c9dSBen Gras 	case PT_GETXMMREGS:						\
1169c031c9dSBen Gras 	case PT_SETXMMREGS:
1179c031c9dSBen Gras 
1189c031c9dSBen Gras /*
1199c031c9dSBen Gras  * These are used to define machine-dependent procfs node types.
1209c031c9dSBen Gras  */
1219c031c9dSBen Gras #define	PROCFS_MACHDEP_NODE_TYPES					\
1229c031c9dSBen Gras 	Pmachdep_xmmregs,	/* extended FP register set */
1239c031c9dSBen Gras 
1249c031c9dSBen Gras /*
1259c031c9dSBen Gras  * These are used in switch statements to catch machine-dependent
1269c031c9dSBen Gras  * procfs node types.
1279c031c9dSBen Gras  */
1289c031c9dSBen Gras #define	PROCFS_MACHDEP_NODETYPE_CASES					\
1299c031c9dSBen Gras 	case Pmachdep_xmmregs:
1309c031c9dSBen Gras 
1319c031c9dSBen Gras /*
1329c031c9dSBen Gras  * These are used to protect a privileged process's state.
1339c031c9dSBen Gras  */
1349c031c9dSBen Gras #define	PROCFS_MACHDEP_PROTECT_CASES					\
1359c031c9dSBen Gras 	case Pmachdep_xmmregs:
1369c031c9dSBen Gras 
1379c031c9dSBen Gras /*
1389c031c9dSBen Gras  * These are used to define the machine-dependent procfs nodes.
1399c031c9dSBen Gras  */
1409c031c9dSBen Gras #define	PROCFS_MACHDEP_NODETYPE_DEFNS					\
1419c031c9dSBen Gras 	{ DT_REG, N("xmmregs"), Pmachdep_xmmregs,			\
1429c031c9dSBen Gras 	  procfs_machdep_validxmmregs },
1439c031c9dSBen Gras 
1449c031c9dSBen Gras struct xmmregs;
1459c031c9dSBen Gras 
1469c031c9dSBen Gras /* Functions used by both ptrace(2) and procfs. */
1479c031c9dSBen Gras int	process_machdep_doxmmregs(struct lwp *, struct lwp *, struct uio *);
1489c031c9dSBen Gras int	process_machdep_validxmmregs(struct proc *);
1499c031c9dSBen Gras 
1509c031c9dSBen Gras /* Functions used by procfs. */
1519c031c9dSBen Gras struct mount;
1529c031c9dSBen Gras struct pfsnode;
1539c031c9dSBen Gras int	procfs_machdep_doxmmregs(struct lwp *, struct lwp *,
1549c031c9dSBen Gras 	    struct pfsnode *, struct uio *);
1559c031c9dSBen Gras int	procfs_machdep_validxmmregs(struct lwp *, struct mount *);
1569c031c9dSBen Gras 
1579c031c9dSBen Gras #endif /* _KERNEL */
1589c031c9dSBen Gras 
1599c031c9dSBen Gras #endif /* _I386_PTRACE_H_ */
160