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.
14 * SPDX-License-Identifier: LGPL-2.1-or-later
17 #ifndef STRACE_PTRACE_H
18 #define STRACE_PTRACE_H
21 #include <sys/ptrace.h>
23 #ifdef HAVE_STRUCT_IA64_FPREG
24 # define ia64_fpreg XXX_ia64_fpreg
26 #ifdef HAVE_STRUCT_PT_ALL_USER_REGS
27 # define pt_all_user_regs XXX_pt_all_user_regs
29 #ifdef HAVE_STRUCT_PTRACE_PEEKSIGINFO_ARGS
30 # define ptrace_peeksiginfo_args XXX_ptrace_peeksiginfo_args
33 #include <linux/ptrace.h>
35 #ifdef HAVE_STRUCT_IA64_FPREG
38 #ifdef HAVE_STRUCT_PT_ALL_USER_REGS
39 # undef pt_all_user_regs
41 #ifdef HAVE_STRUCT_PTRACE_PEEKSIGINFO_ARGS
42 # undef ptrace_peeksiginfo_args
45 #if defined(SPARC) || defined(SPARC64)
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.
52 # define PTRACE_DETACH PTRACE_SUNDETACH
55 #ifndef PTRACE_EVENT_FORK
56 # define PTRACE_EVENT_FORK 1
58 #ifndef PTRACE_EVENT_VFORK
59 # define PTRACE_EVENT_VFORK 2
61 #ifndef PTRACE_EVENT_CLONE
62 # define PTRACE_EVENT_CLONE 3
64 #ifndef PTRACE_EVENT_EXEC
65 # define PTRACE_EVENT_EXEC 4
67 #ifndef PTRACE_EVENT_VFORK_DONE
68 # define PTRACE_EVENT_VFORK_DONE 5
70 #ifndef PTRACE_EVENT_EXIT
71 # define PTRACE_EVENT_EXIT 6
73 #ifndef PTRACE_EVENT_SECCOMP
74 # define PTRACE_EVENT_SECCOMP 7
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
82 #ifndef PTRACE_EVENT_STOP
83 # define PTRACE_EVENT_STOP 128
86 #ifndef PTRACE_O_TRACESYSGOOD
87 # define PTRACE_O_TRACESYSGOOD 1
89 #ifndef PTRACE_O_TRACEFORK
90 # define PTRACE_O_TRACEFORK (1 << PTRACE_EVENT_FORK)
92 #ifndef PTRACE_O_TRACEVFORK
93 # define PTRACE_O_TRACEVFORK (1 << PTRACE_EVENT_VFORK)
95 #ifndef PTRACE_O_TRACECLONE
96 # define PTRACE_O_TRACECLONE (1 << PTRACE_EVENT_CLONE)
98 #ifndef PTRACE_O_TRACEEXEC
99 # define PTRACE_O_TRACEEXEC (1 << PTRACE_EVENT_EXEC)
101 #ifndef PTRACE_O_TRACEVFORKDONE
102 # define PTRACE_O_TRACEVFORKDONE (1 << PTRACE_EVENT_VFORK_DONE)
104 #ifndef PTRACE_O_TRACEEXIT
105 # define PTRACE_O_TRACEEXIT (1 << PTRACE_EVENT_EXIT)
107 #ifndef PTRACE_O_TRACESECCOMP
108 # define PTRACE_O_TRACESECCOMP (1 << PTRACE_EVENT_SECCOMP)
110 #ifndef PTRACE_O_EXITKILL
111 # define PTRACE_O_EXITKILL (1 << 20)
113 #ifndef PTRACE_O_SUSPEND_SECCOMP
114 # define PTRACE_O_SUSPEND_SECCOMP (1 << 21)
117 #ifndef PTRACE_SETOPTIONS
118 # define PTRACE_SETOPTIONS 0x4200
120 #ifndef PTRACE_GETEVENTMSG
121 # define PTRACE_GETEVENTMSG 0x4201
123 #ifndef PTRACE_GETSIGINFO
124 # define PTRACE_GETSIGINFO 0x4202
126 #ifndef PTRACE_SETSIGINFO
127 # define PTRACE_SETSIGINFO 0x4203
129 #ifndef PTRACE_GETREGSET
130 # define PTRACE_GETREGSET 0x4204
132 #ifndef PTRACE_SETREGSET
133 # define PTRACE_SETREGSET 0x4205
136 # define PTRACE_SEIZE 0x4206
138 #ifndef PTRACE_INTERRUPT
139 # define PTRACE_INTERRUPT 0x4207
141 #ifndef PTRACE_LISTEN
142 # define PTRACE_LISTEN 0x4208
144 #ifndef PTRACE_PEEKSIGINFO
145 # define PTRACE_PEEKSIGINFO 0x4209
147 #ifndef PTRACE_GETSIGMASK
148 # define PTRACE_GETSIGMASK 0x420a
150 #ifndef PTRACE_SETSIGMASK
151 # define PTRACE_SETSIGMASK 0x420b
153 #ifndef PTRACE_SECCOMP_GET_FILTER
154 # define PTRACE_SECCOMP_GET_FILTER 0x420c
156 #ifndef PTRACE_SECCOMP_GET_METADATA
157 # define PTRACE_SECCOMP_GET_METADATA 0x420d
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 {
169 uint64_t instruction_pointer;
170 uint64_t stack_pointer;
189 #if !HAVE_DECL_PTRACE_PEEKUSER
190 # define PTRACE_PEEKUSER PTRACE_PEEKUSR
192 #if !HAVE_DECL_PTRACE_POKEUSER
193 # define PTRACE_POKEUSER PTRACE_POKEUSR
196 #endif /* !STRACE_PTRACE_H */