php-internal-docs
8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
fpm_trace_ptrace.c
Go to the documentation of this file.
1
/* (c) 2007,2008 Andrei Nigmatulin */
2
3
#include "
fpm_config.h
"
4
5
#include <sys/wait.h>
6
#include <sys/ptrace.h>
7
#include <
unistd.h
>
8
#include <errno.h>
9
10
#if defined(PT_ATTACH) && !defined(PTRACE_ATTACH)
11
#define PTRACE_ATTACH PT_ATTACH
12
#endif
13
14
#if defined(PT_DETACH) && !defined(PTRACE_DETACH)
15
#define PTRACE_DETACH PT_DETACH
16
#endif
17
18
#if defined(PT_READ_D) && !defined(PTRACE_PEEKDATA)
19
#define PTRACE_PEEKDATA PT_READ_D
20
#endif
21
22
#include "
fpm_trace.h
"
23
#include "
zlog.h
"
24
25
static
pid_t traced_pid;
26
27
int
fpm_trace_signal
(pid_t pid)
/* {{{ */
28
{
29
if
(0 > ptrace(PTRACE_ATTACH, pid, 0, 0)) {
30
zlog
(
ZLOG_SYSERROR
,
"failed to ptrace(ATTACH) child %d"
, pid);
31
return
-1;
32
}
33
return
0;
34
}
35
/* }}} */
36
37
int
fpm_trace_ready
(pid_t pid)
/* {{{ */
38
{
39
traced_pid = pid;
40
return
0;
41
}
42
/* }}} */
43
44
int
fpm_trace_close
(pid_t pid)
/* {{{ */
45
{
46
if
(0 > ptrace(PTRACE_DETACH, pid, (
void
*) 1, 0)) {
47
zlog
(
ZLOG_SYSERROR
,
"failed to ptrace(DETACH) child %d"
, pid);
48
return
-1;
49
}
50
traced_pid = 0;
51
return
0;
52
}
53
/* }}} */
54
55
int
fpm_trace_get_long
(
long
addr
,
long
*
data
)
/* {{{ */
56
{
57
#ifdef PT_IO
58
struct
ptrace_io_desc ptio = {
59
.piod_op = PIOD_READ_D,
60
.piod_offs = (
void
*)
addr
,
61
.piod_addr = (
void
*)
data
,
62
.piod_len =
sizeof
(long)
63
};
64
65
if
(0 > ptrace(PT_IO, traced_pid, (
void
*) &ptio, 0)) {
66
zlog
(
ZLOG_SYSERROR
,
"failed to ptrace(PT_IO) pid %d"
, traced_pid);
67
return
-1;
68
}
69
#else
70
errno
= 0;
71
*
data
= ptrace(PTRACE_PEEKDATA, traced_pid, (
void
*)
addr
, 0);
72
if
(
errno
) {
73
zlog
(
ZLOG_SYSERROR
,
"failed to ptrace(PEEKDATA) pid %d"
, traced_pid);
74
return
-1;
75
}
76
#endif
77
return
0;
78
}
79
/* }}} */
fpm_config.h
fpm_trace.h
fpm_trace_signal
int fpm_trace_signal(pid_t pid)
Definition
fpm_trace_ptrace.c:27
fpm_trace_close
int fpm_trace_close(pid_t pid)
Definition
fpm_trace_ptrace.c:44
fpm_trace_get_long
int fpm_trace_get_long(long addr, long *data)
Definition
fpm_trace_ptrace.c:55
fpm_trace_ready
int fpm_trace_ready(pid_t pid)
Definition
fpm_trace_ptrace.c:37
data
zend_constant * data
Definition
phpdbg_info.c:102
addr
Definition
sljitNativeS390X.c:880
unistd.h
errno
#define errno
Definition
windows_common.h:29
zlog.h
ZLOG_SYSERROR
#define ZLOG_SYSERROR
Definition
zlog.h:53
zlog
#define zlog(flags,...)
Definition
zlog.h:9
sapi
fpm
fpm
fpm_trace_ptrace.c
Generated on Sat Aug 23 2025 01:46:13 for php-internal-docs by
1.13.2