21
21
#include "zend_API.h"
22
22
#include "zend_instrument.h"
23
23
24
- struct zend_instruments_list {
25
- struct zend_instruments_list * prev ;
26
- zend_instrument instrument ;
24
+ struct zend_instrument_fcall_init_list {
25
+ struct zend_instrument_fcall_init_list * prev ;
26
+ zend_instrument_fcall_init instrument ;
27
27
};
28
- typedef struct zend_instruments_list zend_instruments_list ;
28
+ typedef struct zend_instrument_fcall_init_list zend_instrument_fcall_init_list ;
29
29
30
- static zend_instruments_list * _zend_instruments ;
30
+ static zend_instrument_fcall_init_list * zend_instrument_fcalls ;
31
31
32
- ZEND_API void zend_instrument_init (void )
33
- {
34
- _zend_instruments = NULL ;
32
+ ZEND_API void zend_instrument_init (void ) {
33
+ zend_instrument_fcalls = NULL ;
35
34
}
36
35
37
- ZEND_API void zend_instrument_shutdown (void )
38
- {
39
- zend_instruments_list * curr , * prev ;
40
- for (curr = _zend_instruments ; curr ; curr = prev ) {
36
+ ZEND_API void zend_instrument_shutdown (void ) {
37
+ zend_instrument_fcall_init_list * curr , * prev ;
38
+ for (curr = zend_instrument_fcalls ; curr ; curr = prev ) {
41
39
prev = curr -> prev ;
42
40
free (curr );
43
41
}
44
42
}
45
43
46
- ZEND_API void zend_instrument_register ( zend_instrument instrument )
47
- {
48
- zend_instruments_list * node = malloc (sizeof (zend_instruments_list ));
49
- node -> instrument = instrument ;
50
- node -> prev = _zend_instruments ;
51
- _zend_instruments = node ;
44
+ ZEND_API void zend_instrument_fcall_register ( zend_instrument_fcall_init cb ) {
45
+ zend_instrument_fcall_init_list * node =
46
+ malloc (sizeof (zend_instrument_fcall_init_list ));
47
+ node -> instrument = cb ;
48
+ node -> prev = zend_instrument_fcalls ;
49
+ zend_instrument_fcalls = node ;
52
50
}
53
51
54
- struct zend_instrument_handlers_list {
55
- struct zend_instrument_handlers_list * prev ;
56
- zend_instrument_handlers handlers ;
52
+ struct zend_instrument_fcall_list {
53
+ struct zend_instrument_fcall_list * prev ;
54
+ zend_instrument_fcall handlers ;
57
55
size_t count ;
58
56
};
59
- typedef struct zend_instrument_handlers_list zend_instrument_handlers_list ;
57
+ typedef struct zend_instrument_fcall_list zend_instrument_fcall_list ;
60
58
61
59
62
- extern inline void zend_instrument_call_begin_handlers (
63
- zend_execute_data * execute_data , zend_instrument_cache * cache );
64
- extern inline void zend_instrument_call_end_handlers (
65
- zend_execute_data * execute_data , zend_instrument_cache * cache );
60
+ extern inline void zend_instrument_fcall_call_begin (
61
+ zend_instrument_fcall_cache * cache ,
62
+ zend_execute_data * execute_data );
66
63
67
- static zend_instrument_handlers_list * _instrument_add (
68
- zend_instrument_handlers_list * instruments ,
69
- zend_instrument_handlers handlers )
64
+ extern inline void zend_instrument_fcall_call_end (
65
+ zend_instrument_fcall_cache * cache ,
66
+ zend_execute_data * execute_data ,
67
+ zval * return_value );
68
+
69
+ static zend_instrument_fcall_list * zend_instrument_fcall_add (
70
+ zend_instrument_fcall_list * instruments ,
71
+ zend_instrument_fcall handlers )
70
72
{
71
73
if (!handlers .begin && !handlers .end ) {
72
74
return instruments ;
73
75
}
74
76
75
- zend_instrument_handlers_list * n =
76
- emalloc (sizeof (zend_instrument_handlers_list ));
77
+ zend_instrument_fcall_list * n =
78
+ emalloc (sizeof (zend_instrument_fcall_list ));
77
79
if (instruments ) {
78
80
n -> prev = instruments ;
79
81
n -> count = instruments -> count + 1 ;
@@ -85,18 +87,18 @@ static zend_instrument_handlers_list *_instrument_add(
85
87
return n ;
86
88
}
87
89
88
- static zend_instrument_cache * _instrument_attach_handler (
90
+ static zend_instrument_fcall_cache * zend_instrument_fcall_list_attach (
89
91
zend_function * function ,
90
- zend_instrument_handlers_list * handlers_list )
92
+ zend_instrument_fcall_list * handlers_list )
91
93
{
92
- zend_instrument_cache * cache =
93
- malloc (sizeof (zend_instrument_cache ));
94
+ zend_instrument_fcall_cache * cache =
95
+ malloc (sizeof (zend_instrument_fcall_cache ));
94
96
cache -> instruments_len = handlers_list -> count ;
95
97
cache -> handlers =
96
- calloc (handlers_list -> count , sizeof (zend_instrument_handlers ));
98
+ calloc (handlers_list -> count , sizeof (zend_instrument_fcall ));
97
99
98
- zend_instrument_handlers * handlers = cache -> handlers ;
99
- zend_instrument_handlers_list * curr ;
100
+ zend_instrument_fcall * handlers = cache -> handlers ;
101
+ zend_instrument_fcall_list * curr ;
100
102
for (curr = handlers_list ; curr ; curr = curr -> prev ) {
101
103
* handlers ++ = curr -> handlers ;
102
104
}
@@ -106,26 +108,26 @@ static zend_instrument_cache *_instrument_attach_handler(
106
108
return cache ;
107
109
}
108
110
109
- ZEND_API void zend_instrument_install_handlers (zend_function * function )
110
- {
111
- zend_instrument_handlers_list * handlers_list = NULL ;
112
- zend_instruments_list * elem ;
111
+ ZEND_API void zend_instrument_fcall_install (zend_function * function ) {
112
+ zend_instrument_fcall_list * fcall_list = NULL ;
113
+ zend_instrument_fcall_init_list * elem ;
113
114
114
- for (elem = _zend_instruments ; elem ; elem = elem -> prev ) {
115
- zend_instrument_handlers handlers = elem -> instrument (function );
116
- handlers_list = _instrument_add ( handlers_list , handlers );
115
+ for (elem = zend_instrument_fcalls ; elem ; elem = elem -> prev ) {
116
+ zend_instrument_fcall handlers = elem -> instrument (function );
117
+ fcall_list = zend_instrument_fcall_add ( fcall_list , handlers );
117
118
}
118
119
119
- if (handlers_list ) {
120
- _instrument_attach_handler (function , handlers_list );
120
+ if (fcall_list ) {
121
+ zend_instrument_fcall_list_attach (function , fcall_list );
121
122
122
- // cleanup handlers_list
123
- zend_instrument_handlers_list * curr , * prev ;
124
- for (curr = handlers_list ; curr ; curr = prev ) {
123
+ // cleanup fcall_list
124
+ zend_instrument_fcall_list * curr , * prev ;
125
+ for (curr = fcall_list ; curr ; curr = prev ) {
125
126
prev = curr -> prev ;
126
127
efree (curr );
127
128
}
128
129
} else {
129
- ZEND_MAP_PTR_SET (function -> common .instrument_cache , ZEND_NOT_INSTRUMENTED );
130
+ ZEND_MAP_PTR_SET (function -> common .instrument_cache ,
131
+ ZEND_INSTRUMENT_FCALL_NOT_INSTRUMENTED );
130
132
}
131
133
}
0 commit comments