]> granicus.if.org Git - strace/blob - ptrace.h
net: fix off-by-one error in sorted xlat lookup
[strace] / ptrace.h
1 /*
2  * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3  * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4  * Copyright (c) 1993-1996 Rick Sladkey <jrs@world.std.com>
5  * Copyright (c) 2004 Roland McGrath <roland@redhat.com>
6  * Copyright (c) 2010 Wang Chao <wang.chao@cn.fujitsu.com>
7  * Copyright (c) 2011-2013 Denys Vlasenko <vda.linux@googlemail.com>
8  * Copyright (c) 2011-2016 Dmitry V. Levin <ldv@altlinux.org>
9  * Copyright (c) 2013 Ali Polatel <alip@exherbo.org>
10  * Copyright (c) 2015 Mike Frysinger <vapier@gentoo.org>
11  * Copyright (c) 2015-2018 The strace developers.
12  * All rights reserved.
13  *
14  * SPDX-License-Identifier: LGPL-2.1-or-later
15  */
16
17 #ifndef STRACE_PTRACE_H
18 #define STRACE_PTRACE_H
19
20 #include <stdint.h>
21 #include <sys/ptrace.h>
22
23 #ifdef HAVE_STRUCT_IA64_FPREG
24 # define ia64_fpreg XXX_ia64_fpreg
25 #endif
26 #ifdef HAVE_STRUCT_PT_ALL_USER_REGS
27 # define pt_all_user_regs XXX_pt_all_user_regs
28 #endif
29 #ifdef HAVE_STRUCT_PTRACE_PEEKSIGINFO_ARGS
30 # define ptrace_peeksiginfo_args XXX_ptrace_peeksiginfo_args
31 #endif
32
33 #include <linux/ptrace.h>
34
35 #ifdef HAVE_STRUCT_IA64_FPREG
36 # undef ia64_fpreg
37 #endif
38 #ifdef HAVE_STRUCT_PT_ALL_USER_REGS
39 # undef pt_all_user_regs
40 #endif
41 #ifdef HAVE_STRUCT_PTRACE_PEEKSIGINFO_ARGS
42 # undef ptrace_peeksiginfo_args
43 #endif
44
45 #if defined(SPARC) || defined(SPARC64)
46 /*
47  * SPARC has a different PTRACE_DETACH value correctly defined in sys/ptrace.h,
48  * but linux/ptrace.h clobbers it with the standard one.  PTRACE_SUNDETACH is
49  * also defined to the correct value by sys/ptrace.h, so use that instead.
50  */
51 # undef PTRACE_DETACH
52 # define PTRACE_DETACH PTRACE_SUNDETACH
53 #endif
54
55 #ifndef PTRACE_EVENT_FORK
56 # define PTRACE_EVENT_FORK      1
57 #endif
58 #ifndef PTRACE_EVENT_VFORK
59 # define PTRACE_EVENT_VFORK     2
60 #endif
61 #ifndef PTRACE_EVENT_CLONE
62 # define PTRACE_EVENT_CLONE     3
63 #endif
64 #ifndef PTRACE_EVENT_EXEC
65 # define PTRACE_EVENT_EXEC      4
66 #endif
67 #ifndef PTRACE_EVENT_VFORK_DONE
68 # define PTRACE_EVENT_VFORK_DONE        5
69 #endif
70 #ifndef PTRACE_EVENT_EXIT
71 # define PTRACE_EVENT_EXIT      6
72 #endif
73 #ifndef PTRACE_EVENT_SECCOMP
74 # define PTRACE_EVENT_SECCOMP   7
75 #endif
76 #ifdef PTRACE_EVENT_STOP
77 /* Linux 3.1 - 3.3 releases had a broken value.  It was fixed in 3.4.  */
78 # if PTRACE_EVENT_STOP == 7
79 #  undef PTRACE_EVENT_STOP
80 # endif
81 #endif
82 #ifndef PTRACE_EVENT_STOP
83 # define PTRACE_EVENT_STOP      128
84 #endif
85
86 #ifndef PTRACE_O_TRACESYSGOOD
87 # define PTRACE_O_TRACESYSGOOD  1
88 #endif
89 #ifndef PTRACE_O_TRACEFORK
90 # define PTRACE_O_TRACEFORK     (1 << PTRACE_EVENT_FORK)
91 #endif
92 #ifndef PTRACE_O_TRACEVFORK
93 # define PTRACE_O_TRACEVFORK    (1 << PTRACE_EVENT_VFORK)
94 #endif
95 #ifndef PTRACE_O_TRACECLONE
96 # define PTRACE_O_TRACECLONE    (1 << PTRACE_EVENT_CLONE)
97 #endif
98 #ifndef PTRACE_O_TRACEEXEC
99 # define PTRACE_O_TRACEEXEC     (1 << PTRACE_EVENT_EXEC)
100 #endif
101 #ifndef PTRACE_O_TRACEVFORKDONE
102 # define PTRACE_O_TRACEVFORKDONE        (1 << PTRACE_EVENT_VFORK_DONE)
103 #endif
104 #ifndef PTRACE_O_TRACEEXIT
105 # define PTRACE_O_TRACEEXIT     (1 << PTRACE_EVENT_EXIT)
106 #endif
107 #ifndef PTRACE_O_TRACESECCOMP
108 # define PTRACE_O_TRACESECCOMP  (1 << PTRACE_EVENT_SECCOMP)
109 #endif
110 #ifndef PTRACE_O_EXITKILL
111 # define PTRACE_O_EXITKILL      (1 << 20)
112 #endif
113 #ifndef PTRACE_O_SUSPEND_SECCOMP
114 # define PTRACE_O_SUSPEND_SECCOMP       (1 << 21)
115 #endif
116
117 #ifndef PTRACE_SETOPTIONS
118 # define PTRACE_SETOPTIONS      0x4200
119 #endif
120 #ifndef PTRACE_GETEVENTMSG
121 # define PTRACE_GETEVENTMSG     0x4201
122 #endif
123 #ifndef PTRACE_GETSIGINFO
124 # define PTRACE_GETSIGINFO      0x4202
125 #endif
126 #ifndef PTRACE_SETSIGINFO
127 # define PTRACE_SETSIGINFO      0x4203
128 #endif
129 #ifndef PTRACE_GETREGSET
130 # define PTRACE_GETREGSET       0x4204
131 #endif
132 #ifndef PTRACE_SETREGSET
133 # define PTRACE_SETREGSET       0x4205
134 #endif
135 #ifndef PTRACE_SEIZE
136 # define PTRACE_SEIZE           0x4206
137 #endif
138 #ifndef PTRACE_INTERRUPT
139 # define PTRACE_INTERRUPT       0x4207
140 #endif
141 #ifndef PTRACE_LISTEN
142 # define PTRACE_LISTEN          0x4208
143 #endif
144 #ifndef PTRACE_PEEKSIGINFO
145 # define PTRACE_PEEKSIGINFO     0x4209
146 #endif
147 #ifndef PTRACE_GETSIGMASK
148 # define PTRACE_GETSIGMASK      0x420a
149 #endif
150 #ifndef PTRACE_SETSIGMASK
151 # define PTRACE_SETSIGMASK      0x420b
152 #endif
153 #ifndef PTRACE_SECCOMP_GET_FILTER
154 # define PTRACE_SECCOMP_GET_FILTER      0x420c
155 #endif
156 #ifndef PTRACE_SECCOMP_GET_METADATA
157 # define PTRACE_SECCOMP_GET_METADATA    0x420d
158 #endif
159 #ifndef PTRACE_GET_SYSCALL_INFO
160 # define PTRACE_GET_SYSCALL_INFO        0x420e
161 # define PTRACE_SYSCALL_INFO_NONE       0
162 # define PTRACE_SYSCALL_INFO_ENTRY      1
163 # define PTRACE_SYSCALL_INFO_EXIT       2
164 # define PTRACE_SYSCALL_INFO_SECCOMP    3
165 struct ptrace_syscall_info {
166         uint8_t op;
167         uint8_t pad[3];
168         uint32_t arch;
169         uint64_t instruction_pointer;
170         uint64_t stack_pointer;
171         union {
172                 struct {
173                         uint64_t nr;
174                         uint64_t args[6];
175                 } entry;
176                 struct {
177                         int64_t rval;
178                         uint8_t is_error;
179                 } exit;
180                 struct {
181                         uint64_t nr;
182                         uint64_t args[6];
183                         uint32_t ret_data;
184                 } seccomp;
185         };
186 };
187 #endif
188
189 #if !HAVE_DECL_PTRACE_PEEKUSER
190 # define PTRACE_PEEKUSER PTRACE_PEEKUSR
191 #endif
192 #if !HAVE_DECL_PTRACE_POKEUSER
193 # define PTRACE_POKEUSER PTRACE_POKEUSR
194 #endif
195
196 #endif /* !STRACE_PTRACE_H */