ptrace.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /* `ptrace' debugger support interface. Linux/Tile version.
  2. Copyright (C) 2011-2018 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. __BEGIN_DECLS
  19. /* Type of the REQUEST argument to `ptrace.' */
  20. enum __ptrace_request
  21. {
  22. /* Indicate that the process making this request should be traced.
  23. All signals received by this process can be intercepted by its
  24. parent, and its parent can use the other `ptrace' requests. */
  25. PTRACE_TRACEME = 0,
  26. #define PT_TRACE_ME PTRACE_TRACEME
  27. /* Return the word in the process's text space at address ADDR. */
  28. PTRACE_PEEKTEXT = 1,
  29. #define PT_READ_I PTRACE_PEEKTEXT
  30. /* Return the word in the process's data space at address ADDR. */
  31. PTRACE_PEEKDATA = 2,
  32. #define PT_READ_D PTRACE_PEEKDATA
  33. /* Return the word in the process's user area at offset ADDR. */
  34. PTRACE_PEEKUSER = 3,
  35. #define PT_READ_U PTRACE_PEEKUSER
  36. /* Write the word DATA into the process's text space at address ADDR. */
  37. PTRACE_POKETEXT = 4,
  38. #define PT_WRITE_I PTRACE_POKETEXT
  39. /* Write the word DATA into the process's data space at address ADDR. */
  40. PTRACE_POKEDATA = 5,
  41. #define PT_WRITE_D PTRACE_POKEDATA
  42. /* Write the word DATA into the process's user area at offset ADDR. */
  43. PTRACE_POKEUSER = 6,
  44. #define PT_WRITE_U PTRACE_POKEUSER
  45. /* Continue the process. */
  46. PTRACE_CONT = 7,
  47. #define PT_CONTINUE PTRACE_CONT
  48. /* Kill the process. */
  49. PTRACE_KILL = 8,
  50. #define PT_KILL PTRACE_KILL
  51. /* Single step the process. */
  52. PTRACE_SINGLESTEP = 9,
  53. #define PT_STEP PTRACE_SINGLESTEP
  54. /* Get all general purpose registers used by a processes. */
  55. PTRACE_GETREGS = 12,
  56. #define PT_GETREGS PTRACE_GETREGS
  57. /* Set all general purpose registers used by a processes. */
  58. PTRACE_SETREGS = 13,
  59. #define PT_SETREGS PTRACE_SETREGS
  60. /* Attach to a process that is already running. */
  61. PTRACE_ATTACH = 16,
  62. #define PT_ATTACH PTRACE_ATTACH
  63. /* Detach from a process attached to with PTRACE_ATTACH. */
  64. PTRACE_DETACH = 17,
  65. #define PT_DETACH PTRACE_DETACH
  66. /* Continue and stop at the next entry to or return from syscall. */
  67. PTRACE_SYSCALL = 24,
  68. #define PT_SYSCALL PTRACE_SYSCALL
  69. /* Set ptrace filter options. */
  70. PTRACE_SETOPTIONS = 0x4200,
  71. #define PT_SETOPTIONS PTRACE_SETOPTIONS
  72. /* Get last ptrace message. */
  73. PTRACE_GETEVENTMSG = 0x4201,
  74. #define PT_GETEVENTMSG PTRACE_GETEVENTMSG
  75. /* Get siginfo for process. */
  76. PTRACE_GETSIGINFO = 0x4202,
  77. #define PT_GETSIGINFO PTRACE_GETSIGINFO
  78. /* Set new siginfo for process. */
  79. PTRACE_SETSIGINFO = 0x4203,
  80. #define PT_SETSIGINFO PTRACE_SETSIGINFO
  81. /* Set register content. */
  82. PTRACE_SETREGSET = 0x4205,
  83. #define PTRACE_SETREGSET PTRACE_SETREGSET
  84. /* Like PTRACE_ATTACH, but do not force tracee to trap and do not affect
  85. signal or group stop state. */
  86. PTRACE_SEIZE = 0x4206,
  87. #define PTRACE_SEIZE PTRACE_SEIZE
  88. /* Trap seized tracee. */
  89. PTRACE_INTERRUPT = 0x4207,
  90. #define PTRACE_INTERRUPT PTRACE_INTERRUPT
  91. /* Wait for next group event. */
  92. PTRACE_LISTEN = 0x4208,
  93. #define PTRACE_LISTEN PTRACE_LISTEN
  94. /* Retrieve siginfo_t structures without removing signals from a queue. */
  95. PTRACE_PEEKSIGINFO = 0x4209,
  96. #define PTRACE_PEEKSIGINFO PTRACE_PEEKSIGINFO
  97. /* Get the mask of blocked signals. */
  98. PTRACE_GETSIGMASK = 0x420a,
  99. #define PTRACE_GETSIGMASK PTRACE_GETSIGMASK
  100. /* Change the mask of blocked signals. */
  101. PTRACE_SETSIGMASK = 0x420b,
  102. #define PTRACE_SETSIGMASK PTRACE_SETSIGMASK
  103. /* Get seccomp BPF filters. */
  104. PTRACE_SECCOMP_GET_FILTER = 0x420c
  105. #define PTRACE_SECCOMP_GET_FILTER PTRACE_SECCOMP_GET_FILTER
  106. };
  107. /* Options set using PTRACE_SETOPTIONS. */
  108. enum __ptrace_setoptions
  109. {
  110. PTRACE_O_TRACESYSGOOD = 0x00000001,
  111. PTRACE_O_TRACEFORK = 0x00000002,
  112. PTRACE_O_TRACEVFORK = 0x00000004,
  113. PTRACE_O_TRACECLONE = 0x00000008,
  114. PTRACE_O_TRACEEXEC = 0x00000010,
  115. PTRACE_O_TRACEVFORKDONE = 0x00000020,
  116. PTRACE_O_TRACEEXIT = 0x00000040,
  117. PTRACE_O_TRACESECCOMP = 0x00000080,
  118. PTRACE_O_EXITKILL = 0x00100000,
  119. PTRACE_O_SUSPEND_SECCOMP = 0x00200000,
  120. PTRACE_O_MASK = 0x003000ff
  121. };
  122. enum __ptrace_eventcodes
  123. {
  124. /* Wait extended result codes for the above trace options. */
  125. PTRACE_EVENT_FORK = 1,
  126. PTRACE_EVENT_VFORK = 2,
  127. PTRACE_EVENT_CLONE = 3,
  128. PTRACE_EVENT_EXEC = 4,
  129. PTRACE_EVENT_VFORK_DONE = 5,
  130. PTRACE_EVENT_EXIT = 6,
  131. PTRACE_EVENT_SECCOMP = 7,
  132. /* Extended result codes enabled by means other than options. */
  133. PTRACE_EVENT_STOP = 128
  134. };
  135. /* Arguments for PTRACE_PEEKSIGINFO. */
  136. struct __ptrace_peeksiginfo_args
  137. {
  138. __uint64_t off; /* From which siginfo to start. */
  139. __uint32_t flags; /* Flags for peeksiginfo. */
  140. __int32_t nr; /* How many siginfos to take. */
  141. };
  142. enum __ptrace_peeksiginfo_flags
  143. {
  144. /* Read signals from a shared (process wide) queue. */
  145. PTRACE_PEEKSIGINFO_SHARED = (1 << 0)
  146. };
  147. /* Perform process tracing functions. REQUEST is one of the values
  148. above, and determines the action to be taken.
  149. For all requests except PTRACE_TRACEME, PID specifies the process to be
  150. traced.
  151. PID and the other arguments described above for the various requests should
  152. appear (those that are used for the particular request) as:
  153. pid_t PID, void *ADDR, int DATA, void *ADDR2
  154. after REQUEST. */
  155. extern long int ptrace (enum __ptrace_request __request, ...) __THROW;
  156. __END_DECLS
  157. #endif /* _SYS_PTRACE_H */