ptrace.h 5.4 KB

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