42
42
43
43
static int fpm_php_trace_dump (struct fpm_child_s * child , FILE * slowlog ) /* {{{ */
44
44
{
45
- // TODO: fpm_php_trace_dump() has to be reimplemented ???
46
- #if 0
47
45
int callers_limit = 20 ;
48
46
pid_t pid = child -> pid ;
49
47
struct timeval tv ;
50
48
static const int buf_size = 1024 ;
51
49
char buf [buf_size ];
52
50
long execute_data ;
51
+ long path_translated ;
53
52
long l ;
54
53
55
54
gettimeofday (& tv , 0 );
@@ -58,7 +57,13 @@ static int fpm_php_trace_dump(struct fpm_child_s *child, FILE *slowlog) /* {{{ *
58
57
59
58
fprintf (slowlog , "\n%s [pool %s] pid %d\n" , buf , child -> wp -> config -> name , (int ) pid );
60
59
61
- if (0 > fpm_trace_get_strz (buf , buf_size , (long ) & SG (request_info ).path_translated )) {
60
+ if (0 > fpm_trace_get_long ((long ) & SG (request_info ).path_translated , & l )) {
61
+ return -1 ;
62
+ }
63
+
64
+ path_translated = l ;
65
+
66
+ if (0 > fpm_trace_get_strz (buf , buf_size , path_translated )) {
62
67
return -1 ;
63
68
}
64
69
@@ -72,68 +77,118 @@ static int fpm_php_trace_dump(struct fpm_child_s *child, FILE *slowlog) /* {{{ *
72
77
73
78
while (execute_data ) {
74
79
long function ;
80
+ long function_name ;
81
+ long file_name ;
82
+ long prev ;
75
83
uint lineno = 0 ;
76
84
77
- fprintf (slowlog , "[0x%" PTR_FMT "lx] " , execute_data );
78
-
79
- if (0 > fpm_trace_get_long (execute_data + offsetof(zend_execute_data , function_state .function ), & l )) {
85
+ if (0 > fpm_trace_get_long (execute_data + offsetof(zend_execute_data , func ), & l )) {
80
86
return -1 ;
81
87
}
82
88
83
89
function = l ;
84
90
85
91
if (valid_ptr (function )) {
86
- if (0 > fpm_trace_get_strz ( buf , buf_size , function + offsetof(zend_function , common .function_name ))) {
92
+ if (0 > fpm_trace_get_long ( function + offsetof(zend_function , common .function_name ), & l )) {
87
93
return -1 ;
88
94
}
89
95
90
- fprintf (slowlog , "%s()" , buf );
96
+ function_name = l ;
97
+
98
+ if (function_name == 0 ) {
99
+ uint32_t * call_info = (uint32_t * )& l ;
100
+ if (0 > fpm_trace_get_long (execute_data + offsetof(zend_execute_data , This .u1 .type_info ), & l )) {
101
+ return -1 ;
102
+ }
103
+
104
+ if (ZEND_CALL_KIND_EX ((* call_info ) >> 24 ) == ZEND_CALL_TOP_CODE ) {
105
+ return 0 ;
106
+ } else if (ZEND_CALL_KIND_EX (* (call_info ) >> 24 ) == ZEND_CALL_NESTED_CODE ) {
107
+ memcpy (buf , "[INCLUDE_OR_EVAL]" , sizeof ("[INCLUDE_OR_EVAL]" ));
108
+ } else {
109
+ ZEND_ASSERT (0 );
110
+ }
111
+ } else {
112
+ if (0 > fpm_trace_get_strz (buf , buf_size , function_name + offsetof(zend_string , val ))) {
113
+ return -1 ;
114
+ }
115
+
116
+ }
91
117
} else {
92
- fprintf ( slowlog , "???" );
118
+ memcpy ( buf , "???" , sizeof ( "???" ) );
93
119
}
120
+
121
+ fprintf (slowlog , "[0x%" PTR_FMT "lx] " , execute_data );
94
122
95
- if (0 > fpm_trace_get_long (execute_data + offsetof(zend_execute_data , op_array ), & l )) {
123
+ fprintf (slowlog , "%s()" , buf );
124
+
125
+ * buf = '\0' ;
126
+
127
+ if (0 > fpm_trace_get_long (execute_data + offsetof(zend_execute_data , prev_execute_data ), & l )) {
96
128
return -1 ;
97
129
}
98
130
99
- * buf = '\0' ;
131
+ execute_data = prev = l ;
100
132
101
- if (valid_ptr (l )) {
102
- long op_array = l ;
133
+ while (prev ) {
103
134
104
- if (0 > fpm_trace_get_strz ( buf , buf_size , op_array + offsetof(zend_op_array , filename ) )) {
135
+ if (0 > fpm_trace_get_long ( prev + offsetof(zend_execute_data , func ), & l )) {
105
136
return -1 ;
106
137
}
107
- }
108
138
109
- if (0 > fpm_trace_get_long (execute_data + offsetof(zend_execute_data , opline ), & l )) {
110
- return -1 ;
111
- }
139
+ function = l ;
112
140
113
- if (valid_ptr (l )) {
114
- long opline = l ;
115
- uint * lu = ( uint * ) & l ;
141
+ if (! valid_ptr (function )) {
142
+ break ;
143
+ }
116
144
117
- if (0 > fpm_trace_get_long (opline + offsetof(struct _zend_op , lineno ), & l )) {
145
+ if (0 > fpm_trace_get_long (function + offsetof(zend_function , type ), & l )) {
118
146
return -1 ;
119
147
}
120
148
121
- lineno = * lu ;
122
- }
149
+ /* zend_uchar? */
150
+ if (ZEND_USER_CODE (l )) {
151
+ if (0 > fpm_trace_get_long (function + offsetof(zend_op_array , filename ), & l )) {
152
+ return -1 ;
153
+ }
123
154
124
- fprintf ( slowlog , " %s:%u\n" , * buf ? buf : "unknown" , lineno ) ;
155
+ file_name = l ;
125
156
126
- if (0 > fpm_trace_get_long (execute_data + offsetof(zend_execute_data , prev_execute_data ), & l )) {
127
- return -1 ;
157
+ if (0 > fpm_trace_get_strz (buf , buf_size , file_name + offsetof(zend_string , val ))) {
158
+ return -1 ;
159
+ }
160
+
161
+ if (0 > fpm_trace_get_long (prev + offsetof(zend_execute_data , opline ), & l )) {
162
+ return -1 ;
163
+ }
164
+
165
+ if (valid_ptr (l )) {
166
+ long opline = l ;
167
+ uint32_t * lu = (uint32_t * ) & l ;
168
+
169
+ if (0 > fpm_trace_get_long (opline + offsetof(struct _zend_op , lineno ), & l )) {
170
+ return -1 ;
171
+ }
172
+
173
+ lineno = * lu ;
174
+ }
175
+ break ;
176
+ }
177
+
178
+ if (0 > fpm_trace_get_long (prev + offsetof(zend_execute_data , prev_execute_data ), & l )) {
179
+ return -1 ;
180
+ }
181
+
182
+ prev = l ;
128
183
}
129
184
130
- execute_data = l ;
185
+ fprintf ( slowlog , " %s:%u\n" , * buf ? buf : "unknown" , lineno ) ;
131
186
132
187
if (0 == -- callers_limit ) {
133
188
break ;
134
189
}
135
190
}
136
- #endif
191
+
137
192
return 0 ;
138
193
}
139
194
/* }}} */
0 commit comments