ptrace.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #ifndef _SYS_PTRACE_H
  2. #define _SYS_PTRACE_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <stdint.h>
  7. #define PTRACE_TRACEME 0
  8. #define PT_TRACE_ME PTRACE_TRACEME
  9. #define PTRACE_PEEKTEXT 1
  10. #define PTRACE_PEEKDATA 2
  11. #define PTRACE_PEEKUSER 3
  12. #define PTRACE_POKETEXT 4
  13. #define PTRACE_POKEDATA 5
  14. #define PTRACE_POKEUSER 6
  15. #define PTRACE_CONT 7
  16. #define PTRACE_KILL 8
  17. #define PTRACE_SINGLESTEP 9
  18. #define PTRACE_GETREGS 12
  19. #define PTRACE_SETREGS 13
  20. #define PTRACE_GETFPREGS 14
  21. #define PTRACE_SETFPREGS 15
  22. #define PTRACE_ATTACH 16
  23. #define PTRACE_DETACH 17
  24. #define PTRACE_GETFPXREGS 18
  25. #define PTRACE_SETFPXREGS 19
  26. #define PTRACE_SYSCALL 24
  27. #define PTRACE_SETOPTIONS 0x4200
  28. #define PTRACE_GETEVENTMSG 0x4201
  29. #define PTRACE_GETSIGINFO 0x4202
  30. #define PTRACE_SETSIGINFO 0x4203
  31. #define PTRACE_GETREGSET 0x4204
  32. #define PTRACE_SETREGSET 0x4205
  33. #define PTRACE_SEIZE 0x4206
  34. #define PTRACE_INTERRUPT 0x4207
  35. #define PTRACE_LISTEN 0x4208
  36. #define PTRACE_PEEKSIGINFO 0x4209
  37. #define PTRACE_GETSIGMASK 0x420a
  38. #define PTRACE_SETSIGMASK 0x420b
  39. #define PTRACE_SECCOMP_GET_FILTER 0x420c
  40. #define PTRACE_SECCOMP_GET_METADATA 0x420d
  41. #define PTRACE_GET_SYSCALL_INFO 0x420e
  42. #define PTRACE_GET_RSEQ_CONFIGURATION 0x420f
  43. #define PT_READ_I PTRACE_PEEKTEXT
  44. #define PT_READ_D PTRACE_PEEKDATA
  45. #define PT_READ_U PTRACE_PEEKUSER
  46. #define PT_WRITE_I PTRACE_POKETEXT
  47. #define PT_WRITE_D PTRACE_POKEDATA
  48. #define PT_WRITE_U PTRACE_POKEUSER
  49. #define PT_CONTINUE PTRACE_CONT
  50. #define PT_KILL PTRACE_KILL
  51. #define PT_STEP PTRACE_SINGLESTEP
  52. #define PT_GETREGS PTRACE_GETREGS
  53. #define PT_SETREGS PTRACE_SETREGS
  54. #define PT_GETFPREGS PTRACE_GETFPREGS
  55. #define PT_SETFPREGS PTRACE_SETFPREGS
  56. #define PT_ATTACH PTRACE_ATTACH
  57. #define PT_DETACH PTRACE_DETACH
  58. #define PT_GETFPXREGS PTRACE_GETFPXREGS
  59. #define PT_SETFPXREGS PTRACE_SETFPXREGS
  60. #define PT_SYSCALL PTRACE_SYSCALL
  61. #define PT_SETOPTIONS PTRACE_SETOPTIONS
  62. #define PT_GETEVENTMSG PTRACE_GETEVENTMSG
  63. #define PT_GETSIGINFO PTRACE_GETSIGINFO
  64. #define PT_SETSIGINFO PTRACE_SETSIGINFO
  65. #define PTRACE_O_TRACESYSGOOD 0x00000001
  66. #define PTRACE_O_TRACEFORK 0x00000002
  67. #define PTRACE_O_TRACEVFORK 0x00000004
  68. #define PTRACE_O_TRACECLONE 0x00000008
  69. #define PTRACE_O_TRACEEXEC 0x00000010
  70. #define PTRACE_O_TRACEVFORKDONE 0x00000020
  71. #define PTRACE_O_TRACEEXIT 0x00000040
  72. #define PTRACE_O_TRACESECCOMP 0x00000080
  73. #define PTRACE_O_EXITKILL 0x00100000
  74. #define PTRACE_O_SUSPEND_SECCOMP 0x00200000
  75. #define PTRACE_O_MASK 0x003000ff
  76. #define PTRACE_EVENT_FORK 1
  77. #define PTRACE_EVENT_VFORK 2
  78. #define PTRACE_EVENT_CLONE 3
  79. #define PTRACE_EVENT_EXEC 4
  80. #define PTRACE_EVENT_VFORK_DONE 5
  81. #define PTRACE_EVENT_EXIT 6
  82. #define PTRACE_EVENT_SECCOMP 7
  83. #define PTRACE_EVENT_STOP 128
  84. #define PTRACE_PEEKSIGINFO_SHARED 1
  85. #define PTRACE_SYSCALL_INFO_NONE 0
  86. #define PTRACE_SYSCALL_INFO_ENTRY 1
  87. #define PTRACE_SYSCALL_INFO_EXIT 2
  88. #define PTRACE_SYSCALL_INFO_SECCOMP 3
  89. #include <bits/ptrace.h>
  90. struct __ptrace_peeksiginfo_args {
  91. uint64_t off;
  92. uint32_t flags;
  93. int32_t nr;
  94. };
  95. struct __ptrace_seccomp_metadata {
  96. uint64_t filter_off;
  97. uint64_t flags;
  98. };
  99. struct __ptrace_syscall_info {
  100. uint8_t op;
  101. uint8_t __pad[3];
  102. uint32_t arch;
  103. uint64_t instruction_pointer;
  104. uint64_t stack_pointer;
  105. union {
  106. struct {
  107. uint64_t nr;
  108. uint64_t args[6];
  109. } entry;
  110. struct {
  111. int64_t rval;
  112. uint8_t is_error;
  113. } exit;
  114. struct {
  115. uint64_t nr;
  116. uint64_t args[6];
  117. uint32_t ret_data;
  118. } seccomp;
  119. };
  120. };
  121. struct __ptrace_rseq_configuration {
  122. uint64_t rseq_abi_pointer;
  123. uint32_t rseq_abi_size;
  124. uint32_t signature;
  125. uint32_t flags;
  126. uint32_t pad;
  127. };
  128. long ptrace(int, ...);
  129. #ifdef __cplusplus
  130. }
  131. #endif
  132. #endif