1
0

ptrace.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /* `ptrace' debugger support interface. Linux/x86 version.
  17. Copyright (C) 1996-2026 Free Software Foundation, Inc.
  18. This file is part of the GNU C Library.
  19. The GNU C Library is free software; you can redistribute it and/or
  20. modify it under the terms of the GNU Lesser General Public
  21. License as published by the Free Software Foundation; either
  22. version 2.1 of the License, or (at your option) any later version.
  23. The GNU C Library is distributed in the hope that it will be useful,
  24. but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  26. Lesser General Public License for more details.
  27. You should have received a copy of the GNU Lesser General Public
  28. License along with the GNU C Library; if not, see
  29. <https://www.gnu.org/licenses/>. */
  30. #ifndef _SYS_PTRACE_H
  31. #define _SYS_PTRACE_H 1
  32. #include <features.h>
  33. #include <bits/types.h>
  34. __BEGIN_DECLS
  35. /* Type of the REQUEST argument to `ptrace.' */
  36. enum __ptrace_request
  37. {
  38. /* Indicate that the process making this request should be traced.
  39. All signals received by this process can be intercepted by its
  40. parent, and its parent can use the other `ptrace' requests. */
  41. PTRACE_TRACEME = 0,
  42. #define PT_TRACE_ME PTRACE_TRACEME
  43. /* Return the word in the process's text space at address ADDR. */
  44. PTRACE_PEEKTEXT = 1,
  45. #define PT_READ_I PTRACE_PEEKTEXT
  46. /* Return the word in the process's data space at address ADDR. */
  47. PTRACE_PEEKDATA = 2,
  48. #define PT_READ_D PTRACE_PEEKDATA
  49. /* Return the word in the process's user area at offset ADDR. */
  50. PTRACE_PEEKUSER = 3,
  51. #define PT_READ_U PTRACE_PEEKUSER
  52. /* Write the word DATA into the process's text space at address ADDR. */
  53. PTRACE_POKETEXT = 4,
  54. #define PT_WRITE_I PTRACE_POKETEXT
  55. /* Write the word DATA into the process's data space at address ADDR. */
  56. PTRACE_POKEDATA = 5,
  57. #define PT_WRITE_D PTRACE_POKEDATA
  58. /* Write the word DATA into the process's user area at offset ADDR. */
  59. PTRACE_POKEUSER = 6,
  60. #define PT_WRITE_U PTRACE_POKEUSER
  61. /* Continue the process. */
  62. PTRACE_CONT = 7,
  63. #define PT_CONTINUE PTRACE_CONT
  64. /* Kill the process. */
  65. PTRACE_KILL = 8,
  66. #define PT_KILL PTRACE_KILL
  67. /* Single step the process. */
  68. PTRACE_SINGLESTEP = 9,
  69. #define PT_STEP PTRACE_SINGLESTEP
  70. /* Get all general purpose registers used by a processes. */
  71. PTRACE_GETREGS = 12,
  72. #define PT_GETREGS PTRACE_GETREGS
  73. /* Set all general purpose registers used by a processes. */
  74. PTRACE_SETREGS = 13,
  75. #define PT_SETREGS PTRACE_SETREGS
  76. /* Get all floating point registers used by a processes. */
  77. PTRACE_GETFPREGS = 14,
  78. #define PT_GETFPREGS PTRACE_GETFPREGS
  79. /* Set all floating point registers used by a processes. */
  80. PTRACE_SETFPREGS = 15,
  81. #define PT_SETFPREGS PTRACE_SETFPREGS
  82. /* Attach to a process that is already running. */
  83. PTRACE_ATTACH = 16,
  84. #define PT_ATTACH PTRACE_ATTACH
  85. /* Detach from a process attached to with PTRACE_ATTACH. */
  86. PTRACE_DETACH = 17,
  87. #define PT_DETACH PTRACE_DETACH
  88. /* Get all extended floating point registers used by a processes. */
  89. PTRACE_GETFPXREGS = 18,
  90. #define PT_GETFPXREGS PTRACE_GETFPXREGS
  91. /* Set all extended floating point registers used by a processes. */
  92. PTRACE_SETFPXREGS = 19,
  93. #define PT_SETFPXREGS PTRACE_SETFPXREGS
  94. /* Continue and stop at the next entry to or return from syscall. */
  95. PTRACE_SYSCALL = 24,
  96. #define PT_SYSCALL PTRACE_SYSCALL
  97. /* Get a TLS entry in the GDT. */
  98. PTRACE_GET_THREAD_AREA = 25,
  99. #define PT_GET_THREAD_AREA PTRACE_GET_THREAD_AREA
  100. /* Change a TLS entry in the GDT. */
  101. PTRACE_SET_THREAD_AREA = 26,
  102. #define PT_SET_THREAD_AREA PTRACE_SET_THREAD_AREA
  103. #ifdef __x86_64__
  104. /* Access TLS data. */
  105. PTRACE_ARCH_PRCTL = 30,
  106. # define PT_ARCH_PRCTL PTRACE_ARCH_PRCTL
  107. #endif
  108. /* Continue and stop at the next syscall, it will not be executed. */
  109. PTRACE_SYSEMU = 31,
  110. #define PT_SYSEMU PTRACE_SYSEMU
  111. /* Single step the process, the next syscall will not be executed. */
  112. PTRACE_SYSEMU_SINGLESTEP = 32,
  113. #define PT_SYSEMU_SINGLESTEP PTRACE_SYSEMU_SINGLESTEP
  114. /* Execute process until next taken branch. */
  115. PTRACE_SINGLEBLOCK = 33,
  116. #define PT_STEPBLOCK PTRACE_SINGLEBLOCK
  117. /* Set ptrace filter options. */
  118. PTRACE_SETOPTIONS = 0x4200,
  119. #define PT_SETOPTIONS PTRACE_SETOPTIONS
  120. /* Get last ptrace message. */
  121. PTRACE_GETEVENTMSG = 0x4201,
  122. #define PT_GETEVENTMSG PTRACE_GETEVENTMSG
  123. /* Get siginfo for process. */
  124. PTRACE_GETSIGINFO = 0x4202,
  125. #define PT_GETSIGINFO PTRACE_GETSIGINFO
  126. /* Set new siginfo for process. */
  127. PTRACE_SETSIGINFO = 0x4203,
  128. #define PT_SETSIGINFO PTRACE_SETSIGINFO
  129. /* Get register content. */
  130. PTRACE_GETREGSET = 0x4204,
  131. #define PTRACE_GETREGSET PTRACE_GETREGSET
  132. /* Set register content. */
  133. PTRACE_SETREGSET = 0x4205,
  134. #define PTRACE_SETREGSET PTRACE_SETREGSET
  135. /* Like PTRACE_ATTACH, but do not force tracee to trap and do not affect
  136. signal or group stop state. */
  137. PTRACE_SEIZE = 0x4206,
  138. #define PTRACE_SEIZE PTRACE_SEIZE
  139. /* Trap seized tracee. */
  140. PTRACE_INTERRUPT = 0x4207,
  141. #define PTRACE_INTERRUPT PTRACE_INTERRUPT
  142. /* Wait for next group event. */
  143. PTRACE_LISTEN = 0x4208,
  144. #define PTRACE_LISTEN PTRACE_LISTEN
  145. /* Retrieve siginfo_t structures without removing signals from a queue. */
  146. PTRACE_PEEKSIGINFO = 0x4209,
  147. #define PTRACE_PEEKSIGINFO PTRACE_PEEKSIGINFO
  148. /* Get the mask of blocked signals. */
  149. PTRACE_GETSIGMASK = 0x420a,
  150. #define PTRACE_GETSIGMASK PTRACE_GETSIGMASK
  151. /* Change the mask of blocked signals. */
  152. PTRACE_SETSIGMASK = 0x420b,
  153. #define PTRACE_SETSIGMASK PTRACE_SETSIGMASK
  154. /* Get seccomp BPF filters. */
  155. PTRACE_SECCOMP_GET_FILTER = 0x420c,
  156. #define PTRACE_SECCOMP_GET_FILTER PTRACE_SECCOMP_GET_FILTER
  157. /* Get seccomp BPF filter metadata. */
  158. PTRACE_SECCOMP_GET_METADATA = 0x420d,
  159. #define PTRACE_SECCOMP_GET_METADATA PTRACE_SECCOMP_GET_METADATA
  160. /* Get information about system call. */
  161. PTRACE_GET_SYSCALL_INFO = 0x420e,
  162. #define PTRACE_GET_SYSCALL_INFO PTRACE_GET_SYSCALL_INFO
  163. /* Get rseq configuration information. */
  164. PTRACE_GET_RSEQ_CONFIGURATION = 0x420f,
  165. #define PTRACE_GET_RSEQ_CONFIGURATION PTRACE_GET_RSEQ_CONFIGURATION
  166. /* Set configuration for syscall user dispatch. */
  167. PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG = 0x4210,
  168. #define PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG \
  169. PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG
  170. /* Get configuration for syscall user dispatch. */
  171. PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG = 0x4211
  172. #define PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG \
  173. PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG
  174. };
  175. #include <bits/ptrace-shared.h>
  176. __END_DECLS
  177. #endif /* _SYS_PTRACE_H */