Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 #ifndef _UAPI_LINUX_PTRACE_H
0003 #define _UAPI_LINUX_PTRACE_H
0004 /* ptrace.h */
0005 /* structs and defines to help the user use the ptrace system call. */
0006 
0007 /* has the defines to get at the registers. */
0008 
0009 #include <linux/types.h>
0010 
0011 #define PTRACE_TRACEME         0
0012 #define PTRACE_PEEKTEXT        1
0013 #define PTRACE_PEEKDATA        2
0014 #define PTRACE_PEEKUSR         3
0015 #define PTRACE_POKETEXT        4
0016 #define PTRACE_POKEDATA        5
0017 #define PTRACE_POKEUSR         6
0018 #define PTRACE_CONT        7
0019 #define PTRACE_KILL        8
0020 #define PTRACE_SINGLESTEP      9
0021 
0022 #define PTRACE_ATTACH         16
0023 #define PTRACE_DETACH         17
0024 
0025 #define PTRACE_SYSCALL        24
0026 
0027 /* 0x4200-0x4300 are reserved for architecture-independent additions.  */
0028 #define PTRACE_SETOPTIONS   0x4200
0029 #define PTRACE_GETEVENTMSG  0x4201
0030 #define PTRACE_GETSIGINFO   0x4202
0031 #define PTRACE_SETSIGINFO   0x4203
0032 
0033 /*
0034  * Generic ptrace interface that exports the architecture specific regsets
0035  * using the corresponding NT_* types (which are also used in the core dump).
0036  * Please note that the NT_PRSTATUS note type in a core dump contains a full
0037  * 'struct elf_prstatus'. But the user_regset for NT_PRSTATUS contains just the
0038  * elf_gregset_t that is the pr_reg field of 'struct elf_prstatus'. For all the
0039  * other user_regset flavors, the user_regset layout and the ELF core dump note
0040  * payload are exactly the same layout.
0041  *
0042  * This interface usage is as follows:
0043  *  struct iovec iov = { buf, len};
0044  *
0045  *  ret = ptrace(PTRACE_GETREGSET/PTRACE_SETREGSET, pid, NT_XXX_TYPE, &iov);
0046  *
0047  * On the successful completion, iov.len will be updated by the kernel,
0048  * specifying how much the kernel has written/read to/from the user's iov.buf.
0049  */
0050 #define PTRACE_GETREGSET    0x4204
0051 #define PTRACE_SETREGSET    0x4205
0052 
0053 #define PTRACE_SEIZE        0x4206
0054 #define PTRACE_INTERRUPT    0x4207
0055 #define PTRACE_LISTEN       0x4208
0056 
0057 #define PTRACE_PEEKSIGINFO  0x4209
0058 
0059 struct ptrace_peeksiginfo_args {
0060     __u64 off;  /* from which siginfo to start */
0061     __u32 flags;
0062     __s32 nr;   /* how may siginfos to take */
0063 };
0064 
0065 #define PTRACE_GETSIGMASK   0x420a
0066 #define PTRACE_SETSIGMASK   0x420b
0067 
0068 #define PTRACE_SECCOMP_GET_FILTER   0x420c
0069 #define PTRACE_SECCOMP_GET_METADATA 0x420d
0070 
0071 struct seccomp_metadata {
0072     __u64 filter_off;   /* Input: which filter */
0073     __u64 flags;        /* Output: filter's flags */
0074 };
0075 
0076 #define PTRACE_GET_SYSCALL_INFO     0x420e
0077 #define PTRACE_SYSCALL_INFO_NONE    0
0078 #define PTRACE_SYSCALL_INFO_ENTRY   1
0079 #define PTRACE_SYSCALL_INFO_EXIT    2
0080 #define PTRACE_SYSCALL_INFO_SECCOMP 3
0081 
0082 struct ptrace_syscall_info {
0083     __u8 op;    /* PTRACE_SYSCALL_INFO_* */
0084     __u8 pad[3];
0085     __u32 arch;
0086     __u64 instruction_pointer;
0087     __u64 stack_pointer;
0088     union {
0089         struct {
0090             __u64 nr;
0091             __u64 args[6];
0092         } entry;
0093         struct {
0094             __s64 rval;
0095             __u8 is_error;
0096         } exit;
0097         struct {
0098             __u64 nr;
0099             __u64 args[6];
0100             __u32 ret_data;
0101         } seccomp;
0102     };
0103 };
0104 
0105 #define PTRACE_GET_RSEQ_CONFIGURATION   0x420f
0106 
0107 struct ptrace_rseq_configuration {
0108     __u64 rseq_abi_pointer;
0109     __u32 rseq_abi_size;
0110     __u32 signature;
0111     __u32 flags;
0112     __u32 pad;
0113 };
0114 
0115 /*
0116  * These values are stored in task->ptrace_message
0117  * by ptrace_stop to describe the current syscall-stop.
0118  */
0119 #define PTRACE_EVENTMSG_SYSCALL_ENTRY   1
0120 #define PTRACE_EVENTMSG_SYSCALL_EXIT    2
0121 
0122 /* Read signals from a shared (process wide) queue */
0123 #define PTRACE_PEEKSIGINFO_SHARED   (1 << 0)
0124 
0125 /* Wait extended result codes for the above trace options.  */
0126 #define PTRACE_EVENT_FORK   1
0127 #define PTRACE_EVENT_VFORK  2
0128 #define PTRACE_EVENT_CLONE  3
0129 #define PTRACE_EVENT_EXEC   4
0130 #define PTRACE_EVENT_VFORK_DONE 5
0131 #define PTRACE_EVENT_EXIT   6
0132 #define PTRACE_EVENT_SECCOMP    7
0133 /* Extended result codes which enabled by means other than options.  */
0134 #define PTRACE_EVENT_STOP   128
0135 
0136 /* Options set using PTRACE_SETOPTIONS or using PTRACE_SEIZE @data param */
0137 #define PTRACE_O_TRACESYSGOOD   1
0138 #define PTRACE_O_TRACEFORK  (1 << PTRACE_EVENT_FORK)
0139 #define PTRACE_O_TRACEVFORK (1 << PTRACE_EVENT_VFORK)
0140 #define PTRACE_O_TRACECLONE (1 << PTRACE_EVENT_CLONE)
0141 #define PTRACE_O_TRACEEXEC  (1 << PTRACE_EVENT_EXEC)
0142 #define PTRACE_O_TRACEVFORKDONE (1 << PTRACE_EVENT_VFORK_DONE)
0143 #define PTRACE_O_TRACEEXIT  (1 << PTRACE_EVENT_EXIT)
0144 #define PTRACE_O_TRACESECCOMP   (1 << PTRACE_EVENT_SECCOMP)
0145 
0146 /* eventless options */
0147 #define PTRACE_O_EXITKILL       (1 << 20)
0148 #define PTRACE_O_SUSPEND_SECCOMP    (1 << 21)
0149 
0150 #define PTRACE_O_MASK       (\
0151     0x000000ff | PTRACE_O_EXITKILL | PTRACE_O_SUSPEND_SECCOMP)
0152 
0153 #include <asm/ptrace.h>
0154 
0155 
0156 #endif /* _UAPI_LINUX_PTRACE_H */