Rizin
unix-like reverse engineering framework and cli tools
linux_ptrace.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2020 Anton Kochkov <anton.kochkov@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #ifndef LINUX_PTRACE_H
5 #define LINUX_PTRACE_H
6 
7 // PTRACE_* constants are defined only since glibc 2.4 but appeared much
8 // earlier in linux kernel - since 2.3.99-pre6
9 // So we define it manually
10 // Originally these constants are defined in Linux include/uapi/linux/ptrace.h
11 //
12 #if __linux__ && defined(__GLIBC__)
13 
14 #if !defined(PTRACE_SETOPTIONS) && !defined(PTRACE_GETSIGINFO) && !defined(PTRACE_SETSIGINFO)
15 #define PTRACE_SETOPTIONS 0x4200
16 #define PTRACE_GETSIGINFO 0x4202
17 #define PTRACE_SETSIGINFO 0x4203
18 #endif
19 
20 // A special case of the older Glibc but the kernel newer than 2.5.46
21 // Sadly, there is no reliable and portable way to check the linux kernel
22 // version from headers, so we assume it's supported.
23 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 3)
24 #if !defined(PT_GETEVENTMSG) && !defined(PTRACE_GETEVENTMSG)
25 #define PTRACE_GETEVENTMSG 0x4201
26 #define PT_GETEVENTMSG PTRACE_GETEVENTMSG
27 #endif
28 #endif
29 
30 #if !defined(PTRACE_EVENT_FORK) && !defined(PTRACE_EVENT_VFORK) && !defined(PTRACE_EVENT_CLONE) && !defined(PTRACE_EVENT_EXEC) && !defined(PTRACE_EVENT_VFORK_DONE) && !defined(PTRACE_EVENT_EXIT)
31 
32 #define PTRACE_EVENT_FORK 1
33 #define PTRACE_EVENT_VFORK 2
34 #define PTRACE_EVENT_CLONE 3
35 #define PTRACE_EVENT_EXEC 4
36 #define PTRACE_EVENT_VFORK_DONE 5
37 #define PTRACE_EVENT_EXIT 6
38 
39 #endif
40 
41 #if !defined(PTRACE_O_TRACEFORK) && !defined(PTRACE_O_TRACEVFORK) && !defined(PTRACE_O_TRACECLONE) && !defined(PTRACE_O_TRACEEXEC) && !defined(PTRACE_O_TRACEVFORKDONE) && !defined(PTRACE_O_TRACEEXIT)
42 
43 #define PTRACE_O_TRACESYSGOOD 1
44 #define PTRACE_O_TRACEFORK (1 << 1)
45 #define PTRACE_O_TRACEVFORK (1 << 2)
46 #define PTRACE_O_TRACECLONE (1 << 3)
47 #define PTRACE_O_TRACEEXEC (1 << 4)
48 #define PTRACE_O_TRACEVFORKDONE (1 << 5)
49 #define PTRACE_O_TRACEEXIT (1 << 6)
50 
51 #endif
52 
53 #endif
54 
56 
57 #endif
RzDebug * dbg
Definition: desil.c:30
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc pid
Definition: sflib.h:64
long rz_debug_ptrace_get_x86_xstate(RzDebug *dbg, pid_t pid, struct iovec *iov)
Definition: linux_debug.c:50
int pid_t
Definition: sftypes.h:38
Definition: sftypes.h:73
static uv_buf_t iov
Definition: main.c:15