1 /* `ptrace' debugger support interface.  Linux version.
2    Copyright (C) 1996-2012 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4 
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9 
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14 
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <http://www.gnu.org/licenses/>.  */
18 
19 #ifndef _SYS_PTRACE_H
20 #define _SYS_PTRACE_H	1
21 
22 #include <features.h>
23 
24 __BEGIN_DECLS
25 
26 /* Type of the REQUEST argument to `ptrace.'  */
27 enum __ptrace_request
28 {
29   /* Indicate that the process making this request should be traced.
30      All signals received by this process can be intercepted by its
31      parent, and its parent can use the other `ptrace' requests.  */
32   PTRACE_TRACEME = 0,
33 #define PT_TRACE_ME PTRACE_TRACEME
34 
35   /* Return the word in the process's text space at address ADDR.  */
36   PTRACE_PEEKTEXT = 1,
37 #define PT_READ_I PTRACE_PEEKTEXT
38 
39   /* Return the word in the process's data space at address ADDR.  */
40   PTRACE_PEEKDATA = 2,
41 #define PT_READ_D PTRACE_PEEKDATA
42 
43   /* Return the word in the process's user area at offset ADDR.  */
44   PTRACE_PEEKUSER = 3,
45 #define PT_READ_U PTRACE_PEEKUSER
46 
47   /* Write the word DATA into the process's text space at address ADDR.  */
48   PTRACE_POKETEXT = 4,
49 #define PT_WRITE_I PTRACE_POKETEXT
50 
51   /* Write the word DATA into the process's data space at address ADDR.  */
52   PTRACE_POKEDATA = 5,
53 #define PT_WRITE_D PTRACE_POKEDATA
54 
55   /* Write the word DATA into the process's user area at offset ADDR.  */
56   PTRACE_POKEUSER = 6,
57 #define PT_WRITE_U PTRACE_POKEUSER
58 
59   /* Continue the process.  */
60   PTRACE_CONT = 7,
61 #define PT_CONTINUE PTRACE_CONT
62 
63   /* Kill the process.  */
64   PTRACE_KILL = 8,
65 #define PT_KILL PTRACE_KILL
66 
67   /* Single step the process.
68      This is not supported on all machines.  */
69   PTRACE_SINGLESTEP = 9,
70 #define PT_STEP PTRACE_SINGLESTEP
71 
72   /* Get all general purpose registers used by a processes.
73      This is not supported on all machines.  */
74    PTRACE_GETREGS = 12,
75 #define PT_GETREGS PTRACE_GETREGS
76 
77   /* Set all general purpose registers used by a processes.
78      This is not supported on all machines.  */
79    PTRACE_SETREGS = 13,
80 #define PT_SETREGS PTRACE_SETREGS
81 
82   /* Get all floating point registers used by a processes.
83      This is not supported on all machines.  */
84    PTRACE_GETFPREGS = 14,
85 #define PT_GETFPREGS PTRACE_GETFPREGS
86 
87   /* Set all floating point registers used by a processes.
88      This is not supported on all machines.  */
89    PTRACE_SETFPREGS = 15,
90 #define PT_SETFPREGS PTRACE_SETFPREGS
91 
92   /* Attach to a process that is already running. */
93   PTRACE_ATTACH = 16,
94 #define PT_ATTACH PTRACE_ATTACH
95 
96   /* Detach from a process attached to with PTRACE_ATTACH.  */
97   PTRACE_DETACH = 17,
98 #define PT_DETACH PTRACE_DETACH
99 
100   /* Get all extended floating point registers used by a processes.
101      This is not supported on all machines.  */
102    PTRACE_GETFPXREGS = 18,
103 #define PT_GETFPXREGS PTRACE_GETFPXREGS
104 
105   /* Set all extended floating point registers used by a processes.
106      This is not supported on all machines.  */
107    PTRACE_SETFPXREGS = 19,
108 #define PT_SETFPXREGS PTRACE_SETFPXREGS
109 
110   /* Continue and stop at the next (return from) syscall.  */
111   PTRACE_SYSCALL = 24,
112 #define PT_SYSCALL PTRACE_SYSCALL
113 
114   /* Set ptrace filter options.  */
115   PTRACE_SETOPTIONS = 0x4200,
116 #define PT_SETOPTIONS PTRACE_SETOPTIONS
117 
118   /* Get last ptrace message.  */
119   PTRACE_GETEVENTMSG = 0x4201,
120 #define PT_GETEVENTMSG PTRACE_GETEVENTMSG
121 
122   /* Get siginfo for process.  */
123   PTRACE_GETSIGINFO = 0x4202,
124 #define PT_GETSIGINFO PTRACE_GETSIGINFO
125 
126   /* Set new siginfo for process.  */
127   PTRACE_SETSIGINFO = 0x4203,
128 #define PT_SETSIGINFO PTRACE_SETSIGINFO
129 
130   /* Get register content.  */
131   PTRACE_GETREGSET = 0x4204,
132 #define PTRACE_GETREGSET PTRACE_GETREGSET
133 
134   /* Set register content.  */
135   PTRACE_SETREGSET = 0x4205,
136 #define PTRACE_SETREGSET PTRACE_SETREGSET
137 
138   /* Like PTRACE_ATTACH, but do not force tracee to trap and do not affect
139      signal or group stop state.  */
140   PTRACE_SEIZE = 0x4206,
141 #define PTRACE_SEIZE PTRACE_SEIZE
142 
143   /* Trap seized tracee.  */
144   PTRACE_INTERRUPT = 0x4207,
145 #define PTRACE_INTERRUPT PTRACE_INTERRUPT
146 
147   /* Wait for next group event.  */
148   PTRACE_LISTEN = 0x4208
149 };
150 
151 
152 /* Flag for PTRACE_LISTEN.  */
153 enum __ptrace_flags
154 {
155   PTRACE_SEIZE_DEVEL = 0x80000000
156 };
157 
158 /* Options set using PTRACE_SETOPTIONS.  */
159 enum __ptrace_setoptions
160 {
161   PTRACE_O_TRACESYSGOOD	= 0x00000001,
162   PTRACE_O_TRACEFORK	= 0x00000002,
163   PTRACE_O_TRACEVFORK   = 0x00000004,
164   PTRACE_O_TRACECLONE	= 0x00000008,
165   PTRACE_O_TRACEEXEC	= 0x00000010,
166   PTRACE_O_TRACEVFORKDONE = 0x00000020,
167   PTRACE_O_TRACEEXIT	= 0x00000040,
168   PTRACE_O_TRACESECCOMP = 0x00000080,
169   PTRACE_O_MASK		= 0x000000ff
170 };
171 
172 /* Wait extended result codes for the above trace options.  */
173 enum __ptrace_eventcodes
174 {
175   PTRACE_EVENT_FORK	= 1,
176   PTRACE_EVENT_VFORK	= 2,
177   PTRACE_EVENT_CLONE	= 3,
178   PTRACE_EVENT_EXEC	= 4,
179   PTRACE_EVENT_VFORK_DONE = 5,
180   PTRACE_EVENT_EXIT	= 6,
181   PTRAVE_EVENT_SECCOMP  = 7
182 };
183 
184 /* Perform process tracing functions.  REQUEST is one of the values
185    above, and determines the action to be taken.
186    For all requests except PTRACE_TRACEME, PID specifies the process to be
187    traced.
188 
189    PID and the other arguments described above for the various requests should
190    appear (those that are used for the particular request) as:
191      pid_t PID, void *ADDR, int DATA, void *ADDR2
192    after REQUEST.  */
193 extern long int ptrace (enum __ptrace_request __request, ...) __THROW;
194 
195 __END_DECLS
196 
197 #endif /* _SYS_PTRACE_H */
198