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 46570af302Sopenharmony_ci#define PT_READ_I PTRACE_PEEKTEXT 47570af302Sopenharmony_ci#define PT_READ_D PTRACE_PEEKDATA 48570af302Sopenharmony_ci#define PT_READ_U PTRACE_PEEKUSER 49570af302Sopenharmony_ci#define PT_WRITE_I PTRACE_POKETEXT 50570af302Sopenharmony_ci#define PT_WRITE_D PTRACE_POKEDATA 51570af302Sopenharmony_ci#define PT_WRITE_U PTRACE_POKEUSER 52570af302Sopenharmony_ci#define PT_CONTINUE PTRACE_CONT 53570af302Sopenharmony_ci#define PT_KILL PTRACE_KILL 54570af302Sopenharmony_ci#define PT_STEP PTRACE_SINGLESTEP 55570af302Sopenharmony_ci#define PT_GETREGS PTRACE_GETREGS 56570af302Sopenharmony_ci#define PT_SETREGS PTRACE_SETREGS 57570af302Sopenharmony_ci#define PT_GETFPREGS PTRACE_GETFPREGS 58570af302Sopenharmony_ci#define PT_SETFPREGS PTRACE_SETFPREGS 59570af302Sopenharmony_ci#define PT_ATTACH PTRACE_ATTACH 60570af302Sopenharmony_ci#define PT_DETACH PTRACE_DETACH 61570af302Sopenharmony_ci#define PT_GETFPXREGS PTRACE_GETFPXREGS 62570af302Sopenharmony_ci#define PT_SETFPXREGS PTRACE_SETFPXREGS 63570af302Sopenharmony_ci#define PT_SYSCALL PTRACE_SYSCALL 64570af302Sopenharmony_ci#define PT_SETOPTIONS PTRACE_SETOPTIONS 65570af302Sopenharmony_ci#define PT_GETEVENTMSG PTRACE_GETEVENTMSG 66570af302Sopenharmony_ci#define PT_GETSIGINFO PTRACE_GETSIGINFO 67570af302Sopenharmony_ci#define PT_SETSIGINFO PTRACE_SETSIGINFO 68570af302Sopenharmony_ci 69570af302Sopenharmony_ci#define PTRACE_O_TRACESYSGOOD 0x00000001 70570af302Sopenharmony_ci#define PTRACE_O_TRACEFORK 0x00000002 71570af302Sopenharmony_ci#define PTRACE_O_TRACEVFORK 0x00000004 72570af302Sopenharmony_ci#define PTRACE_O_TRACECLONE 0x00000008 73570af302Sopenharmony_ci#define PTRACE_O_TRACEEXEC 0x00000010 74570af302Sopenharmony_ci#define PTRACE_O_TRACEVFORKDONE 0x00000020 75570af302Sopenharmony_ci#define PTRACE_O_TRACEEXIT 0x00000040 76570af302Sopenharmony_ci#define PTRACE_O_TRACESECCOMP 0x00000080 77570af302Sopenharmony_ci#define PTRACE_O_EXITKILL 0x00100000 78570af302Sopenharmony_ci#define PTRACE_O_SUSPEND_SECCOMP 0x00200000 79570af302Sopenharmony_ci#define PTRACE_O_MASK 0x003000ff 80570af302Sopenharmony_ci 81570af302Sopenharmony_ci#define PTRACE_EVENT_FORK 1 82570af302Sopenharmony_ci#define PTRACE_EVENT_VFORK 2 83570af302Sopenharmony_ci#define PTRACE_EVENT_CLONE 3 84570af302Sopenharmony_ci#define PTRACE_EVENT_EXEC 4 85570af302Sopenharmony_ci#define PTRACE_EVENT_VFORK_DONE 5 86570af302Sopenharmony_ci#define PTRACE_EVENT_EXIT 6 87570af302Sopenharmony_ci#define PTRACE_EVENT_SECCOMP 7 88570af302Sopenharmony_ci#define PTRACE_EVENT_STOP 128 89570af302Sopenharmony_ci 90570af302Sopenharmony_ci#define PTRACE_PEEKSIGINFO_SHARED 1 91570af302Sopenharmony_ci 92570af302Sopenharmony_ci#define PTRACE_SYSCALL_INFO_NONE 0 93570af302Sopenharmony_ci#define PTRACE_SYSCALL_INFO_ENTRY 1 94570af302Sopenharmony_ci#define PTRACE_SYSCALL_INFO_EXIT 2 95570af302Sopenharmony_ci#define PTRACE_SYSCALL_INFO_SECCOMP 3 96570af302Sopenharmony_ci 97570af302Sopenharmony_ci#include <bits/ptrace.h> 98570af302Sopenharmony_ci 99570af302Sopenharmony_cistruct __ptrace_peeksiginfo_args { 100570af302Sopenharmony_ci uint64_t off; 101570af302Sopenharmony_ci uint32_t flags; 102570af302Sopenharmony_ci int32_t nr; 103570af302Sopenharmony_ci}; 104570af302Sopenharmony_ci 105570af302Sopenharmony_cistruct __ptrace_seccomp_metadata { 106570af302Sopenharmony_ci uint64_t filter_off; 107570af302Sopenharmony_ci uint64_t flags; 108570af302Sopenharmony_ci}; 109570af302Sopenharmony_ci 110570af302Sopenharmony_cistruct __ptrace_syscall_info { 111570af302Sopenharmony_ci uint8_t op; 112570af302Sopenharmony_ci uint8_t __pad[3]; 113570af302Sopenharmony_ci uint32_t arch; 114570af302Sopenharmony_ci uint64_t instruction_pointer; 115570af302Sopenharmony_ci uint64_t stack_pointer; 116570af302Sopenharmony_ci union { 117570af302Sopenharmony_ci struct { 118570af302Sopenharmony_ci uint64_t nr; 119570af302Sopenharmony_ci uint64_t args[6]; 120570af302Sopenharmony_ci } entry; 121570af302Sopenharmony_ci struct { 122570af302Sopenharmony_ci int64_t rval; 123570af302Sopenharmony_ci uint8_t is_error; 124570af302Sopenharmony_ci } exit; 125570af302Sopenharmony_ci struct { 126570af302Sopenharmony_ci uint64_t nr; 127570af302Sopenharmony_ci uint64_t args[6]; 128570af302Sopenharmony_ci uint32_t ret_data; 129570af302Sopenharmony_ci } seccomp; 130570af302Sopenharmony_ci }; 131570af302Sopenharmony_ci}; 132570af302Sopenharmony_ci 133570af302Sopenharmony_cilong ptrace(int, ...); 134570af302Sopenharmony_ci 135570af302Sopenharmony_ci#ifdef __cplusplus 136570af302Sopenharmony_ci} 137570af302Sopenharmony_ci#endif 138570af302Sopenharmony_ci#endif 139