ptrace.h 6.7 KB

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