ptrace.h 7.6 KB

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