1 /* `ptrace' debugger support interface. Linux/SPARC version. 2 Copyright (C) 1996-2014 Free Software Foundation, Inc. 3 4 The GNU C Library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 2.1 of the License, or (at your option) any later version. 8 9 The GNU C Library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 14 You should have received a copy of the GNU Lesser General Public 15 License along with the GNU C Library; if not, see 16 <http://www.gnu.org/licenses/>. */ 17 18 #ifndef _SYS_PTRACE_H 19 #define _SYS_PTRACE_H 1 20 21 #include <features.h> 22 #include <bits/types.h> 23 24 /* Linux/SPARC kernels up to 2.3.18 do not care much 25 about what namespace polution, so use a kludge now. */ 26 #undef PTRACE_GETREGS 27 #undef PTRACE_SETREGS 28 #undef PTRACE_GETFPREGS 29 #undef PTRACE_SETFPREGS 30 #undef PTRACE_READDATA 31 #undef PTRACE_WRITEDATA 32 #undef PTRACE_READTEXT 33 #undef PTRACE_WRITETEXT 34 #undef PTRACE_SUNDETACH 35 36 __BEGIN_DECLS 37 38 /* Type of the REQUEST argument to `ptrace.' */ 39 enum __ptrace_request 40 { 41 /* Indicate that the process making this request should be traced. 42 All signals received by this process can be intercepted by its 43 parent, and its parent can use the other `ptrace' requests. */ 44 PTRACE_TRACEME = 0, 45 #define PT_TRACE_ME PTRACE_TRACEME 46 47 /* Return the word in the process's text space at address ADDR. */ 48 PTRACE_PEEKTEXT = 1, 49 #define PT_READ_I PTRACE_PEEKTEXT 50 51 /* Return the word in the process's data space at address ADDR. */ 52 PTRACE_PEEKDATA = 2, 53 #define PT_READ_D PTRACE_PEEKDATA 54 55 /* Return the word in the process's user area at offset ADDR. */ 56 PTRACE_PEEKUSER = 3, 57 #define PT_READ_U PTRACE_PEEKUSER 58 59 /* Write the word DATA into the process's text space at address ADDR. */ 60 PTRACE_POKETEXT = 4, 61 #define PT_WRITE_I PTRACE_POKETEXT 62 63 /* Write the word DATA into the process's data space at address ADDR. */ 64 PTRACE_POKEDATA = 5, 65 #define PT_WRITE_D PTRACE_POKEDATA 66 67 /* Write the word DATA into the process's user area at offset ADDR. */ 68 PTRACE_POKEUSER = 6, 69 #define PT_WRITE_U PTRACE_POKEUSER 70 71 /* Continue the process. */ 72 PTRACE_CONT = 7, 73 #define PT_CONTINUE PTRACE_CONT 74 75 /* Kill the process. */ 76 PTRACE_KILL = 8, 77 #define PT_KILL PTRACE_KILL 78 79 /* Single step the process. 80 This is not supported on all machines. */ 81 PTRACE_SINGLESTEP = 9, 82 #define PT_STEP PTRACE_SINGLESTEP 83 84 /* Detach from a process attached to with PTRACE_ATTACH. */ 85 PTRACE_DETACH = 11, 86 #define PT_DETACH PTRACE_DETACH 87 88 /* This define is needed for older programs which were 89 trying to work around sparc-linux ptrace nastiness. */ 90 #define PTRACE_SUNDETACH PTRACE_DETACH 91 92 /* Get all general purpose registers used by a processes. 93 This is not supported on all machines. */ 94 PTRACE_GETREGS = 12, 95 #define PT_GETREGS PTRACE_GETREGS 96 97 /* Set all general purpose registers used by a processes. 98 This is not supported on all machines. */ 99 PTRACE_SETREGS = 13, 100 #define PT_SETREGS PTRACE_SETREGS 101 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 106 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 111 112 /* Attach to a process that is already running. */ 113 PTRACE_ATTACH = 16, 114 #define PT_ATTACH PTRACE_ATTACH 115 116 /* Write several bytes at a time. */ 117 PTRACE_WRITEDATA = 17, 118 #define PTRACE_WRITEDATA PTRACE_WRITEDATA 119 120 /* Read several bytes at a time. */ 121 PTRACE_READTEXT = 18, 122 #define PTRACE_READTEXT PTRACE_READTEXT 123 #define PTRACE_READDATA PTRACE_READTEXT 124 125 /* Write several bytes at a time. */ 126 PTRACE_WRITETEXT = 19, 127 #define PTRACE_WRITETEXT PTRACE_WRITETEXT 128 129 /* Continue and stop at the next (return from) syscall. */ 130 PTRACE_SYSCALL = 24, 131 #define PTRACE_SYSCALL PTRACE_SYSCALL 132 133 /* Set ptrace filter options. */ 134 PTRACE_SETOPTIONS = 0x4200, 135 #define PT_SETOPTIONS PTRACE_SETOPTIONS 136 137 /* Get last ptrace message. */ 138 PTRACE_GETEVENTMSG = 0x4201, 139 #define PT_GETEVENTMSG PTRACE_GETEVENTMSG 140 141 /* Get siginfo for process. */ 142 PTRACE_GETSIGINFO = 0x4202, 143 #define PT_GETSIGINFO PTRACE_GETSIGINFO 144 145 /* Set new siginfo for process. */ 146 PTRACE_SETSIGINFO = 0x4203, 147 #define PT_SETSIGINFO PTRACE_SETSIGINFO 148 149 /* Get register content. */ 150 PTRACE_GETREGSET = 0x4204, 151 #define PTRACE_GETREGSET PTRACE_GETREGSET 152 153 /* Set register content. */ 154 PTRACE_SETREGSET = 0x4205, 155 #define PTRACE_SETREGSET PTRACE_SETREGSET 156 157 /* Like PTRACE_ATTACH, but do not force tracee to trap and do not affect 158 signal or group stop state. */ 159 PTRACE_SEIZE = 0x4206, 160 #define PTRACE_SEIZE PTRACE_SEIZE 161 162 /* Trap seized tracee. */ 163 PTRACE_INTERRUPT = 0x4207, 164 #define PTRACE_INTERRUPT PTRACE_INTERRUPT 165 166 /* Wait for next group event. */ 167 PTRACE_LISTEN = 0x4208, 168 #define PTRACE_LISTEN PTRACE_LISTEN 169 170 PTRACE_PEEKSIGINFO = 0x4209 171 #define PTRACE_PEEKSIGINFO PTRACE_PEEKSIGINFO 172 }; 173 174 /* Options set using PTRACE_SETOPTIONS. */ 175 enum __ptrace_setoptions 176 { 177 PTRACE_O_TRACESYSGOOD = 0x00000001, 178 PTRACE_O_TRACEFORK = 0x00000002, 179 PTRACE_O_TRACEVFORK = 0x00000004, 180 PTRACE_O_TRACECLONE = 0x00000008, 181 PTRACE_O_TRACEEXEC = 0x00000010, 182 PTRACE_O_TRACEVFORKDONE = 0x00000020, 183 PTRACE_O_TRACEEXIT = 0x00000040, 184 PTRACE_O_TRACESECCOMP = 0x00000080, 185 PTRACE_O_EXITKILL = 0x00100000, 186 PTRACE_O_MASK = 0x001000ff 187 }; 188 189 /* Wait extended result codes for the above trace options. */ 190 enum __ptrace_eventcodes 191 { 192 PTRACE_EVENT_FORK = 1, 193 PTRACE_EVENT_VFORK = 2, 194 PTRACE_EVENT_CLONE = 3, 195 PTRACE_EVENT_EXEC = 4, 196 PTRACE_EVENT_VFORK_DONE = 5, 197 PTRACE_EVENT_EXIT = 6, 198 PTRACE_EVENT_SECCOMP = 7 199 }; 200 201 /* Arguments for PTRACE_PEEKSIGINFO. */ 202 struct __ptrace_peeksiginfo_args 203 { 204 __uint64_t off; /* From which siginfo to start. */ 205 __uint32_t flags; /* Flags for peeksiginfo. */ 206 __int32_t nr; /* How many siginfos to take. */ 207 }; 208 209 enum __ptrace_peeksiginfo_flags 210 { 211 /* Read signals from a shared (process wide) queue. */ 212 PTRACE_PEEKSIGINFO_SHARED = (1 << 0) 213 }; 214 215 /* Perform process tracing functions. REQUEST is one of the values 216 above, and determines the action to be taken. 217 For all requests except PTRACE_TRACEME, PID specifies the process to be 218 traced. 219 220 PID and the other arguments described above for the various requests should 221 appear (those that are used for the particular request) as: 222 pid_t PID, void *ADDR, int DATA, void *ADDR2 223 after REQUEST. */ 224 extern long int ptrace (enum __ptrace_request __request, ...) __THROW; 225 226 __END_DECLS 227 228 #endif /* _SYS_PTRACE_H */ 229