xref: /netbsd-src/sys/arch/arm/include/ptrace.h (revision 3d5424fd1c8b6aafe4a38aef592ad0e80d45792d)
1 /*	$NetBSD: ptrace.h,v 1.17 2020/12/14 01:58:48 rin Exp $	*/
2 
3 /*
4  * Copyright (c) 1995 Frank Lancaster
5  * Copyright (c) 1995 Tools GmbH
6  * 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. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *      This product includes software developed by TooLs GmbH.
19  * 4. The name of the author may not be used to endorse or promote products
20  *    derived from this software without specific prior written permission
21  *
22  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #include <arm/cdefs.h>
35 
36 /*
37  * arm-dependent ptrace definitions
38  */
39 #if 0
40 /* Exposed to userland for NetBSD 1.6 to 9. Do not reuse for other purpose. */
41 #define PT_STEP		(PT_FIRSTMACH + 0) /* Not implemented */
42 #endif
43 #define	PT_GETREGS	(PT_FIRSTMACH + 1)
44 #define	PT_SETREGS	(PT_FIRSTMACH + 2)
45 /* 3 and 4 are for FPE registers */
46 #define	PT_GETFPREGS	(PT_FIRSTMACH + 5)
47 #define	PT_SETFPREGS	(PT_FIRSTMACH + 6)
48 #if 0
49 /* Exposed to userland for NetBSD 8 to 9. Do not reuse for other purpose. */
50 #define PT_SETSTEP	(PT_FIRSTMACH + 7) /* Not implemented */
51 #define PT_CLEARSTEP	(PT_FIRSTMACH + 8) /* Not implemented */
52 #endif
53 
54 #define PT_MACHDEP_STRINGS \
55 	"n/a PT_STEP", \
56 	"PT_GETREGS", \
57 	"PT_SETREGS", \
58 	"old PT_GETFPREGS", \
59 	"old PT_SETFPREGS", \
60 	"PT_GETFPREGS", \
61 	"PT_SETFPREGS", \
62 	"n/a PT_SETSTEP", \
63 	"n/a PT_CLEARSTEP",
64 
65 #include <machine/reg.h>
66 #define PTRACE_REG_PC(_r)		(_r)->r_pc
67 #define PTRACE_REG_FP(_r)		(_r)->r[11]
68 #define PTRACE_REG_SET_PC(_r, _v)	(_r)->r_pc = (_v)
69 #define PTRACE_REG_SP(_r)		(_r)->r_sp
70 #define PTRACE_REG_INTRV(_r)		(_r)->r[0]
71 
72 #define PTRACE_ILLEGAL_ASM	__asm __volatile ("udf #0" : : : "memory")
73 
74 #if defined(__ARMEL__) || defined(_ARM_ARCH_BE8)
75 #define PTRACE_BREAKPOINT	((const uint8_t[]) { 0xfe, 0xde, 0xff, 0xe7 })
76 #else
77 #define PTRACE_BREAKPOINT	((const uint8_t[]) { 0xe7, 0xff, 0xde, 0xfe })
78 #endif
79 
80 #ifdef _ARM_ARCH_BE8
81 #define PTRACE_BREAKPOINT_INSN	0xfedeffe7
82 #else
83 #define PTRACE_BREAKPOINT_INSN	0xe7ffdefe
84 #endif
85 
86 #define PTRACE_BREAKPOINT_ASM	__asm __volatile (".word " ___STRING(PTRACE_BREAKPOINT_INSN) )
87 #define PTRACE_BREAKPOINT_SIZE	4
88