1570af302Sopenharmony_ci#ifndef _SYS_PTRACE_H
2570af302Sopenharmony_ci#define _SYS_PTRACE_H
3570af302Sopenharmony_ci#ifdef __cplusplus
4570af302Sopenharmony_ciextern "C" {
5570af302Sopenharmony_ci#endif
6570af302Sopenharmony_ci
7570af302Sopenharmony_ci#include <stdint.h>
8570af302Sopenharmony_ci
9570af302Sopenharmony_ci#define PTRACE_TRACEME 0
10570af302Sopenharmony_ci#define PT_TRACE_ME PTRACE_TRACEME
11570af302Sopenharmony_ci
12570af302Sopenharmony_ci#define PTRACE_PEEKTEXT 1
13570af302Sopenharmony_ci#define PTRACE_PEEKDATA 2
14570af302Sopenharmony_ci#define PTRACE_PEEKUSER 3
15570af302Sopenharmony_ci#define PTRACE_POKETEXT 4
16570af302Sopenharmony_ci#define PTRACE_POKEDATA 5
17570af302Sopenharmony_ci#define PTRACE_POKEUSER 6
18570af302Sopenharmony_ci#define PTRACE_CONT 7
19570af302Sopenharmony_ci#define PTRACE_KILL 8
20570af302Sopenharmony_ci#define PTRACE_SINGLESTEP 9
21570af302Sopenharmony_ci#define PTRACE_GETREGS 12
22570af302Sopenharmony_ci#define PTRACE_SETREGS 13
23570af302Sopenharmony_ci#define PTRACE_GETFPREGS 14
24570af302Sopenharmony_ci#define PTRACE_SETFPREGS 15
25570af302Sopenharmony_ci#define PTRACE_ATTACH 16
26570af302Sopenharmony_ci#define PTRACE_DETACH 17
27570af302Sopenharmony_ci#define PTRACE_GETFPXREGS 18
28570af302Sopenharmony_ci#define PTRACE_SETFPXREGS 19
29570af302Sopenharmony_ci#define PTRACE_SYSCALL 24
30570af302Sopenharmony_ci#define PTRACE_SETOPTIONS 0x4200
31570af302Sopenharmony_ci#define PTRACE_GETEVENTMSG 0x4201
32570af302Sopenharmony_ci#define PTRACE_GETSIGINFO 0x4202
33570af302Sopenharmony_ci#define PTRACE_SETSIGINFO 0x4203
34570af302Sopenharmony_ci#define PTRACE_GETREGSET 0x4204
35570af302Sopenharmony_ci#define PTRACE_SETREGSET 0x4205
36570af302Sopenharmony_ci#define PTRACE_SEIZE 0x4206
37570af302Sopenharmony_ci#define PTRACE_INTERRUPT 0x4207
38570af302Sopenharmony_ci#define PTRACE_LISTEN 0x4208
39570af302Sopenharmony_ci#define PTRACE_PEEKSIGINFO 0x4209
40570af302Sopenharmony_ci#define PTRACE_GETSIGMASK 0x420a
41570af302Sopenharmony_ci#define PTRACE_SETSIGMASK 0x420b
42570af302Sopenharmony_ci#define PTRACE_SECCOMP_GET_FILTER 0x420c
43570af302Sopenharmony_ci#define PTRACE_SECCOMP_GET_METADATA 0x420d
44570af302Sopenharmony_ci#define PTRACE_GET_SYSCALL_INFO 0x420e
45570af302Sopenharmony_ci#define PTRACE_GET_RSEQ_CONFIGURATION	0x420f
46570af302Sopenharmony_ci
47570af302Sopenharmony_ci#define PT_READ_I PTRACE_PEEKTEXT
48570af302Sopenharmony_ci#define PT_READ_D PTRACE_PEEKDATA
49570af302Sopenharmony_ci#define PT_READ_U PTRACE_PEEKUSER
50570af302Sopenharmony_ci#define PT_WRITE_I PTRACE_POKETEXT
51570af302Sopenharmony_ci#define PT_WRITE_D PTRACE_POKEDATA
52570af302Sopenharmony_ci#define PT_WRITE_U PTRACE_POKEUSER
53570af302Sopenharmony_ci#define PT_CONTINUE PTRACE_CONT
54570af302Sopenharmony_ci#define PT_KILL PTRACE_KILL
55570af302Sopenharmony_ci#define PT_STEP PTRACE_SINGLESTEP
56570af302Sopenharmony_ci#define PT_GETREGS PTRACE_GETREGS
57570af302Sopenharmony_ci#define PT_SETREGS PTRACE_SETREGS
58570af302Sopenharmony_ci#define PT_GETFPREGS PTRACE_GETFPREGS
59570af302Sopenharmony_ci#define PT_SETFPREGS PTRACE_SETFPREGS
60570af302Sopenharmony_ci#define PT_ATTACH PTRACE_ATTACH
61570af302Sopenharmony_ci#define PT_DETACH PTRACE_DETACH
62570af302Sopenharmony_ci#define PT_GETFPXREGS PTRACE_GETFPXREGS
63570af302Sopenharmony_ci#define PT_SETFPXREGS PTRACE_SETFPXREGS
64570af302Sopenharmony_ci#define PT_SYSCALL PTRACE_SYSCALL
65570af302Sopenharmony_ci#define PT_SETOPTIONS PTRACE_SETOPTIONS
66570af302Sopenharmony_ci#define PT_GETEVENTMSG PTRACE_GETEVENTMSG
67570af302Sopenharmony_ci#define PT_GETSIGINFO PTRACE_GETSIGINFO
68570af302Sopenharmony_ci#define PT_SETSIGINFO PTRACE_SETSIGINFO
69570af302Sopenharmony_ci
70570af302Sopenharmony_ci#define PTRACE_O_TRACESYSGOOD   0x00000001
71570af302Sopenharmony_ci#define PTRACE_O_TRACEFORK      0x00000002
72570af302Sopenharmony_ci#define PTRACE_O_TRACEVFORK     0x00000004
73570af302Sopenharmony_ci#define PTRACE_O_TRACECLONE     0x00000008
74570af302Sopenharmony_ci#define PTRACE_O_TRACEEXEC      0x00000010
75570af302Sopenharmony_ci#define PTRACE_O_TRACEVFORKDONE 0x00000020
76570af302Sopenharmony_ci#define PTRACE_O_TRACEEXIT      0x00000040
77570af302Sopenharmony_ci#define PTRACE_O_TRACESECCOMP   0x00000080
78570af302Sopenharmony_ci#define PTRACE_O_EXITKILL       0x00100000
79570af302Sopenharmony_ci#define PTRACE_O_SUSPEND_SECCOMP 0x00200000
80570af302Sopenharmony_ci#define PTRACE_O_MASK           0x003000ff
81570af302Sopenharmony_ci
82570af302Sopenharmony_ci#define PTRACE_EVENT_FORK 1
83570af302Sopenharmony_ci#define PTRACE_EVENT_VFORK 2
84570af302Sopenharmony_ci#define PTRACE_EVENT_CLONE 3
85570af302Sopenharmony_ci#define PTRACE_EVENT_EXEC 4
86570af302Sopenharmony_ci#define PTRACE_EVENT_VFORK_DONE 5
87570af302Sopenharmony_ci#define PTRACE_EVENT_EXIT 6
88570af302Sopenharmony_ci#define PTRACE_EVENT_SECCOMP 7
89570af302Sopenharmony_ci#define PTRACE_EVENT_STOP 128
90570af302Sopenharmony_ci
91570af302Sopenharmony_ci#define PTRACE_PEEKSIGINFO_SHARED 1
92570af302Sopenharmony_ci
93570af302Sopenharmony_ci#define PTRACE_SYSCALL_INFO_NONE 0
94570af302Sopenharmony_ci#define PTRACE_SYSCALL_INFO_ENTRY 1
95570af302Sopenharmony_ci#define PTRACE_SYSCALL_INFO_EXIT 2
96570af302Sopenharmony_ci#define PTRACE_SYSCALL_INFO_SECCOMP 3
97570af302Sopenharmony_ci
98570af302Sopenharmony_ci#include <bits/ptrace.h>
99570af302Sopenharmony_ci
100570af302Sopenharmony_cistruct __ptrace_peeksiginfo_args {
101570af302Sopenharmony_ci	uint64_t off;
102570af302Sopenharmony_ci	uint32_t flags;
103570af302Sopenharmony_ci	int32_t nr;
104570af302Sopenharmony_ci};
105570af302Sopenharmony_ci
106570af302Sopenharmony_cistruct __ptrace_seccomp_metadata {
107570af302Sopenharmony_ci	uint64_t filter_off;
108570af302Sopenharmony_ci	uint64_t flags;
109570af302Sopenharmony_ci};
110570af302Sopenharmony_ci
111570af302Sopenharmony_cistruct __ptrace_syscall_info {
112570af302Sopenharmony_ci	uint8_t op;
113570af302Sopenharmony_ci	uint8_t __pad[3];
114570af302Sopenharmony_ci	uint32_t arch;
115570af302Sopenharmony_ci	uint64_t instruction_pointer;
116570af302Sopenharmony_ci	uint64_t stack_pointer;
117570af302Sopenharmony_ci	union {
118570af302Sopenharmony_ci		struct {
119570af302Sopenharmony_ci			uint64_t nr;
120570af302Sopenharmony_ci			uint64_t args[6];
121570af302Sopenharmony_ci		} entry;
122570af302Sopenharmony_ci		struct {
123570af302Sopenharmony_ci			int64_t rval;
124570af302Sopenharmony_ci			uint8_t is_error;
125570af302Sopenharmony_ci		} exit;
126570af302Sopenharmony_ci		struct {
127570af302Sopenharmony_ci			uint64_t nr;
128570af302Sopenharmony_ci			uint64_t args[6];
129570af302Sopenharmony_ci			uint32_t ret_data;
130570af302Sopenharmony_ci		} seccomp;
131570af302Sopenharmony_ci	};
132570af302Sopenharmony_ci};
133570af302Sopenharmony_ci
134570af302Sopenharmony_cistruct __ptrace_rseq_configuration {
135570af302Sopenharmony_ci	uint64_t rseq_abi_pointer;
136570af302Sopenharmony_ci	uint32_t rseq_abi_size;
137570af302Sopenharmony_ci	uint32_t signature;
138570af302Sopenharmony_ci	uint32_t flags;
139570af302Sopenharmony_ci	uint32_t pad;
140570af302Sopenharmony_ci};
141570af302Sopenharmony_ci
142570af302Sopenharmony_cilong ptrace(int, ...);
143570af302Sopenharmony_ci
144570af302Sopenharmony_ci#ifdef __cplusplus
145570af302Sopenharmony_ci}
146570af302Sopenharmony_ci#endif
147570af302Sopenharmony_ci#endif
148