This source file includes following definitions.
- ZEND_BEGIN_MODULE_GLOBALS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #ifndef PHPDBG_H
22 #define PHPDBG_H
23
24 #ifdef PHP_WIN32
25 # define PHPDBG_API __declspec(dllexport)
26 #elif defined(__GNUC__) && __GNUC__ >= 4
27 # define PHPDBG_API __attribute__ ((visibility("default")))
28 #else
29 # define PHPDBG_API
30 #endif
31
32 #ifndef PHP_WIN32
33 # include <stdint.h>
34 # include <stddef.h>
35 #else
36 # include "main/php_stdint.h"
37 #endif
38 #include "php.h"
39 #include "php_globals.h"
40 #include "php_variables.h"
41 #include "php_getopt.h"
42 #include "zend_builtin_functions.h"
43 #include "zend_extensions.h"
44 #include "zend_modules.h"
45 #include "zend_globals.h"
46 #include "zend_ini_scanner.h"
47 #include "zend_stream.h"
48 #ifndef _WIN32
49 # include "zend_signal.h"
50 #endif
51 #include "SAPI.h"
52 #include <fcntl.h>
53 #include <sys/types.h>
54 #if defined(_WIN32) && !defined(__MINGW32__)
55 # include <windows.h>
56 # include "config.w32.h"
57 # undef strcasecmp
58 # undef strncasecmp
59 # define strcasecmp _stricmp
60 # define strncasecmp _strnicmp
61 #else
62 # include "php_config.h"
63 #endif
64 #ifndef O_BINARY
65 # define O_BINARY 0
66 #endif
67 #include "php_main.h"
68
69 #ifdef ZTS
70 # include "TSRM.h"
71 #endif
72
73 #undef zend_hash_str_add
74 #ifdef PHP_WIN32
75 #define zend_hash_str_add(...) \
76 _zend_hash_str_add(__VA_ARGS__ ZEND_FILE_LINE_CC)
77 #else
78 #define zend_hash_str_add_tmp(ht, key, len, pData) \
79 _zend_hash_str_add(ht, key, len, pData ZEND_FILE_LINE_CC)
80 #define zend_hash_str_add(...) zend_hash_str_add_tmp(__VA_ARGS__)
81 #endif
82
83 #ifdef HAVE_LIBREADLINE
84 # include <readline/readline.h>
85 # include <readline/history.h>
86 #endif
87 #ifdef HAVE_LIBEDIT
88 # include <editline/readline.h>
89 #endif
90
91
92 #ifndef _WIN32
93 # include <sys/socket.h>
94 # include <sys/un.h>
95 # include <sys/select.h>
96 # include <sys/types.h>
97 # include <netdb.h>
98 #endif
99
100
101 #define PHPDBG_NAME "phpdbg"
102 #define PHPDBG_AUTHORS "Felipe Pena, Joe Watkins and Bob Weinand"
103 #define PHPDBG_ISSUES "http://bugs.php.net/report.php"
104 #define PHPDBG_VERSION "0.5.0"
105 #define PHPDBG_INIT_FILENAME ".phpdbginit"
106 #define PHPDBG_DEFAULT_PROMPT "prompt>"
107
108
109
110 #ifdef memcpy
111 #define memcpy_tmp(...) memcpy(__VA_ARGS__)
112 #undef memcpy
113 #define memcpy(...) memcpy_tmp(__VA_ARGS__)
114 #endif
115
116 #define quiet_write(...) ZEND_IGNORE_VALUE(write(__VA_ARGS__))
117
118 #if !defined(PHPDBG_WEBDATA_TRANSFER_H) && !defined(PHPDBG_WEBHELPER_H)
119
120 #ifdef ZTS
121 # define PHPDBG_G(v) TSRMG(phpdbg_globals_id, zend_phpdbg_globals *, v)
122 #else
123 # define PHPDBG_G(v) (phpdbg_globals.v)
124 #endif
125
126 #include "phpdbg_sigsafe.h"
127 #include "phpdbg_out.h"
128 #include "phpdbg_lexer.h"
129 #include "phpdbg_cmd.h"
130 #include "phpdbg_utils.h"
131 #include "phpdbg_btree.h"
132 #include "phpdbg_watch.h"
133 #include "phpdbg_bp.h"
134 #include "phpdbg_opcode.h"
135 #ifdef PHP_WIN32
136 # include "phpdbg_sigio_win32.h"
137 #endif
138
139 int phpdbg_do_parse(phpdbg_param_t *stack, char *input);
140
141 #define PHPDBG_NEXT 2
142 #define PHPDBG_UNTIL 3
143 #define PHPDBG_FINISH 4
144 #define PHPDBG_LEAVE 5
145
146
147
148
149
150
151 #define PHPDBG_HAS_FILE_BP (1ULL<<1)
152 #define PHPDBG_HAS_PENDING_FILE_BP (1ULL<<2)
153 #define PHPDBG_HAS_SYM_BP (1ULL<<3)
154 #define PHPDBG_HAS_OPLINE_BP (1ULL<<4)
155 #define PHPDBG_HAS_METHOD_BP (1ULL<<5)
156 #define PHPDBG_HAS_COND_BP (1ULL<<6)
157 #define PHPDBG_HAS_OPCODE_BP (1ULL<<7)
158 #define PHPDBG_HAS_FUNCTION_OPLINE_BP (1ULL<<8)
159 #define PHPDBG_HAS_METHOD_OPLINE_BP (1ULL<<9)
160 #define PHPDBG_HAS_FILE_OPLINE_BP (1ULL<<10)
161
162
163
164
165
166 #define PHPDBG_IN_COND_BP (1ULL<<11)
167 #define PHPDBG_IN_EVAL (1ULL<<12)
168
169 #define PHPDBG_IS_STEPPING (1ULL<<13)
170 #define PHPDBG_STEP_OPCODE (1ULL<<14)
171 #define PHPDBG_IS_QUIET (1ULL<<15)
172 #define PHPDBG_IS_QUITTING (1ULL<<16)
173 #define PHPDBG_IS_COLOURED (1ULL<<17)
174 #define PHPDBG_IS_CLEANING (1ULL<<18)
175 #define PHPDBG_IS_RUNNING (1ULL<<19)
176
177 #define PHPDBG_IN_UNTIL (1ULL<<20)
178 #define PHPDBG_IN_FINISH (1ULL<<21)
179 #define PHPDBG_IN_LEAVE (1ULL<<22)
180
181 #define PHPDBG_IS_REGISTERED (1ULL<<23)
182 #define PHPDBG_IS_STEPONEVAL (1ULL<<24)
183 #define PHPDBG_IS_INITIALIZING (1ULL<<25)
184 #define PHPDBG_IS_SIGNALED (1ULL<<26)
185 #define PHPDBG_IS_INTERACTIVE (1ULL<<27)
186 #define PHPDBG_PREVENT_INTERACTIVE (1ULL<<28)
187 #define PHPDBG_IS_BP_ENABLED (1ULL<<29)
188 #define PHPDBG_IS_REMOTE (1ULL<<30)
189 #define PHPDBG_IS_DISCONNECTED (1ULL<<31)
190 #define PHPDBG_WRITE_XML (1ULL<<32)
191
192 #define PHPDBG_SHOW_REFCOUNTS (1ULL<<33)
193
194 #define PHPDBG_IN_SIGNAL_HANDLER (1ULL<<34)
195
196 #define PHPDBG_DISCARD_OUTPUT (1ULL<<35)
197
198 #define PHPDBG_HAS_PAGINATION (1ULL<<36)
199
200 #define PHPDBG_SEEK_MASK (PHPDBG_IN_UNTIL | PHPDBG_IN_FINISH | PHPDBG_IN_LEAVE)
201 #define PHPDBG_BP_RESOLVE_MASK (PHPDBG_HAS_FUNCTION_OPLINE_BP | PHPDBG_HAS_METHOD_OPLINE_BP | PHPDBG_HAS_FILE_OPLINE_BP)
202 #define PHPDBG_BP_MASK (PHPDBG_HAS_FILE_BP | PHPDBG_HAS_SYM_BP | PHPDBG_HAS_METHOD_BP | PHPDBG_HAS_OPLINE_BP | PHPDBG_HAS_COND_BP | PHPDBG_HAS_OPCODE_BP | PHPDBG_HAS_FUNCTION_OPLINE_BP | PHPDBG_HAS_METHOD_OPLINE_BP | PHPDBG_HAS_FILE_OPLINE_BP)
203 #define PHPDBG_IS_STOPPING (PHPDBG_IS_QUITTING | PHPDBG_IS_CLEANING)
204
205 #define PHPDBG_PRESERVE_FLAGS_MASK (PHPDBG_SHOW_REFCOUNTS | PHPDBG_IS_STEPONEVAL | PHPDBG_IS_BP_ENABLED | PHPDBG_STEP_OPCODE | PHPDBG_IS_QUIET | PHPDBG_IS_COLOURED | PHPDBG_IS_REMOTE | PHPDBG_WRITE_XML | PHPDBG_IS_DISCONNECTED | PHPDBG_HAS_PAGINATION)
206
207 #ifndef _WIN32
208 # define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET | PHPDBG_IS_COLOURED | PHPDBG_IS_BP_ENABLED | PHPDBG_HAS_PAGINATION)
209 #else
210 # define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET | PHPDBG_IS_BP_ENABLED | PHPDBG_HAS_PAGINATION)
211 #endif
212
213
214 #define PHPDBG_STDIN 0
215 #define PHPDBG_STDOUT 1
216 #define PHPDBG_STDERR 2
217 #define PHPDBG_IO_FDS 3
218
219 #define phpdbg_try_access \
220 { \
221 JMP_BUF *__orig_bailout = PHPDBG_G(sigsegv_bailout); \
222 JMP_BUF __bailout; \
223 \
224 PHPDBG_G(sigsegv_bailout) = &__bailout; \
225 if (SETJMP(__bailout) == 0) {
226 #define phpdbg_catch_access \
227 } else { \
228 PHPDBG_G(sigsegv_bailout) = __orig_bailout;
229 #define phpdbg_end_try_access() \
230 } \
231 PHPDBG_G(sigsegv_bailout) = __orig_bailout; \
232 }
233
234
235
236 ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
237 HashTable bp[PHPDBG_BREAK_TABLES];
238 HashTable registered;
239 HashTable seek;
240 zend_execute_data *seek_ex;
241 zend_object *handled_exception;
242 phpdbg_frame_t frame;
243 uint32_t last_line;
244
245 phpdbg_lexer_data lexer;
246 phpdbg_param_t *parser_stack;
247
248 #ifndef _WIN32
249 struct sigaction old_sigsegv_signal;
250 #endif
251 phpdbg_btree watchpoint_tree;
252 phpdbg_btree watch_HashTables;
253 HashTable watchpoints;
254 HashTable watch_collisions;
255 zend_llist watchlist_mem;
256 zend_bool watchpoint_hit;
257 void (*original_free_function)(void *);
258 phpdbg_watchpoint_t *watch_tmp;
259
260 char *exec;
261 size_t exec_len;
262 zend_op_array *ops;
263 zval retval;
264 int bp_count;
265 int vmret;
266 zend_bool in_execution;
267 zend_bool unclean_eval;
268
269 zend_op_array *(*compile_file)(zend_file_handle *file_handle, int type);
270 zend_op_array *(*init_compile_file)(zend_file_handle *file_handle, int type);
271 zend_op_array *(*compile_string)(zval *source_string, char *filename);
272 HashTable file_sources;
273
274 FILE *oplog;
275 zend_arena *oplog_arena;
276 phpdbg_oplog_list *oplog_list;
277 phpdbg_oplog_entry *oplog_cur;
278
279 struct {
280 FILE *ptr;
281 int fd;
282 } io[PHPDBG_IO_FDS];
283 int eol;
284 size_t (*php_stdiop_write)(php_stream *, const char *, size_t);
285 int in_script_xml;
286 struct {
287 zend_bool active;
288 int type;
289 int fd;
290 char *tag;
291 char *msg;
292 int msglen;
293 char *xml;
294 int xmllen;
295 } err_buf;
296 zend_ulong req_id;
297
298 char *prompt[2];
299 const phpdbg_color_t *colors[PHPDBG_COLORS];
300 char *buffer;
301 zend_bool last_was_newline;
302
303 char input_buffer[PHPDBG_MAX_CMD];
304 int input_buflen;
305 phpdbg_signal_safe_mem sigsafe_mem;
306
307 JMP_BUF *sigsegv_bailout;
308
309 uint64_t flags;
310
311 char *socket_path;
312 char *sapi_name_ptr;
313 int socket_fd;
314 int socket_server_fd;
315 #ifdef PHP_WIN32
316 HANDLE sigio_watcher_thread;
317 struct win32_sigio_watcher_data swd;
318 #endif
319 long lines;
320 ZEND_END_MODULE_GLOBALS(phpdbg)
321
322 #endif
323
324 #endif