1 /* `ptrace' debugger support interface. Linux version.
2 Copyright (C) 2000-2016 Free Software Foundation, Inc.
3 Contributed by Denis Joseph Barrow (djbarrow@de.ibm.com).
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
21 #define _SYS_PTRACE_H 1
24 #include <bits/types.h>
27 #ifdef _LINUX_PTRACE_H
28 /* Kludge to stop stuff gdb & strace compiles from getting upset
31 #undef PTRACE_PEEKTEXT
32 #undef PTRACE_PEEKDATA
34 #undef PTRACE_POKETEXT
35 #undef PTRACE_POKEDATA
39 #undef PTRACE_SINGLESTEP
46 /* Type of the REQUEST argument to `ptrace.' */
49 /* Indicate that the process making this request should be traced.
50 All signals received by this process can be intercepted by its
51 parent, and its parent can use the other `ptrace' requests. */
53 #define PT_TRACE_ME PTRACE_TRACEME
55 /* Return the word in the process's text space at address ADDR. */
57 #define PT_READ_I PTRACE_PEEKTEXT
59 /* Return the word in the process's data space at address ADDR. */
61 #define PT_READ_D PTRACE_PEEKDATA
63 /* Return the word in the process's user area at offset ADDR. */
65 #define PT_READ_U PTRACE_PEEKUSER
67 /* Write the word DATA into the process's text space at address ADDR. */
69 #define PT_WRITE_I PTRACE_POKETEXT
71 /* Write the word DATA into the process's data space at address ADDR. */
73 #define PT_WRITE_D PTRACE_POKEDATA
75 /* Write the word DATA into the process's user area at offset ADDR. */
77 #define PT_WRITE_U PTRACE_POKEUSER
79 /* Continue the process. */
81 #define PT_CONTINUE PTRACE_CONT
83 /* Kill the process. */
85 #define PT_KILL PTRACE_KILL
87 /* Single step the process.
88 This is not supported on all machines. */
89 PTRACE_SINGLESTEP
= 9,
90 #define PT_STEP PTRACE_SINGLESTEP
92 /* Get all general purpose registers used by a processes.
93 This is not supported on all machines. */
95 #define PT_GETREGS PTRACE_GETREGS
97 /* Set all general purpose registers used by a processes.
98 This is not supported on all machines. */
100 #define PT_SETREGS PTRACE_SETREGS
102 /* Get all floating point registers used by a processes.
103 This is not supported on all machines. */
104 PTRACE_GETFPREGS
= 14,
105 #define PT_GETFPREGS PTRACE_GETFPREGS
107 /* Set all floating point registers used by a processes.
108 This is not supported on all machines. */
109 PTRACE_SETFPREGS
= 15,
110 #define PT_SETFPREGS PTRACE_SETFPREGS
112 /* Attach to a process that is already running. */
114 #define PT_ATTACH PTRACE_ATTACH
116 /* Detach from a process attached to with PTRACE_ATTACH. */
118 #define PT_DETACH PTRACE_DETACH
120 /* Continue and stop at the next (return from) syscall. */
122 #define PT_SYSCALL PTRACE_SYSCALL
124 /* Set ptrace filter options. */
125 PTRACE_SETOPTIONS
= 0x4200,
126 #define PT_SETOPTIONS PTRACE_SETOPTIONS
128 /* Get last ptrace message. */
129 PTRACE_GETEVENTMSG
= 0x4201,
130 #define PT_GETEVENTMSG PTRACE_GETEVENTMSG
132 /* Get siginfo for process. */
133 PTRACE_GETSIGINFO
= 0x4202,
134 #define PT_GETSIGINFO PTRACE_GETSIGINFO
136 /* Set new siginfo for process. */
137 PTRACE_SETSIGINFO
= 0x4203,
138 #define PT_SETSIGINFO PTRACE_SETSIGINFO
140 /* Get register content. */
141 PTRACE_GETREGSET
= 0x4204,
142 #define PTRACE_GETREGSET PTRACE_GETREGSET
144 /* Set register content. */
145 PTRACE_SETREGSET
= 0x4205,
146 #define PTRACE_SETREGSET PTRACE_SETREGSET
148 /* Like PTRACE_ATTACH, but do not force tracee to trap and do not affect
149 signal or group stop state. */
150 PTRACE_SEIZE
= 0x4206,
151 #define PTRACE_SEIZE PTRACE_SEIZE
153 /* Trap seized tracee. */
154 PTRACE_INTERRUPT
= 0x4207,
155 #define PTRACE_INTERRUPT PTRACE_INTERRUPT
157 /* Wait for next group event. */
158 PTRACE_LISTEN
= 0x4208,
159 #define PTRACE_LISTEN PTRACE_LISTEN
161 PTRACE_PEEKSIGINFO
= 0x4209,
162 #define PTRACE_PEEKSIGINFO PTRACE_PEEKSIGINFO
164 PTRACE_GETSIGMASK
= 0x420a,
165 #define PTRACE_GETSIGMASK PTRACE_GETSIGMASK
167 PTRACE_SETSIGMASK
= 0x420b,
168 #define PTRACE_SETSIGMASK PTRACE_SETSIGMASK
170 PTRACE_SECCOMP_GET_FILTER
= 0x420c
171 #define PTRACE_SECCOMP_GET_FILTER PTRACE_SECCOMP_GET_FILTER
175 /* Flag for PTRACE_LISTEN. */
178 PTRACE_SEIZE_DEVEL
= 0x80000000
181 /* Options set using PTRACE_SETOPTIONS. */
182 enum __ptrace_setoptions
184 PTRACE_O_TRACESYSGOOD
= 0x00000001,
185 PTRACE_O_TRACEFORK
= 0x00000002,
186 PTRACE_O_TRACEVFORK
= 0x00000004,
187 PTRACE_O_TRACECLONE
= 0x00000008,
188 PTRACE_O_TRACEEXEC
= 0x00000010,
189 PTRACE_O_TRACEVFORKDONE
= 0x00000020,
190 PTRACE_O_TRACEEXIT
= 0x00000040,
191 PTRACE_O_TRACESECCOMP
= 0x00000080,
192 PTRACE_O_EXITKILL
= 0x00100000,
193 PTRACE_O_SUSPEND_SECCOMP
= 0x00200000,
194 PTRACE_O_MASK
= 0x003000ff
197 /* Wait extended result codes for the above trace options. */
198 enum __ptrace_eventcodes
200 PTRACE_EVENT_FORK
= 1,
201 PTRACE_EVENT_VFORK
= 2,
202 PTRACE_EVENT_CLONE
= 3,
203 PTRACE_EVENT_EXEC
= 4,
204 PTRACE_EVENT_VFORK_DONE
= 5,
205 PTRACE_EVENT_EXIT
= 6,
206 PTRACE_EVENT_SECCOMP
= 7
209 /* Arguments for PTRACE_PEEKSIGINFO. */
210 struct __ptrace_peeksiginfo_args
212 __uint64_t off
; /* From which siginfo to start. */
213 __uint32_t flags
; /* Flags for peeksiginfo. */
214 __int32_t nr
; /* How many siginfos to take. */
217 enum __ptrace_peeksiginfo_flags
219 /* Read signals from a shared (process wide) queue. */
220 PTRACE_PEEKSIGINFO_SHARED
= (1 << 0)
223 /* Perform process tracing functions. REQUEST is one of the values
224 above, and determines the action to be taken.
225 For all requests except PTRACE_TRACEME, PID specifies the process to be
228 PID and the other arguments described above for the various requests should
229 appear (those that are used for the particular request) as:
230 pid_t PID, void *ADDR, int DATA, void *ADDR2
232 extern long int ptrace (enum __ptrace_request __request
, ...) __THROW
;
236 #endif /* _SYS_PTRACE_H */