ptrace.h revision 1.20 1 1.20 kamil /* $NetBSD: ptrace.h,v 1.20 2019/12/02 19:17:27 kamil Exp $ */
2 1.1 fvdl
3 1.1 fvdl /*
4 1.1 fvdl * Copyright (c) 1993 Christopher G. Demetriou
5 1.1 fvdl * All rights reserved.
6 1.1 fvdl *
7 1.1 fvdl * Redistribution and use in source and binary forms, with or without
8 1.1 fvdl * modification, are permitted provided that the following conditions
9 1.1 fvdl * are met:
10 1.1 fvdl * 1. Redistributions of source code must retain the above copyright
11 1.1 fvdl * notice, this list of conditions and the following disclaimer.
12 1.1 fvdl * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 fvdl * notice, this list of conditions and the following disclaimer in the
14 1.1 fvdl * documentation and/or other materials provided with the distribution.
15 1.1 fvdl * 3. All advertising materials mentioning features or use of this software
16 1.1 fvdl * must display the following acknowledgement:
17 1.1 fvdl * This product includes software developed by Christopher G. Demetriou.
18 1.1 fvdl * 4. The name of the author may not be used to endorse or promote products
19 1.1 fvdl * derived from this software without specific prior written permission
20 1.1 fvdl *
21 1.1 fvdl * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 1.1 fvdl * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 1.1 fvdl * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 1.1 fvdl * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 1.1 fvdl * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 1.1 fvdl * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 1.1 fvdl * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 1.1 fvdl * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 1.1 fvdl * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 1.1 fvdl * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 1.1 fvdl */
32 1.5 christos #ifndef _AMD64_PTRACE_H_
33 1.5 christos #define _AMD64_PTRACE_H_
34 1.1 fvdl
35 1.5 christos #ifdef __x86_64__
36 1.1 fvdl /*
37 1.17 rin * amd64-dependent ptrace definitions
38 1.1 fvdl */
39 1.8 kamil #define PT_STEP (PT_FIRSTMACH + 0)
40 1.8 kamil #define PT_GETREGS (PT_FIRSTMACH + 1)
41 1.8 kamil #define PT_SETREGS (PT_FIRSTMACH + 2)
42 1.8 kamil #define PT_GETFPREGS (PT_FIRSTMACH + 3)
43 1.8 kamil #define PT_SETFPREGS (PT_FIRSTMACH + 4)
44 1.10 kamil #define PT_GETDBREGS (PT_FIRSTMACH + 5)
45 1.10 kamil #define PT_SETDBREGS (PT_FIRSTMACH + 6)
46 1.11 kamil #define PT_SETSTEP (PT_FIRSTMACH + 7)
47 1.11 kamil #define PT_CLEARSTEP (PT_FIRSTMACH + 8)
48 1.16 mgorny #define PT_GETXSTATE (PT_FIRSTMACH + 9)
49 1.16 mgorny #define PT_SETXSTATE (PT_FIRSTMACH + 10)
50 1.19 rin #ifdef _KERNEL
51 1.19 rin /*
52 1.19 rin * Only used internally for COMPAT_NETBSD32
53 1.19 rin */
54 1.19 rin #define PT_GETXMMREGS (PT_FIRSTMACH + 11)
55 1.19 rin #define PT_SETXMMREGS (PT_FIRSTMACH + 12)
56 1.19 rin #endif
57 1.16 mgorny
58 1.16 mgorny /* We have machine-dependent process tracing needs. */
59 1.16 mgorny #define __HAVE_PTRACE_MACHDEP
60 1.2 cube
61 1.3 njoly #define PT_MACHDEP_STRINGS \
62 1.3 njoly "PT_STEP", \
63 1.3 njoly "PT_GETREGS", \
64 1.3 njoly "PT_SETREGS", \
65 1.3 njoly "PT_GETFPREGS", \
66 1.8 kamil "PT_SETFPREGS", \
67 1.10 kamil "PT_GETDBREGS", \
68 1.11 kamil "PT_SETDBREGS", \
69 1.11 kamil "PT_SETSTEP", \
70 1.16 mgorny "PT_CLEARSTEP", \
71 1.16 mgorny "PT_GETXSTATE", \
72 1.20 kamil "PT_SETXSTATE", \
73 1.20 kamil "PT_GETXMMREGS", \
74 1.20 kamil "PT_SETXMMREGS"
75 1.3 njoly
76 1.4 christos #include <machine/reg.h>
77 1.4 christos #define PTRACE_REG_PC(r) (r)->regs[_REG_RIP]
78 1.15 kamil #define PTRACE_REG_FP(r) (r)->regs[_REG_RBP]
79 1.4 christos #define PTRACE_REG_SET_PC(r, v) (r)->regs[_REG_RIP] = (v)
80 1.4 christos #define PTRACE_REG_SP(r) (r)->regs[_REG_RSP]
81 1.4 christos #define PTRACE_REG_INTRV(r) (r)->regs[_REG_RAX]
82 1.4 christos
83 1.13 kamil #define PTRACE_ILLEGAL_ASM __asm __volatile ("ud2" : : : "memory")
84 1.13 kamil
85 1.6 christos #define PTRACE_BREAKPOINT ((const uint8_t[]) { 0xcc })
86 1.12 kamil #define PTRACE_BREAKPOINT_ASM __asm __volatile ("int3" : : : "memory")
87 1.6 christos #define PTRACE_BREAKPOINT_SIZE 1
88 1.6 christos #define PTRACE_BREAKPOINT_ADJ 1
89 1.6 christos
90 1.16 mgorny #ifdef _KERNEL
91 1.16 mgorny
92 1.16 mgorny /*
93 1.16 mgorny * These are used in sys_ptrace() to find good ptrace(2) requests.
94 1.16 mgorny */
95 1.16 mgorny #define PTRACE_MACHDEP_REQUEST_CASES \
96 1.16 mgorny case PT_GETXSTATE: \
97 1.19 rin case PT_SETXSTATE: \
98 1.19 rin case PT_GETXMMREGS: \
99 1.19 rin case PT_SETXMMREGS:
100 1.16 mgorny
101 1.16 mgorny int process_machdep_doxstate(struct lwp *, struct lwp *, struct uio *);
102 1.18 rin int process_machdep_validfpu(struct proc *);
103 1.16 mgorny
104 1.19 rin #include <sys/module_hook.h>
105 1.19 rin MODULE_HOOK(netbsd32_process_doxmmregs_hook, int,
106 1.19 rin (struct lwp *, struct lwp *, void *, bool));
107 1.19 rin
108 1.16 mgorny #endif /* _KERNEL */
109 1.16 mgorny
110 1.2 cube #ifdef _KERNEL_OPT
111 1.2 cube #include "opt_compat_netbsd32.h"
112 1.2 cube
113 1.2 cube #ifdef COMPAT_NETBSD32
114 1.2 cube #include <machine/netbsd32_machdep.h>
115 1.2 cube
116 1.2 cube #define process_read_regs32 netbsd32_process_read_regs
117 1.2 cube #define process_read_fpregs32 netbsd32_process_read_fpregs
118 1.10 kamil #define process_read_dbregs32 netbsd32_process_read_dbregs
119 1.2 cube
120 1.7 skrll #define process_write_regs32 netbsd32_process_write_regs
121 1.7 skrll #define process_write_fpregs32 netbsd32_process_write_fpregs
122 1.10 kamil #define process_write_dbregs32 netbsd32_process_write_dbregs
123 1.8 kamil
124 1.2 cube #define process_reg32 struct reg32
125 1.2 cube #define process_fpreg32 struct fpreg32
126 1.10 kamil #define process_dbreg32 struct dbreg32
127 1.14 mgorny
128 1.14 mgorny #define PTRACE_TRANSLATE_REQUEST32(x) netbsd32_ptrace_translate_request(x)
129 1.5 christos #endif /* COMPAT_NETBSD32 */
130 1.5 christos #endif /* _KERNEL_OPT */
131 1.5 christos
132 1.5 christos #else /* !__x86_64__ */
133 1.5 christos
134 1.5 christos #include <i386/ptrace.h>
135 1.5 christos
136 1.5 christos #endif /* __x86_64__ */
137 1.5 christos
138 1.5 christos #endif /* _AMD64_PTRACE_H_ */
139