1 #ifndef __PTRACE_H__
2 
3 #define __PTRACE_H__
4 
5 struct pt_regs
6 {
7     unsigned long r15;
8     unsigned long r14;
9     unsigned long r13;
10     unsigned long r12;
11     unsigned long r11;
12     unsigned long r10;
13     unsigned long r9;
14     unsigned long r8;
15     unsigned long rbx;
16     unsigned long rcx;
17     unsigned long rdx;
18     unsigned long rsi;
19     unsigned long rdi;
20     unsigned long rbp;
21     unsigned long ds;
22     unsigned long es;
23     unsigned long rax;
24     unsigned long func;
25     unsigned long errcode;
26     unsigned long rip;
27     unsigned long cs;
28     unsigned long rflags;
29     unsigned long rsp;
30     unsigned long ss;
31 };
32 
33 /**
34  * @brief 判断pt_regs是否来自用户态
35  *
36  * @param regs
37  * @return __always_inline
38  */
user_mode(struct pt_regs * regs)39 static inline int user_mode(struct pt_regs *regs)
40 {
41     return !!(regs->cs & 3);
42 }
43 
44 #endif
45