Mirror of strace – the linux syscall tracer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ptrace.h 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*
  2. * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
  3. * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
  4. * Copyright (c) 1993-1996 Rick Sladkey <jrs@world.std.com>
  5. * Copyright (c) 2004 Roland McGrath <roland@redhat.com>
  6. * Copyright (c) 2010 Wang Chao <wang.chao@cn.fujitsu.com>
  7. * Copyright (c) 2011-2013 Denys Vlasenko <vda.linux@googlemail.com>
  8. * Copyright (c) 2011-2016 Dmitry V. Levin <ldv@altlinux.org>
  9. * Copyright (c) 2013 Ali Polatel <alip@exherbo.org>
  10. * Copyright (c) 2015 Mike Frysinger <vapier@gentoo.org>
  11. * Copyright (c) 2015-2018 The strace developers.
  12. * All rights reserved.
  13. *
  14. * SPDX-License-Identifier: LGPL-2.1-or-later
  15. */
  16. #ifndef STRACE_PTRACE_H
  17. # define STRACE_PTRACE_H
  18. # include <stdint.h>
  19. # include <sys/ptrace.h>
  20. # ifdef HAVE_STRUCT_IA64_FPREG
  21. # define ia64_fpreg XXX_ia64_fpreg
  22. # endif
  23. # ifdef HAVE_STRUCT_PT_ALL_USER_REGS
  24. # define pt_all_user_regs XXX_pt_all_user_regs
  25. # endif
  26. # ifdef HAVE_STRUCT_PTRACE_PEEKSIGINFO_ARGS
  27. # define ptrace_peeksiginfo_args XXX_ptrace_peeksiginfo_args
  28. # endif
  29. # include <linux/ptrace.h>
  30. # ifdef HAVE_STRUCT_IA64_FPREG
  31. # undef ia64_fpreg
  32. # endif
  33. # ifdef HAVE_STRUCT_PT_ALL_USER_REGS
  34. # undef pt_all_user_regs
  35. # endif
  36. # ifdef HAVE_STRUCT_PTRACE_PEEKSIGINFO_ARGS
  37. # undef ptrace_peeksiginfo_args
  38. # endif
  39. # if defined(SPARC) || defined(SPARC64)
  40. /*
  41. * SPARC has a different PTRACE_DETACH value correctly defined in sys/ptrace.h,
  42. * but linux/ptrace.h clobbers it with the standard one. PTRACE_SUNDETACH is
  43. * also defined to the correct value by sys/ptrace.h, so use that instead.
  44. */
  45. # undef PTRACE_DETACH
  46. # define PTRACE_DETACH PTRACE_SUNDETACH
  47. # endif
  48. # ifndef PTRACE_EVENT_FORK
  49. # define PTRACE_EVENT_FORK 1
  50. # endif
  51. # ifndef PTRACE_EVENT_VFORK
  52. # define PTRACE_EVENT_VFORK 2
  53. # endif
  54. # ifndef PTRACE_EVENT_CLONE
  55. # define PTRACE_EVENT_CLONE 3
  56. # endif
  57. # ifndef PTRACE_EVENT_EXEC
  58. # define PTRACE_EVENT_EXEC 4
  59. # endif
  60. # ifndef PTRACE_EVENT_VFORK_DONE
  61. # define PTRACE_EVENT_VFORK_DONE 5
  62. # endif
  63. # ifndef PTRACE_EVENT_EXIT
  64. # define PTRACE_EVENT_EXIT 6
  65. # endif
  66. # ifndef PTRACE_EVENT_SECCOMP
  67. # define PTRACE_EVENT_SECCOMP 7
  68. # endif
  69. # ifdef PTRACE_EVENT_STOP
  70. /* Linux 3.1 - 3.3 releases had a broken value. It was fixed in 3.4. */
  71. # if PTRACE_EVENT_STOP == 7
  72. # undef PTRACE_EVENT_STOP
  73. # endif
  74. # endif
  75. # ifndef PTRACE_EVENT_STOP
  76. # define PTRACE_EVENT_STOP 128
  77. # endif
  78. # ifndef PTRACE_O_TRACESYSGOOD
  79. # define PTRACE_O_TRACESYSGOOD 1
  80. # endif
  81. # ifndef PTRACE_O_TRACEFORK
  82. # define PTRACE_O_TRACEFORK (1 << PTRACE_EVENT_FORK)
  83. # endif
  84. # ifndef PTRACE_O_TRACEVFORK
  85. # define PTRACE_O_TRACEVFORK (1 << PTRACE_EVENT_VFORK)
  86. # endif
  87. # ifndef PTRACE_O_TRACECLONE
  88. # define PTRACE_O_TRACECLONE (1 << PTRACE_EVENT_CLONE)
  89. # endif
  90. # ifndef PTRACE_O_TRACEEXEC
  91. # define PTRACE_O_TRACEEXEC (1 << PTRACE_EVENT_EXEC)
  92. # endif
  93. # ifndef PTRACE_O_TRACEVFORKDONE
  94. # define PTRACE_O_TRACEVFORKDONE (1 << PTRACE_EVENT_VFORK_DONE)
  95. # endif
  96. # ifndef PTRACE_O_TRACEEXIT
  97. # define PTRACE_O_TRACEEXIT (1 << PTRACE_EVENT_EXIT)
  98. # endif
  99. # ifndef PTRACE_O_TRACESECCOMP
  100. # define PTRACE_O_TRACESECCOMP (1 << PTRACE_EVENT_SECCOMP)
  101. # endif
  102. # ifndef PTRACE_O_EXITKILL
  103. # define PTRACE_O_EXITKILL (1 << 20)
  104. # endif
  105. # ifndef PTRACE_O_SUSPEND_SECCOMP
  106. # define PTRACE_O_SUSPEND_SECCOMP (1 << 21)
  107. # endif
  108. # ifndef PTRACE_SETOPTIONS
  109. # define PTRACE_SETOPTIONS 0x4200
  110. # endif
  111. # ifndef PTRACE_GETEVENTMSG
  112. # define PTRACE_GETEVENTMSG 0x4201
  113. # endif
  114. # ifndef PTRACE_GETSIGINFO
  115. # define PTRACE_GETSIGINFO 0x4202
  116. # endif
  117. # ifndef PTRACE_SETSIGINFO
  118. # define PTRACE_SETSIGINFO 0x4203
  119. # endif
  120. # ifndef PTRACE_GETREGSET
  121. # define PTRACE_GETREGSET 0x4204
  122. # endif
  123. # ifndef PTRACE_SETREGSET
  124. # define PTRACE_SETREGSET 0x4205
  125. # endif
  126. # ifndef PTRACE_SEIZE
  127. # define PTRACE_SEIZE 0x4206
  128. # endif
  129. # ifndef PTRACE_INTERRUPT
  130. # define PTRACE_INTERRUPT 0x4207
  131. # endif
  132. # ifndef PTRACE_LISTEN
  133. # define PTRACE_LISTEN 0x4208
  134. # endif
  135. # ifndef PTRACE_PEEKSIGINFO
  136. # define PTRACE_PEEKSIGINFO 0x4209
  137. # endif
  138. # ifndef PTRACE_GETSIGMASK
  139. # define PTRACE_GETSIGMASK 0x420a
  140. # endif
  141. # ifndef PTRACE_SETSIGMASK
  142. # define PTRACE_SETSIGMASK 0x420b
  143. # endif
  144. # ifndef PTRACE_SECCOMP_GET_FILTER
  145. # define PTRACE_SECCOMP_GET_FILTER 0x420c
  146. # endif
  147. # ifndef PTRACE_SECCOMP_GET_METADATA
  148. # define PTRACE_SECCOMP_GET_METADATA 0x420d
  149. # endif
  150. # ifndef PTRACE_GET_SYSCALL_INFO
  151. # define PTRACE_GET_SYSCALL_INFO 0x420e
  152. # define PTRACE_SYSCALL_INFO_NONE 0
  153. # define PTRACE_SYSCALL_INFO_ENTRY 1
  154. # define PTRACE_SYSCALL_INFO_EXIT 2
  155. # define PTRACE_SYSCALL_INFO_SECCOMP 3
  156. struct ptrace_syscall_info {
  157. uint8_t op;
  158. uint8_t pad[3];
  159. uint32_t arch;
  160. uint64_t instruction_pointer;
  161. uint64_t stack_pointer;
  162. union {
  163. struct {
  164. uint64_t nr;
  165. uint64_t args[6];
  166. } entry;
  167. struct {
  168. int64_t rval;
  169. uint8_t is_error;
  170. } exit;
  171. struct {
  172. uint64_t nr;
  173. uint64_t args[6];
  174. uint32_t ret_data;
  175. } seccomp;
  176. };
  177. };
  178. # endif
  179. # if !HAVE_DECL_PTRACE_PEEKUSER
  180. # define PTRACE_PEEKUSER PTRACE_PEEKUSR
  181. # endif
  182. # if !HAVE_DECL_PTRACE_POKEUSER
  183. # define PTRACE_POKEUSER PTRACE_POKEUSR
  184. # endif
  185. #endif /* !STRACE_PTRACE_H */