ptrace-shared.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /* `ptrace' debugger support interface. Linux version,
  2. not architecture-specific.
  3. Copyright (C) 1996-2021 Free Software Foundation, Inc.
  4. This file is part of the GNU C Library.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <https://www.gnu.org/licenses/>. */
  16. #ifndef _SYS_PTRACE_H
  17. # error "Never use <bits/ptrace-shared.h> directly; include <sys/ptrace.h> instead."
  18. #endif
  19. /* Options set using PTRACE_SETOPTIONS. */
  20. enum __ptrace_setoptions
  21. {
  22. PTRACE_O_TRACESYSGOOD = 0x00000001,
  23. PTRACE_O_TRACEFORK = 0x00000002,
  24. PTRACE_O_TRACEVFORK = 0x00000004,
  25. PTRACE_O_TRACECLONE = 0x00000008,
  26. PTRACE_O_TRACEEXEC = 0x00000010,
  27. PTRACE_O_TRACEVFORKDONE = 0x00000020,
  28. PTRACE_O_TRACEEXIT = 0x00000040,
  29. PTRACE_O_TRACESECCOMP = 0x00000080,
  30. PTRACE_O_EXITKILL = 0x00100000,
  31. PTRACE_O_SUSPEND_SECCOMP = 0x00200000,
  32. PTRACE_O_MASK = 0x003000ff
  33. };
  34. enum __ptrace_eventcodes
  35. {
  36. /* Wait extended result codes for the above trace options. */
  37. PTRACE_EVENT_FORK = 1,
  38. PTRACE_EVENT_VFORK = 2,
  39. PTRACE_EVENT_CLONE = 3,
  40. PTRACE_EVENT_EXEC = 4,
  41. PTRACE_EVENT_VFORK_DONE = 5,
  42. PTRACE_EVENT_EXIT = 6,
  43. PTRACE_EVENT_SECCOMP = 7,
  44. /* Extended result codes enabled by means other than options. */
  45. PTRACE_EVENT_STOP = 128
  46. };
  47. /* Type of stop for PTRACE_GET_SYSCALL_INFO. */
  48. enum __ptrace_get_syscall_info_op
  49. {
  50. PTRACE_SYSCALL_INFO_NONE = 0,
  51. PTRACE_SYSCALL_INFO_ENTRY = 1,
  52. PTRACE_SYSCALL_INFO_EXIT = 2,
  53. PTRACE_SYSCALL_INFO_SECCOMP = 3
  54. };
  55. /* Arguments for PTRACE_PEEKSIGINFO. */
  56. struct __ptrace_peeksiginfo_args
  57. {
  58. __uint64_t off; /* From which siginfo to start. */
  59. __uint32_t flags; /* Flags for peeksiginfo. */
  60. __int32_t nr; /* How many siginfos to take. */
  61. };
  62. enum __ptrace_peeksiginfo_flags
  63. {
  64. /* Read signals from a shared (process wide) queue. */
  65. PTRACE_PEEKSIGINFO_SHARED = (1 << 0)
  66. };
  67. /* Argument and results of PTRACE_SECCOMP_GET_METADATA. */
  68. struct __ptrace_seccomp_metadata
  69. {
  70. __uint64_t filter_off; /* Input: which filter. */
  71. __uint64_t flags; /* Output: filter's flags. */
  72. };
  73. /* Results of PTRACE_GET_SYSCALL_INFO. */
  74. struct __ptrace_syscall_info
  75. {
  76. __uint8_t op; /* One of the enum
  77. __ptrace_get_syscall_info_op
  78. values. */
  79. __uint32_t arch __attribute__ ((__aligned__ (4))); /* AUDIT_ARCH_*
  80. value. */
  81. __uint64_t instruction_pointer; /* Instruction pointer. */
  82. __uint64_t stack_pointer; /* Stack pointer. */
  83. union
  84. {
  85. /* System call number and arguments, for
  86. PTRACE_SYSCALL_INFO_ENTRY. */
  87. struct
  88. {
  89. __uint64_t nr;
  90. __uint64_t args[6];
  91. } entry;
  92. /* System call return value and error flag, for
  93. PTRACE_SYSCALL_INFO_EXIT. */
  94. struct
  95. {
  96. __int64_t rval;
  97. __uint8_t is_error;
  98. } exit;
  99. /* System call number, arguments and SECCOMP_RET_DATA portion of
  100. SECCOMP_RET_TRACE return value, for
  101. PTRACE_SYSCALL_INFO_SECCOMP. */
  102. struct
  103. {
  104. __uint64_t nr;
  105. __uint64_t args[6];
  106. __uint32_t ret_data;
  107. } seccomp;
  108. };
  109. };
  110. /* Perform process tracing functions. REQUEST is one of the values
  111. above, and determines the action to be taken.
  112. For all requests except PTRACE_TRACEME, PID specifies the process to be
  113. traced.
  114. PID and the other arguments described above for the various requests should
  115. appear (those that are used for the particular request) as:
  116. pid_t PID, void *ADDR, int DATA, void *ADDR2
  117. after REQUEST. */
  118. extern long int ptrace (enum __ptrace_request __request, ...) __THROW;