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

source code of include/x86_64-linux-gnu/bits/ptrace-shared.h