diff options
Diffstat (limited to 'sapi/phpdbg')
| -rw-r--r-- | sapi/phpdbg/Makefile.frag | 2 | ||||
| -rw-r--r-- | sapi/phpdbg/phpdbg.c | 246 | ||||
| -rw-r--r-- | sapi/phpdbg/phpdbg.h | 4 | ||||
| -rw-r--r-- | sapi/phpdbg/phpdbg_bp.c | 24 | ||||
| -rw-r--r-- | sapi/phpdbg/phpdbg_cmd.c | 9 | ||||
| -rw-r--r-- | sapi/phpdbg/phpdbg_lexer.c | 1058 | ||||
| -rw-r--r-- | sapi/phpdbg/phpdbg_lexer.l | 24 | ||||
| -rw-r--r-- | sapi/phpdbg/phpdbg_list.c | 82 | ||||
| -rw-r--r-- | sapi/phpdbg/phpdbg_list.h | 2 | ||||
| -rw-r--r-- | sapi/phpdbg/phpdbg_opcode.c | 2 | ||||
| -rw-r--r-- | sapi/phpdbg/phpdbg_out.c | 1 | ||||
| -rw-r--r-- | sapi/phpdbg/phpdbg_prompt.c | 46 | ||||
| -rw-r--r-- | sapi/phpdbg/phpdbg_prompt.h | 5 | ||||
| -rw-r--r-- | sapi/phpdbg/phpdbg_sigsafe.h | 5 | ||||
| -rw-r--r-- | sapi/phpdbg/phpdbg_utils.c | 16 | ||||
| -rw-r--r-- | sapi/phpdbg/tests/normal_exit.phpt | 15 | ||||
| -rw-r--r-- | sapi/phpdbg/zend_mm_structs.h | 102 |
17 files changed, 812 insertions, 831 deletions
diff --git a/sapi/phpdbg/Makefile.frag b/sapi/phpdbg/Makefile.frag index 36c7512d69..e0cdfe25ef 100644 --- a/sapi/phpdbg/Makefile.frag +++ b/sapi/phpdbg/Makefile.frag @@ -14,7 +14,7 @@ $(BUILD_BINARY): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_PHPDBG_OBJS) $(builddir)/phpdbg_lexer.lo: $(srcdir)/phpdbg_parser.h $(srcdir)/phpdbg_lexer.c: $(srcdir)/phpdbg_lexer.l - @(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) --no-generation-date -cbdFo $(srcdir)/phpdbg_lexer.c $(srcdir)/phpdbg_lexer.l) + @(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) --no-generation-date -cbdFo sapi/phpdbg/phpdbg_lexer.c sapi/phpdbg/phpdbg_lexer.l) $(srcdir)/phpdbg_parser.h: $(srcdir)/phpdbg_parser.c $(srcdir)/phpdbg_parser.c: $(srcdir)/phpdbg_parser.y diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index ecfe7a9249..d92f1ab4dc 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -72,12 +72,6 @@ PHP_INI_END() static zend_bool phpdbg_booted = 0; static zend_bool phpdbg_fully_started = 0; -#if PHP_VERSION_ID >= 50500 -void (*zend_execute_old)(zend_execute_data *execute_data); -#else -void (*zend_execute_old)(zend_op_array *op_array); -#endif - static inline void php_phpdbg_globals_ctor(zend_phpdbg_globals *pg) /* {{{ */ { pg->prompt[0] = NULL; @@ -102,6 +96,7 @@ static inline void php_phpdbg_globals_ctor(zend_phpdbg_globals *pg) /* {{{ */ pg->sapi_name_ptr = NULL; pg->socket_fd = -1; pg->socket_server_fd = -1; + pg->unclean_eval = 0; pg->req_id = 0; pg->err_buf.active = 0; @@ -126,13 +121,7 @@ static PHP_MINIT_FUNCTION(phpdbg) /* {{{ */ ZEND_INIT_MODULE_GLOBALS(phpdbg, php_phpdbg_globals_ctor, NULL); REGISTER_INI_ENTRIES(); -#if PHP_VERSION_ID >= 50500 - zend_execute_old = zend_execute_ex; zend_execute_ex = phpdbg_execute_ex; -#else - zend_execute_old = zend_execute; - zend_execute = phpdbg_execute_ex; -#endif REGISTER_STRINGL_CONSTANT("PHPDBG_VERSION", PHPDBG_VERSION, sizeof(PHPDBG_VERSION)-1, CONST_CS|CONST_PERSISTENT); @@ -151,43 +140,42 @@ static PHP_MINIT_FUNCTION(phpdbg) /* {{{ */ static void php_phpdbg_destroy_bp_file(zval *brake) /* {{{ */ { zend_hash_destroy(Z_ARRVAL_P(brake)); + efree(Z_ARRVAL_P(brake)); } /* }}} */ static void php_phpdbg_destroy_bp_symbol(zval *brake) /* {{{ */ { efree((char *) ((phpdbg_breaksymbol_t *) Z_PTR_P(brake))->symbol); + efree(Z_PTR_P(brake)); } /* }}} */ static void php_phpdbg_destroy_bp_opcode(zval *brake) /* {{{ */ { efree((char *) ((phpdbg_breakop_t *) Z_PTR_P(brake))->name); + efree(Z_PTR_P(brake)); } /* }}} */ - static void php_phpdbg_destroy_bp_methods(zval *brake) /* {{{ */ { zend_hash_destroy(Z_ARRVAL_P(brake)); + efree(Z_ARRVAL_P(brake)); } /* }}} */ static void php_phpdbg_destroy_bp_condition(zval *data) /* {{{ */ { phpdbg_breakcond_t *brake = (phpdbg_breakcond_t *) Z_PTR_P(data); - if (brake) { - if (brake->ops) { - - destroy_op_array(brake->ops); - efree(brake->ops); - } - efree((char*) brake->code); + if (brake->ops) { + destroy_op_array(brake->ops); + efree(brake->ops); } + efree((char*) brake->code); + efree(brake); } /* }}} */ static void php_phpdbg_destroy_registered(zval *data) /* {{{ */ { zend_function *function = (zend_function *) Z_PTR_P(data); - - destroy_zend_function(function); } /* }}} */ @@ -215,6 +203,7 @@ static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */ { zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING]); zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]); zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE]); zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE]); @@ -240,16 +229,6 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */ PHPDBG_G(exec) = NULL; } - if (PHPDBG_G(prompt)[0]) { - free(PHPDBG_G(prompt)[0]); - } - if (PHPDBG_G(prompt)[1]) { - free(PHPDBG_G(prompt)[1]); - } - - PHPDBG_G(prompt)[0] = NULL; - PHPDBG_G(prompt)[1] = NULL; - if (PHPDBG_G(oplog)) { fclose(PHPDBG_G(oplog)); PHPDBG_G(oplog) = NULL; @@ -847,25 +826,8 @@ static void php_sapi_phpdbg_log_message(char *message) /* {{{ */ static int php_sapi_phpdbg_deactivate(void) /* {{{ */ { - if ((PHPDBG_G(flags) & PHPDBG_IS_STOPPING) == PHPDBG_IS_CLEANING) { - zend_phpdbg_globals *pg = PHPDBG_G(backup) = calloc(1, sizeof(zend_phpdbg_globals)); - - php_phpdbg_globals_ctor(pg); - - pg->exec = zend_strndup(PHPDBG_G(exec), PHPDBG_G(exec_len)); - pg->exec_len = PHPDBG_G(exec_len); - pg->oplog = PHPDBG_G(oplog); - pg->prompt[0] = PHPDBG_G(prompt)[0]; - pg->prompt[1] = PHPDBG_G(prompt)[1]; - memcpy(pg->colors, PHPDBG_G(colors), sizeof(pg->colors)); - pg->eol = PHPDBG_G(eol); - pg->input_buflen = PHPDBG_G(input_buflen); - memcpy(pg->input_buffer, PHPDBG_G(input_buffer), pg->input_buflen); - pg->flags = PHPDBG_G(flags) & PHPDBG_PRESERVE_FLAGS_MASK; - } - fflush(stdout); - if(SG(request_info).argv0) { + if (SG(request_info).argv0) { free(SG(request_info).argv0); SG(request_info).argv0 = NULL; } @@ -946,14 +908,8 @@ static size_t phpdbg_stdiop_write(php_stream *stream, const char *buf, size_t co return PHPDBG_G(php_stdiop_write)(stream, buf, count); } -#if PHP_VERSION_ID >= 50700 -static inline void php_sapi_phpdbg_flush(void *context) /* {{{ */ -{ -#else static inline void php_sapi_phpdbg_flush(void *context) /* {{{ */ { -#endif - if (!phpdbg_active_sigsafe_mem()) { fflush(PHPDBG_G(io)[PHPDBG_STDOUT].ptr); } @@ -1083,7 +1039,6 @@ const char phpdbg_ini_hardcoded[] = /* overwriteable ini defaults must be set in phpdbg_ini_defaults() */ #define INI_DEFAULT(name, value) \ ZVAL_STRINGL(&tmp, value, sizeof(value) - 1); \ - Z_SET_REFCOUNT(tmp, 0); \ zend_hash_str_update(configuration_hash, name, sizeof(name) - 1, &tmp); void phpdbg_ini_defaults(HashTable *configuration_hash) /* {{{ */ @@ -1269,37 +1224,64 @@ void phpdbg_signal_handler(int sig, siginfo_t *info, void *context) /* {{{ */ } /* }}} */ #endif -static inline zend_mm_heap *phpdbg_mm_get_heap() /* {{{ */ -{ - zend_mm_heap *mm_heap; - - - mm_heap = zend_mm_set_heap(NULL); - zend_mm_set_heap(mm_heap); - return mm_heap; -} /* }}} */ +/* A bit dark magic in order to have meaningful allocator adresses [ppc(64) may return bogus addresses here] */ +#if ZEND_DEBUG && (__has_builtin(__builtin_frame_address) || ZEND_GCC_VERSION >= 3004) && !defined(__ppc__) && !defined(__ppc64__) +/* with gcc %rbp/%ebp for __builtin_frame_address() and clang returns the frame return address being at %ebp/%rbp + sizeof(void*) */ +# ifdef __clang__ +# define FETCH_PARENT_START() \ + parent -= ZEND_MM_ALIGNED_SIZE(sizeof(void *)); +# else +# define FETCH_PARENT_START() +# endif +# define FETCH_PARENT_FILELINE(argsize) \ + char *__zend_filename, *__zend_orig_filename; \ + uint __zend_lineno, __zend_orig_lineno; \ + void *parent = __builtin_frame_address(1U); \ + FETCH_PARENT_START() \ + parent -= (argsize); /* size of first arguments */ \ + parent -= sizeof(char *); /* filename */ \ + __zend_filename = *(char **) parent; \ + parent = (void *) ((intptr_t) parent & ZEND_MM_ALIGNMENT_MASK); /* realign */ \ + parent -= sizeof(uint); /* lineno */ \ + __zend_lineno = *(uint *) parent; \ + parent = (void *) ((intptr_t) parent & ZEND_MM_ALIGNMENT_MASK); /* realign */ \ + parent -= sizeof(char *); /* orig_filename */ \ + __zend_orig_filename = *(char **) parent; \ + parent = (void *) ((intptr_t) parent & ZEND_MM_ALIGNMENT_MASK); /* realign */ \ + parent -= sizeof(uint); /* orig_lineno */ \ + __zend_orig_lineno = *(uint *) parent; +#elif ZEND_DEBUG +# define FETCH_PARENT_FILELINE(argsize) \ + char *__zend_filename = __FILE__, *__zend_orig_filename = NULL; \ + uint __zend_lineno = __LINE__, __zend_orig_lineno = 0; +#else +# define FETCH_PARENT_FILELINE(argsize) +#endif void *phpdbg_malloc_wrapper(size_t size) /* {{{ */ { - return zend_mm_alloc(phpdbg_mm_get_heap(), size); + FETCH_PARENT_FILELINE(ZEND_MM_ALIGNED_SIZE(sizeof(size))); + return _zend_mm_alloc(zend_mm_get_heap(), size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); } /* }}} */ void phpdbg_free_wrapper(void *p) /* {{{ */ { - zend_mm_heap *heap = phpdbg_mm_get_heap(); + zend_mm_heap *heap = zend_mm_get_heap(); if (UNEXPECTED(heap == p)) { /* TODO: heap maybe allocated by mmap(zend_mm_init) or malloc(USE_ZEND_ALLOC=0) * let's prevent it from segfault for now */ } else { - zend_mm_free(heap, p); + FETCH_PARENT_FILELINE(ZEND_MM_ALIGNED_SIZE(sizeof(p))); + return _zend_mm_free(heap, p ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); } } /* }}} */ void *phpdbg_realloc_wrapper(void *ptr, size_t size) /* {{{ */ { - return zend_mm_realloc(phpdbg_mm_get_heap(), ptr, size); + FETCH_PARENT_FILELINE(ZEND_MM_ALIGNED_SIZE(sizeof(ptr)) + ZEND_MM_ALIGNED_SIZE(sizeof(size))); + return _zend_mm_realloc(zend_mm_get_heap(), ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); } /* }}} */ int main(int argc, char **argv) /* {{{ */ @@ -1333,6 +1315,8 @@ int main(int argc, char **argv) /* {{{ */ FILE* stream = NULL; char *print_opline_func; zend_bool ext_stmt = 0; + zend_bool use_mm_wrappers = 0; + zend_bool is_exit; #ifdef ZTS void ***tsrm_ls; @@ -1377,6 +1361,7 @@ phpdbg_main: oplog_file = NULL; oplog_file_len = 0; flags = PHPDBG_DEFAULT_FLAGS; + is_exit = 0; php_optarg = NULL; php_optind = 1; opt = 0; @@ -1606,11 +1591,11 @@ phpdbg_main: phpdbg->ini_entries = ini_entries; if (phpdbg->startup(phpdbg) == SUCCESS) { + zend_mm_heap *mm_heap; #ifdef _WIN32 EXCEPTION_POINTERS *xp; __try { #endif - zend_mm_heap *mm_heap; void* (*_malloc)(size_t); void (*_free)(void*); void* (*_realloc)(void*, size_t); @@ -1624,6 +1609,7 @@ phpdbg_main: #else phpdbg_globals = *settings; #endif + free(settings); } /* setup remote server if necessary */ @@ -1641,21 +1627,17 @@ phpdbg_main: remote = 1; } - mm_heap = phpdbg_mm_get_heap(); + mm_heap = zend_mm_get_heap(); zend_mm_get_custom_handlers(mm_heap, &_malloc, &_free, &_realloc); - if (!_malloc) { + use_mm_wrappers = !_malloc && !_realloc && !_free; + + if (use_mm_wrappers) { _malloc = phpdbg_malloc_wrapper; - } - if (!_realloc) { _realloc = phpdbg_realloc_wrapper; - } - if (!_free) { _free = phpdbg_free_wrapper; } - zend_activate(); - phpdbg_init_list(); PHPDBG_G(original_free_function) = _free; @@ -1692,9 +1674,14 @@ phpdbg_main: php_output_activate(); php_output_deactivate(); + if (SG(sapi_headers).mimetype) { + efree(SG(sapi_headers).mimetype); + SG(sapi_headers).mimetype = NULL; + } + php_output_activate(); - if (php_request_startup() == SUCCESS) { + { int i; SG(request_info).argc = argc - php_optind + 1; @@ -1703,8 +1690,11 @@ phpdbg_main: SG(request_info).argv[i] = estrdup(argv[php_optind - 1 + i]); } SG(request_info).argv[0] = PHPDBG_G(exec) ? estrdup(PHPDBG_G(exec)) : estrdup(""); + } - php_hash_environment(); + if (php_request_startup() == FAILURE) { + PUTS("Could not startup"); + return 1; } /* do not install sigint handlers for remote consoles */ @@ -1719,20 +1709,13 @@ phpdbg_main: #endif #ifndef _WIN32 } -#endif - PG(modules_activated) = 0; - -#ifndef _WIN32 /* setup io here */ if (remote) { PHPDBG_G(flags) |= PHPDBG_IS_REMOTE; signal(SIGPIPE, SIG_IGN); } -#endif - -#ifndef _WIN32 PHPDBG_G(io)[PHPDBG_STDIN].ptr = stdin; PHPDBG_G(io)[PHPDBG_STDIN].fd = fileno(stdin); PHPDBG_G(io)[PHPDBG_STDOUT].ptr = stdout; @@ -1782,6 +1765,8 @@ phpdbg_main: /* Make stdin, stdout and stderr accessible from PHP scripts */ phpdbg_register_file_handles(); + phpdbg_list_update(); + if (show_banner && cleaning < 2) { /* print blurb */ phpdbg_welcome(cleaning == 1); @@ -1842,7 +1827,6 @@ phpdbg_main: #ifndef _WIN32 phpdbg_interact: #endif - /* phpdbg main() */ do { zend_try { @@ -1857,6 +1841,7 @@ phpdbg_interact: } } + CG(unclean_shutdown) = 0; phpdbg_interactive(1); } zend_catch { if ((PHPDBG_G(flags) & PHPDBG_IS_CLEANING)) { @@ -1900,16 +1885,6 @@ phpdbg_interact: } while (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)); - if (PHPDBG_G(exec) && (PHPDBG_G(flags) & PHPDBG_IS_CLEANING)) { - exec = strdup(PHPDBG_G(exec)); /* preserve exec, don't reparse that from cmd */ - } - - /* this must be forced */ - CG(unclean_shutdown) = 0; - - /* this is just helpful */ - PG(report_memleaks) = 0; - #ifndef _WIN32 phpdbg_out: if ((PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED)) { @@ -1939,16 +1914,6 @@ phpdbg_out: efree(SG(request_info).argv); } -#ifndef _WIN32 - /* reset it... else we risk a stack overflow upon next run (when clean'ing) */ - php_stream_stdio_ops.write = PHPDBG_G(php_stdiop_write); -#endif - -#ifndef ZTS - /* force cleanup of auto and core globals */ - zend_hash_clean(CG(auto_globals)); - memset( &core_globals, 0, sizeof(php_core_globals)); -#endif if (ini_entries) { free(ini_entries); } @@ -1957,42 +1922,73 @@ phpdbg_out: free(ini_override); } - /* this must be forced */ - CG(unclean_shutdown) = 0; - - /* this is just helpful */ - PG(report_memleaks) = 0; + /* In case we aborted during script execution, we may not reset CG(unclean_shutdown) */ + if (!(PHPDBG_G(flags) & PHPDBG_IS_RUNNING)) { + is_exit = !PHPDBG_G(in_execution) && EG(exit_status) != 255; + CG(unclean_shutdown) = is_exit || PHPDBG_G(unclean_eval); + } if ((PHPDBG_G(flags) & (PHPDBG_IS_CLEANING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_CLEANING) { php_free_shutdown_functions(); zend_objects_store_mark_destructed(&EG(objects_store)); } - /* sapi_module.deactivate is where to backup things, last chance before mm_shutdown... */ + /* backup globals when cleaning */ + if ((cleaning > 0 || remote) && !quit_immediately) { + settings = calloc(1, sizeof(zend_phpdbg_globals)); - zend_try { - php_request_shutdown(NULL); - } zend_end_try(); + php_phpdbg_globals_ctor(settings); - if ((PHPDBG_G(flags) & (PHPDBG_IS_QUITTING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_RUNNING) { - if (!quit_immediately && !phpdbg_startup_run) { - phpdbg_notice("stop", "type=\"normal\"", "Script ended normally"); + if (PHPDBG_G(exec)) { + settings->exec = zend_strndup(PHPDBG_G(exec), PHPDBG_G(exec_len)); + settings->exec_len = PHPDBG_G(exec_len); + } + settings->oplog = PHPDBG_G(oplog); + settings->prompt[0] = PHPDBG_G(prompt)[0]; + settings->prompt[1] = PHPDBG_G(prompt)[1]; + memcpy(settings->colors, PHPDBG_G(colors), sizeof(settings->colors)); + settings->eol = PHPDBG_G(eol); + settings->input_buflen = PHPDBG_G(input_buflen); + memcpy(settings->input_buffer, PHPDBG_G(input_buffer), settings->input_buflen); + settings->flags = PHPDBG_G(flags) & PHPDBG_PRESERVE_FLAGS_MASK; + } else { + if (PHPDBG_G(prompt)[0]) { + free(PHPDBG_G(prompt)[0]); + } + if (PHPDBG_G(prompt)[1]) { + free(PHPDBG_G(prompt)[1]); } - cleaning++; } - if ((PHPDBG_G(flags) & PHPDBG_IS_STOPPING) == PHPDBG_IS_CLEANING) { - settings = PHPDBG_G(backup); + /* hack to restore mm_heap->use_custom_heap in order to receive memory leak info */ + if (use_mm_wrappers) { + /* ASSUMING that mm_heap->use_custom_heap is the first element of the struct ... */ + *(int *) mm_heap = 0; } + zend_try { + php_request_shutdown(NULL); + } zend_end_try(); + if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { + if (PHPDBG_G(in_execution) || is_exit) { + if (!quit_immediately && !phpdbg_startup_run) { + phpdbg_notice("stop", "type=\"normal\"", "Script ended normally"); + cleaning++; + } + } + } php_output_deactivate(); zend_try { php_module_shutdown(); } zend_end_try(); - sapi_shutdown(); +#ifndef _WIN32 + /* reset it... else we risk a stack overflow upon next run (when clean'ing) */ + php_stream_stdio_ops.write = PHPDBG_G(php_stdiop_write); +#endif + sapi_shutdown(); } if ((cleaning > 0 || remote) && !quit_immediately) { diff --git a/sapi/phpdbg/phpdbg.h b/sapi/phpdbg/phpdbg.h index f900866211..ac9e80946b 100644 --- a/sapi/phpdbg/phpdbg.h +++ b/sapi/phpdbg/phpdbg.h @@ -259,8 +259,10 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) int bp_count; /* breakpoint count */ int vmret; /* return from last opcode handler execution */ zend_bool in_execution; /* in execution? */ + zend_bool unclean_eval; /* do not check for memory leaks when we needed to bail out during eval */ zend_op_array *(*compile_file)(zend_file_handle *file_handle, int type); + zend_op_array *(*init_compile_file)(zend_file_handle *file_handle, int type); HashTable file_sources; FILE *oplog; /* opline log */ @@ -308,8 +310,6 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) HANDLE sigio_watcher_thread; /* sigio watcher thread handle */ struct win32_sigio_watcher_data swd; #endif - - struct _zend_phpdbg_globals *backup; /* backup of data to store */ ZEND_END_MODULE_GLOBALS(phpdbg) /* }}} */ #endif diff --git a/sapi/phpdbg/phpdbg_bp.c b/sapi/phpdbg/phpdbg_bp.c index 60c68e2cc3..7a6a66b50e 100644 --- a/sapi/phpdbg/phpdbg_bp.c +++ b/sapi/phpdbg/phpdbg_bp.c @@ -63,6 +63,7 @@ static void phpdbg_file_breaks_dtor(zval *data) /* {{{ */ phpdbg_breakfile_t *bp = (phpdbg_breakfile_t*) Z_PTR_P(data); efree((char*)bp->filename); + efree(bp); } /* }}} */ static void phpdbg_class_breaks_dtor(zval *data) /* {{{ */ @@ -71,11 +72,13 @@ static void phpdbg_class_breaks_dtor(zval *data) /* {{{ */ efree((char*)bp->class_name); efree((char*)bp->func_name); + efree(bp); } /* }}} */ static void phpdbg_opline_class_breaks_dtor(zval *data) /* {{{ */ { - zend_hash_destroy((HashTable *) Z_PTR_P(data)); + zend_hash_destroy(Z_ARRVAL_P(data)); + efree(Z_ARRVAL_P(data)); } /* }}} */ static void phpdbg_opline_breaks_dtor(zval *data) /* {{{ */ @@ -88,6 +91,7 @@ static void phpdbg_opline_breaks_dtor(zval *data) /* {{{ */ if (bp->func_name) { efree((char*)bp->func_name); } + efree(bp); } /* }}} */ PHPDBG_API void phpdbg_reset_breakpoints(void) /* {{{ */ @@ -230,8 +234,9 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num) /* { char realpath[MAXPATHLEN]; const char *original_path = path; zend_bool pending = 0; + zend_string *path_str; - HashTable *broken, *file_breaks = &PHPDBG_G(bp)[PHPDBG_BREAK_FILE]; + HashTable *broken, *file_breaks = &PHPDBG_G(bp)[PHPDBG_BREAK_FILE]; phpdbg_breakfile_t new_break; size_t path_len = 0L; @@ -261,11 +266,13 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num) /* { } } - if (!(broken = zend_hash_str_find_ptr(file_breaks, path, path_len))) { + path_str = zend_string_init(path, path_len, 0); + + if (!(broken = zend_hash_find_ptr(file_breaks, path_str))) { HashTable breaks; zend_hash_init(&breaks, 8, NULL, phpdbg_file_breaks_dtor, 0); - broken = zend_hash_str_add_mem(file_breaks, path, path_len, &breaks, sizeof(HashTable)); + broken = zend_hash_add_mem(file_breaks, path_str, &breaks, sizeof(HashTable)); } if (!zend_hash_index_exists(broken, line_num)) { @@ -278,7 +285,7 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num) /* { PHPDBG_BREAK_MAPPING(new_break.id, broken); if (pending) { - zend_string *file, *path_str = zend_string_init(path, path_len, 0); + zend_string *file; ZEND_HASH_FOREACH_STR_KEY(&PHPDBG_G(file_sources), file) { HashTable *fileht; @@ -289,7 +296,6 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num) /* { break; } } ZEND_HASH_FOREACH_END(); - zend_string_release(path_str); } if (pending) { @@ -304,6 +310,8 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num) /* { } else { phpdbg_error("breakpoint", "type=\"exists\" add=\"fail\" file=\"%s\" line=\"%ld\"", "Breakpoint at %s:%ld exists", path, line_num); } + + zend_string_release(path_str); } /* }}} */ PHPDBG_API HashTable *phpdbg_resolve_pending_file_break_ex(const char *file, uint filelen, zend_string *cur, HashTable *fileht) /* {{{ */ @@ -1066,11 +1074,7 @@ static inline phpdbg_breakbase_t *phpdbg_find_conditional_breakpoint(zend_execut zend_try { PHPDBG_G(flags) |= PHPDBG_IN_COND_BP; zend_execute(bp->ops, &retval); -#if PHP_VERSION_ID >= 50700 if (zend_is_true(&retval)) { -#else - if (zend_is_true(&retval)) { -#endif breakpoint = SUCCESS; } } zend_end_try(); diff --git a/sapi/phpdbg/phpdbg_cmd.c b/sapi/phpdbg/phpdbg_cmd.c index 12eb3874fd..69b08f33ec 100644 --- a/sapi/phpdbg/phpdbg_cmd.c +++ b/sapi/phpdbg/phpdbg_cmd.c @@ -325,7 +325,7 @@ PHPDBG_API void phpdbg_param_debug(const phpdbg_param_t *param, const char *msg) if (param && param->type) { switch (param->type) { case STR_PARAM: - fprintf(stderr, "%s STR_PARAM(%s=%lu)\n", msg, param->str, param->len); + fprintf(stderr, "%s STR_PARAM(%s=%zu)\n", msg, param->str, param->len); break; case ADDR_PARAM: @@ -357,11 +357,11 @@ PHPDBG_API void phpdbg_param_debug(const phpdbg_param_t *param, const char *msg) break; case COND_PARAM: - fprintf(stderr, "%s COND_PARAM(%s=%lu)\n", msg, param->str, param->len); + fprintf(stderr, "%s COND_PARAM(%s=%zu)\n", msg, param->str, param->len); break; case OP_PARAM: - fprintf(stderr, "%s OP_PARAM(%s=%lu)\n", msg, param->str, param->len); + fprintf(stderr, "%s OP_PARAM(%s=%zu)\n", msg, param->str, param->len); break; default: { @@ -765,6 +765,9 @@ PHPDBG_API char *phpdbg_read_input(char *buffered) /* {{{ */ PHPDBG_G(buffer) = estrdup(buffer); } else { if (PHPDBG_G(buffer)) { + if (buffer) { + efree(buffer); + } buffer = estrdup(PHPDBG_G(buffer)); } } diff --git a/sapi/phpdbg/phpdbg_lexer.c b/sapi/phpdbg/phpdbg_lexer.c index 6b503f04ed..1e4193b72f 100644 --- a/sapi/phpdbg/phpdbg_lexer.c +++ b/sapi/phpdbg/phpdbg_lexer.c @@ -1,5 +1,5 @@ /* Generated by re2c 0.13.5 */ -#line 1 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 1 "sapi/phpdbg/phpdbg_lexer.l" /* * phpdbg_lexer.l */ @@ -45,7 +45,7 @@ restart: LEX(text) = YYCURSOR; -#line 49 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" +#line 49 "sapi/phpdbg/phpdbg_lexer.c" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -150,14 +150,14 @@ yy2: yy3: YYDEBUG(3, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 176 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 178 "sapi/phpdbg/phpdbg_lexer.l" { YYSETCONDITION(NORMAL); YYCURSOR = LEX(text); goto restart; } -#line 161 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" +#line 161 "sapi/phpdbg/phpdbg_lexer.c" yy4: YYDEBUG(4, *YYCURSOR); ++YYCURSOR; @@ -172,11 +172,11 @@ yy4: yy6: YYDEBUG(6, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 69 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 70 "sapi/phpdbg/phpdbg_lexer.l" { return 0; } -#line 180 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" +#line 180 "sapi/phpdbg/phpdbg_lexer.c" yy7: YYDEBUG(7, *YYCURSOR); yych = *++YYCURSOR; @@ -243,13 +243,13 @@ yy16: } YYDEBUG(18, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 163 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 165 "sapi/phpdbg/phpdbg_lexer.l" { YYSETCONDITION(PRE_RAW); phpdbg_init_param(yylval, EMPTY_PARAM); return T_RUN; } -#line 253 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" +#line 253 "sapi/phpdbg/phpdbg_lexer.c" yy19: YYDEBUG(19, *YYCURSOR); yych = *++YYCURSOR; @@ -276,13 +276,13 @@ yy20: yy22: YYDEBUG(22, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 158 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 160 "sapi/phpdbg/phpdbg_lexer.l" { YYSETCONDITION(PRE_RAW); phpdbg_init_param(yylval, EMPTY_PARAM); return T_SHELL; } -#line 286 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" +#line 286 "sapi/phpdbg/phpdbg_lexer.c" yy23: YYDEBUG(23, *YYCURSOR); yych = *++YYCURSOR; @@ -309,13 +309,13 @@ yy24: yy26: YYDEBUG(26, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 153 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 155 "sapi/phpdbg/phpdbg_lexer.l" { YYSETCONDITION(PRE_RAW); phpdbg_init_param(yylval, EMPTY_PARAM); return T_EVAL; } -#line 319 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" +#line 319 "sapi/phpdbg/phpdbg_lexer.c" yy27: YYDEBUG(27, *YYCURSOR); yych = *++YYCURSOR; @@ -334,13 +334,13 @@ yy29: if (yych == '\n') goto yy4; YYDEBUG(30, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 147 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 149 "sapi/phpdbg/phpdbg_lexer.l" { /* ignore whitespace */ goto restart; } -#line 344 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" +#line 344 "sapi/phpdbg/phpdbg_lexer.c" } /* *********************************** */ yyc_NORMAL: @@ -390,40 +390,40 @@ yyc_NORMAL: if (yych <= '#') { if (yych <= '\t') { if (yych <= 0x00) goto yy39; - goto yy43; + goto yy46; } else { if (yych <= '\n') goto yy36; - if (yych <= '"') goto yy43; - goto yy58; + if (yych <= '"') goto yy46; + goto yy43; } } else { if (yych <= '-') { - if (yych <= ',') goto yy43; + if (yych <= ',') goto yy46; goto yy40; } else { - if (yych <= '.') goto yy45; - if (yych <= '/') goto yy43; - goto yy48; + if (yych <= '.') goto yy48; + if (yych <= '/') goto yy46; + goto yy51; } } } else { if (yych <= 'E') { if (yych <= ':') { - if (yych <= '9') goto yy45; - goto yy60; + if (yych <= '9') goto yy48; + goto yy45; } else { - if (yych <= 'C') goto yy43; - if (yych <= 'D') goto yy49; - goto yy50; + if (yych <= 'C') goto yy46; + if (yych <= 'D') goto yy52; + goto yy53; } } else { if (yych <= 'H') { - if (yych <= 'F') goto yy51; - goto yy43; + if (yych <= 'F') goto yy54; + goto yy46; } else { if (yych <= 'I') goto yy42; - if (yych <= 'M') goto yy43; - goto yy52; + if (yych <= 'M') goto yy46; + goto yy55; } } } @@ -431,41 +431,41 @@ yyc_NORMAL: if (yych <= 'f') { if (yych <= 'Y') { if (yych <= 'S') { - if (yych <= 'O') goto yy53; - goto yy43; + if (yych <= 'O') goto yy56; + goto yy46; } else { - if (yych <= 'T') goto yy54; - if (yych <= 'X') goto yy43; - goto yy55; + if (yych <= 'T') goto yy57; + if (yych <= 'X') goto yy46; + goto yy58; } } else { if (yych <= 'c') { - if (yych <= 'Z') goto yy56; - goto yy43; + if (yych <= 'Z') goto yy59; + goto yy46; } else { - if (yych <= 'd') goto yy49; - if (yych <= 'e') goto yy50; - goto yy51; + if (yych <= 'd') goto yy52; + if (yych <= 'e') goto yy53; + goto yy54; } } } else { if (yych <= 'o') { if (yych <= 'i') { - if (yych <= 'h') goto yy43; + if (yych <= 'h') goto yy46; goto yy42; } else { - if (yych <= 'm') goto yy43; - if (yych <= 'n') goto yy52; - goto yy53; + if (yych <= 'm') goto yy46; + if (yych <= 'n') goto yy55; + goto yy56; } } else { if (yych <= 'x') { - if (yych == 't') goto yy54; - goto yy43; + if (yych == 't') goto yy57; + goto yy46; } else { - if (yych <= 'y') goto yy55; - if (yych <= 'z') goto yy57; - goto yy43; + if (yych <= 'y') goto yy58; + if (yych <= 'z') goto yy60; + goto yy46; } } } @@ -483,13 +483,13 @@ yy33: if (yych == '\n') goto yy36; YYDEBUG(35, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 147 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 149 "sapi/phpdbg/phpdbg_lexer.l" { /* ignore whitespace */ goto restart; } -#line 493 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" +#line 493 "sapi/phpdbg/phpdbg_lexer.c" yy36: YYDEBUG(36, *YYCURSOR); ++YYCURSOR; @@ -504,11 +504,11 @@ yy36: yy38: YYDEBUG(38, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 69 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 70 "sapi/phpdbg/phpdbg_lexer.l" { return 0; } -#line 512 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" +#line 512 "sapi/phpdbg/phpdbg_lexer.c" yy39: YYDEBUG(39, *YYCURSOR); yych = *++YYCURSOR; @@ -518,685 +518,719 @@ yy40: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if (yybm[0+yych] & 16) { - goto yy45; + goto yy48; } - if (yych == 'r') goto yy114; - goto yy44; + if (yych == 'r') goto yy117; + goto yy47; yy41: YYDEBUG(41, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 133 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 135 "sapi/phpdbg/phpdbg_lexer.l" { phpdbg_init_param(yylval, STR_PARAM); yylval->str = zend_strndup(yytext, yyleng); yylval->len = yyleng; return T_ID; } -#line 536 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" +#line 536 "sapi/phpdbg/phpdbg_lexer.c" yy42: YYDEBUG(42, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'F') goto yy110; - if (yych == 'f') goto yy110; - goto yy44; + if (yych == 'F') goto yy113; + if (yych == 'f') goto yy113; + goto yy47; yy43: YYDEBUG(43, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(44, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 87 "sapi/phpdbg/phpdbg_lexer.l" + { + return T_POUND; +} +#line 553 "sapi/phpdbg/phpdbg_lexer.c" +yy45: + YYDEBUG(45, *YYCURSOR); + YYCTXMARKER = YYCURSOR + 1; + yych = *++YYCURSOR; + if (yych == ':') goto yy111; + if (yych == '\\') goto yy65; + goto yy109; +yy46: + YYDEBUG(46, *YYCURSOR); yyaccept = 0; YYMARKER = ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; -yy44: - YYDEBUG(44, *YYCURSOR); +yy47: + YYDEBUG(47, *YYCURSOR); if (yybm[0+yych] & 8) { - goto yy43; + goto yy46; } if (yych <= '9') goto yy41; - goto yy67; -yy45: - YYDEBUG(45, *YYCURSOR); + goto yy62; +yy48: + YYDEBUG(48, *YYCURSOR); yyaccept = 1; YYMARKER = ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; - YYDEBUG(46, *YYCURSOR); + YYDEBUG(49, *YYCURSOR); if (yybm[0+yych] & 16) { - goto yy45; + goto yy48; } if (yych <= 0x1F) { if (yych <= '\n') { - if (yych <= 0x00) goto yy47; - if (yych <= 0x08) goto yy43; + if (yych <= 0x00) goto yy50; + if (yych <= 0x08) goto yy46; } else { - if (yych != '\r') goto yy43; + if (yych != '\r') goto yy46; } } else { if (yych <= '#') { - if (yych <= ' ') goto yy47; - if (yych <= '"') goto yy43; + if (yych <= ' ') goto yy50; + if (yych <= '"') goto yy46; } else { - if (yych == ':') goto yy67; - goto yy43; + if (yych == ':') goto yy62; + goto yy46; } } -yy47: - YYDEBUG(47, *YYCURSOR); +yy50: + YYDEBUG(50, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 114 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 116 "sapi/phpdbg/phpdbg_lexer.l" { phpdbg_init_param(yylval, NUMERIC_PARAM); yylval->num = atoi(yytext); return T_DIGITS; } -#line 592 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" -yy48: - YYDEBUG(48, *YYCURSOR); +#line 609 "sapi/phpdbg/phpdbg_lexer.c" +yy51: + YYDEBUG(51, *YYCURSOR); yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); if (yybm[0+yych] & 16) { - goto yy45; + goto yy48; } if (yych <= 0x1F) { if (yych <= '\n') { - if (yych <= 0x00) goto yy47; - if (yych <= 0x08) goto yy44; - goto yy47; + if (yych <= 0x00) goto yy50; + if (yych <= 0x08) goto yy47; + goto yy50; } else { - if (yych == '\r') goto yy47; - goto yy44; + if (yych == '\r') goto yy50; + goto yy47; } } else { if (yych <= '#') { - if (yych <= ' ') goto yy47; - if (yych <= '"') goto yy44; - goto yy47; + if (yych <= ' ') goto yy50; + if (yych <= '"') goto yy47; + goto yy50; } else { - if (yych == 'x') goto yy106; - goto yy44; + if (yych == 'x') goto yy105; + goto yy47; } } -yy49: - YYDEBUG(49, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'I') goto yy100; - if (yych == 'i') goto yy100; - goto yy44; -yy50: - YYDEBUG(50, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'N') goto yy95; - if (yych == 'n') goto yy95; - goto yy44; -yy51: - YYDEBUG(51, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'A') goto yy92; - if (yych == 'a') goto yy92; - goto yy44; yy52: YYDEBUG(52, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'O') goto yy88; - if (yych == 'o') goto yy88; - goto yy44; + if (yych == 'I') goto yy99; + if (yych == 'i') goto yy99; + goto yy47; yy53: YYDEBUG(53, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 'N') { - if (yych == 'F') goto yy87; - if (yych <= 'M') goto yy44; - goto yy81; - } else { - if (yych <= 'f') { - if (yych <= 'e') goto yy44; - goto yy87; - } else { - if (yych == 'n') goto yy81; - goto yy44; - } - } + if (yych == 'N') goto yy94; + if (yych == 'n') goto yy94; + goto yy47; yy54: YYDEBUG(54, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'R') goto yy85; - if (yych == 'r') goto yy85; - goto yy44; + if (yych == 'A') goto yy91; + if (yych == 'a') goto yy91; + goto yy47; yy55: YYDEBUG(55, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy80; - if (yych == 'e') goto yy80; - goto yy44; + if (yych == 'O') goto yy87; + if (yych == 'o') goto yy87; + goto yy47; yy56: YYDEBUG(56, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy77; - goto yy44; + if (yych <= 'N') { + if (yych == 'F') goto yy86; + if (yych <= 'M') goto yy47; + goto yy80; + } else { + if (yych <= 'f') { + if (yych <= 'e') goto yy47; + goto yy86; + } else { + if (yych == 'n') goto yy80; + goto yy47; + } + } yy57: YYDEBUG(57, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'e') goto yy66; - goto yy44; + if (yych == 'R') goto yy84; + if (yych == 'r') goto yy84; + goto yy47; yy58: YYDEBUG(58, *YYCURSOR); - ++YYCURSOR; + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'E') goto yy79; + if (yych == 'e') goto yy79; + goto yy47; +yy59: YYDEBUG(59, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 92 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" - { - return T_POUND; -} -#line 699 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'E') goto yy76; + goto yy47; yy60: YYDEBUG(60, *YYCURSOR); - YYCTXMARKER = YYCURSOR + 1; - yych = *++YYCURSOR; - if (yych == ':') goto yy64; - if (yych != '\\') goto yy62; -yy61: + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy47; YYDEBUG(61, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'n') goto yy70; + goto yy47; +yy62: + YYDEBUG(62, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == '/') goto yy64; + if (yych == '\\') goto yy65; +yy63: + YYDEBUG(63, *YYCURSOR); YYCURSOR = YYMARKER; if (yyaccept <= 2) { if (yyaccept <= 1) { if (yyaccept <= 0) { goto yy41; } else { - goto yy47; + goto yy50; } } else { - goto yy76; + goto yy75; } } else { if (yyaccept <= 3) { - goto yy109; + goto yy108; } else { - goto yy120; + goto yy123; } } -yy62: - YYDEBUG(62, *YYCURSOR); - ++YYCURSOR; - YYDEBUG(63, *YYCURSOR); - YYCURSOR = YYCTXMARKER; - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 98 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" - { - return T_COLON; -} -#line 736 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" yy64: YYDEBUG(64, *YYCURSOR); - ++YYCURSOR; + yych = *++YYCURSOR; + if (yych == '/') goto yy68; + goto yy63; +yy65: YYDEBUG(65, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 95 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" - { - return T_DCOLON; -} -#line 746 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" -yy66: - YYDEBUG(66, *YYCURSOR); yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'n') goto yy71; - goto yy44; -yy67: + YYMARKER = ++YYCURSOR; + YYFILL(1); + yych = *YYCURSOR; + YYDEBUG(66, *YYCURSOR); + if (yych <= 0x1F) { + if (yych <= '\n') { + if (yych <= 0x00) goto yy41; + if (yych <= 0x08) goto yy65; + goto yy41; + } else { + if (yych == '\r') goto yy41; + goto yy65; + } + } else { + if (yych <= '#') { + if (yych <= ' ') goto yy41; + if (yych <= '"') goto yy65; + goto yy41; + } else { + if (yych != ':') goto yy65; + } + } YYDEBUG(67, *YYCURSOR); - yych = *++YYCURSOR; - if (yych != '/') goto yy61; + ++YYCURSOR; + YYFILL(1); + yych = *YYCURSOR; + if (yych == '\\') goto yy65; + goto yy63; +yy68: YYDEBUG(68, *YYCURSOR); - yych = *++YYCURSOR; - if (yych != '/') goto yy61; - YYDEBUG(69, *YYCURSOR); ++YYCURSOR; - YYDEBUG(70, *YYCURSOR); + YYDEBUG(69, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 86 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 97 "sapi/phpdbg/phpdbg_lexer.l" { phpdbg_init_param(yylval, STR_PARAM); yylval->str = zend_strndup(yytext, yyleng); yylval->len = yyleng; return T_PROTO; } -#line 771 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" -yy71: - YYDEBUG(71, *YYCURSOR); +#line 784 "sapi/phpdbg/phpdbg_lexer.c" +yy70: + YYDEBUG(70, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych != 'd') goto yy44; - YYDEBUG(72, *YYCURSOR); + if (yych != 'd') goto yy47; + YYDEBUG(71, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych != '_') goto yy44; -yy73: - YYDEBUG(73, *YYCURSOR); + if (yych != '_') goto yy47; +yy72: + YYDEBUG(72, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if (yybm[0+yych] & 32) { - goto yy74; + goto yy73; } - goto yy44; -yy74: - YYDEBUG(74, *YYCURSOR); + goto yy47; +yy73: + YYDEBUG(73, *YYCURSOR); yyaccept = 2; YYMARKER = ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; - YYDEBUG(75, *YYCURSOR); + YYDEBUG(74, *YYCURSOR); if (yybm[0+yych] & 32) { - goto yy74; + goto yy73; } if (yych <= 0x1F) { if (yych <= '\n') { - if (yych <= 0x00) goto yy76; - if (yych <= 0x08) goto yy43; + if (yych <= 0x00) goto yy75; + if (yych <= 0x08) goto yy46; } else { - if (yych != '\r') goto yy43; + if (yych != '\r') goto yy46; } } else { if (yych <= '#') { - if (yych <= ' ') goto yy76; - if (yych <= '"') goto yy43; + if (yych <= ' ') goto yy75; + if (yych <= '"') goto yy46; } else { - if (yych == ':') goto yy67; - goto yy43; + if (yych == ':') goto yy62; + goto yy46; } } -yy76: - YYDEBUG(76, *YYCURSOR); +yy75: + YYDEBUG(75, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 126 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 128 "sapi/phpdbg/phpdbg_lexer.l" { phpdbg_init_param(yylval, OP_PARAM); yylval->str = zend_strndup(yytext, yyleng); yylval->len = yyleng; return T_OPCODE; } -#line 825 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" -yy77: +#line 838 "sapi/phpdbg/phpdbg_lexer.c" +yy76: + YYDEBUG(76, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'N') goto yy47; YYDEBUG(77, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych != 'N') goto yy44; + if (yych != 'D') goto yy47; YYDEBUG(78, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych != 'D') goto yy44; + if (yych == '_') goto yy72; + goto yy47; +yy79: YYDEBUG(79, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == '_') goto yy73; - goto yy44; + if (yych == 'S') goto yy80; + if (yych != 's') goto yy47; yy80: YYDEBUG(80, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'S') goto yy81; - if (yych != 's') goto yy44; -yy81: - YYDEBUG(81, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); if (yybm[0+yych] & 64) { - goto yy82; + goto yy81; } - goto yy44; -yy82: - YYDEBUG(82, *YYCURSOR); + goto yy47; +yy81: + YYDEBUG(81, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(83, *YYCURSOR); + YYDEBUG(82, *YYCURSOR); if (yybm[0+yych] & 64) { - goto yy82; + goto yy81; } - YYDEBUG(84, *YYCURSOR); + YYDEBUG(83, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 102 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 104 "sapi/phpdbg/phpdbg_lexer.l" { phpdbg_init_param(yylval, NUMERIC_PARAM); yylval->num = 1; return T_TRUTHY; } -#line 871 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" +#line 884 "sapi/phpdbg/phpdbg_lexer.c" +yy84: + YYDEBUG(84, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'U') goto yy85; + if (yych != 'u') goto yy47; yy85: YYDEBUG(85, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'U') goto yy86; - if (yych != 'u') goto yy44; + if (yych == 'E') goto yy80; + if (yych == 'e') goto yy80; + goto yy47; yy86: YYDEBUG(86, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy81; - if (yych == 'e') goto yy81; - goto yy44; + if (yych == 'F') goto yy87; + if (yych != 'f') goto yy47; yy87: YYDEBUG(87, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'F') goto yy88; - if (yych != 'f') goto yy44; -yy88: - YYDEBUG(88, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); if (yych <= '\f') { - if (yych <= 0x08) goto yy44; - if (yych >= '\v') goto yy44; + if (yych <= 0x08) goto yy47; + if (yych >= '\v') goto yy47; } else { - if (yych <= '\r') goto yy89; - if (yych != ' ') goto yy44; + if (yych <= '\r') goto yy88; + if (yych != ' ') goto yy47; } -yy89: - YYDEBUG(89, *YYCURSOR); +yy88: + YYDEBUG(88, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(90, *YYCURSOR); + YYDEBUG(89, *YYCURSOR); if (yych <= '\f') { - if (yych <= 0x08) goto yy91; - if (yych <= '\n') goto yy89; + if (yych <= 0x08) goto yy90; + if (yych <= '\n') goto yy88; } else { - if (yych <= '\r') goto yy89; - if (yych == ' ') goto yy89; + if (yych <= '\r') goto yy88; + if (yych == ' ') goto yy88; } -yy91: - YYDEBUG(91, *YYCURSOR); +yy90: + YYDEBUG(90, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 108 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 110 "sapi/phpdbg/phpdbg_lexer.l" { phpdbg_init_param(yylval, NUMERIC_PARAM); yylval->num = 0; return T_FALSY; } -#line 924 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" +#line 937 "sapi/phpdbg/phpdbg_lexer.c" +yy91: + YYDEBUG(91, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'L') goto yy92; + if (yych != 'l') goto yy47; yy92: YYDEBUG(92, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'L') goto yy93; - if (yych != 'l') goto yy44; + if (yych == 'S') goto yy93; + if (yych != 's') goto yy47; yy93: YYDEBUG(93, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'S') goto yy94; - if (yych != 's') goto yy44; + if (yych == 'E') goto yy87; + if (yych == 'e') goto yy87; + goto yy47; yy94: YYDEBUG(94, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy88; - if (yych == 'e') goto yy88; - goto yy44; + if (yych == 'A') goto yy95; + if (yych != 'a') goto yy47; yy95: YYDEBUG(95, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'A') goto yy96; - if (yych != 'a') goto yy44; + if (yych == 'B') goto yy96; + if (yych != 'b') goto yy47; yy96: YYDEBUG(96, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'B') goto yy97; - if (yych != 'b') goto yy44; + if (yych == 'L') goto yy97; + if (yych != 'l') goto yy47; yy97: YYDEBUG(97, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'L') goto yy98; - if (yych != 'l') goto yy44; + if (yych == 'E') goto yy98; + if (yych != 'e') goto yy47; yy98: YYDEBUG(98, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy99; - if (yych != 'e') goto yy44; + if (yych == 'D') goto yy80; + if (yych == 'd') goto yy80; + goto yy47; yy99: YYDEBUG(99, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'D') goto yy81; - if (yych == 'd') goto yy81; - goto yy44; + if (yych == 'S') goto yy100; + if (yych != 's') goto yy47; yy100: YYDEBUG(100, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'S') goto yy101; - if (yych != 's') goto yy44; + if (yych == 'A') goto yy101; + if (yych != 'a') goto yy47; yy101: YYDEBUG(101, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'A') goto yy102; - if (yych != 'a') goto yy44; + if (yych == 'B') goto yy102; + if (yych != 'b') goto yy47; yy102: YYDEBUG(102, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'B') goto yy103; - if (yych != 'b') goto yy44; + if (yych == 'L') goto yy103; + if (yych != 'l') goto yy47; yy103: YYDEBUG(103, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'L') goto yy104; - if (yych != 'l') goto yy44; + if (yych == 'E') goto yy104; + if (yych != 'e') goto yy47; yy104: YYDEBUG(104, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy105; - if (yych != 'e') goto yy44; + if (yych == 'D') goto yy87; + if (yych == 'd') goto yy87; + goto yy47; yy105: YYDEBUG(105, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'D') goto yy88; - if (yych == 'd') goto yy88; - goto yy44; -yy106: - YYDEBUG(106, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); if (yybm[0+yych] & 128) { - goto yy107; + goto yy106; } - goto yy44; -yy107: - YYDEBUG(107, *YYCURSOR); + goto yy47; +yy106: + YYDEBUG(106, *YYCURSOR); yyaccept = 3; YYMARKER = ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; - YYDEBUG(108, *YYCURSOR); + YYDEBUG(107, *YYCURSOR); if (yybm[0+yych] & 128) { - goto yy107; + goto yy106; } if (yych <= 0x1F) { if (yych <= '\n') { - if (yych <= 0x00) goto yy109; - if (yych <= 0x08) goto yy43; + if (yych <= 0x00) goto yy108; + if (yych <= 0x08) goto yy46; } else { - if (yych != '\r') goto yy43; + if (yych != '\r') goto yy46; } } else { if (yych <= '#') { - if (yych <= ' ') goto yy109; - if (yych <= '"') goto yy43; + if (yych <= ' ') goto yy108; + if (yych <= '"') goto yy46; } else { - if (yych == ':') goto yy67; - goto yy43; + if (yych == ':') goto yy62; + goto yy46; } } -yy109: - YYDEBUG(109, *YYCURSOR); +yy108: + YYDEBUG(108, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 120 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 122 "sapi/phpdbg/phpdbg_lexer.l" { phpdbg_init_param(yylval, ADDR_PARAM); yylval->addr = strtoul(yytext, 0, 16); return T_ADDR; } -#line 1055 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" -yy110: +#line 1068 "sapi/phpdbg/phpdbg_lexer.c" +yy109: + YYDEBUG(109, *YYCURSOR); + ++YYCURSOR; YYDEBUG(110, *YYCURSOR); + YYCURSOR = YYCTXMARKER; + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 93 "sapi/phpdbg/phpdbg_lexer.l" + { + return T_COLON; +} +#line 1079 "sapi/phpdbg/phpdbg_lexer.c" +yy111: + YYDEBUG(111, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(112, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 90 "sapi/phpdbg/phpdbg_lexer.l" + { + return T_DCOLON; +} +#line 1089 "sapi/phpdbg/phpdbg_lexer.c" +yy113: + YYDEBUG(113, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if (yych <= '\f') { - if (yych <= 0x08) goto yy44; - if (yych >= '\v') goto yy44; + if (yych <= 0x08) goto yy47; + if (yych >= '\v') goto yy47; } else { - if (yych <= '\r') goto yy111; - if (yych != ' ') goto yy44; + if (yych <= '\r') goto yy114; + if (yych != ' ') goto yy47; } -yy111: - YYDEBUG(111, *YYCURSOR); +yy114: + YYDEBUG(114, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(112, *YYCURSOR); + YYDEBUG(115, *YYCURSOR); if (yych <= '\f') { - if (yych <= 0x08) goto yy113; - if (yych <= '\n') goto yy111; + if (yych <= 0x08) goto yy116; + if (yych <= '\n') goto yy114; } else { - if (yych <= '\r') goto yy111; - if (yych == ' ') goto yy111; + if (yych <= '\r') goto yy114; + if (yych == ' ') goto yy114; } -yy113: - YYDEBUG(113, *YYCURSOR); +yy116: + YYDEBUG(116, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 80 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 81 "sapi/phpdbg/phpdbg_lexer.l" { YYSETCONDITION(RAW); phpdbg_init_param(yylval, EMPTY_PARAM); return T_IF; } -#line 1089 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" -yy114: - YYDEBUG(114, *YYCURSOR); +#line 1123 "sapi/phpdbg/phpdbg_lexer.c" +yy117: + YYDEBUG(117, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if (yych <= ' ') { if (yych <= '\f') { - if (yych <= 0x08) goto yy44; - if (yych >= '\v') goto yy44; + if (yych <= 0x08) goto yy47; + if (yych >= '\v') goto yy47; } else { - if (yych <= '\r') goto yy115; - if (yych <= 0x1F) goto yy44; + if (yych <= '\r') goto yy118; + if (yych <= 0x1F) goto yy47; } } else { if (yych <= '.') { - if (yych <= ',') goto yy44; - if (yych <= '-') goto yy117; - goto yy118; + if (yych <= ',') goto yy47; + if (yych <= '-') goto yy120; + goto yy121; } else { - if (yych <= '/') goto yy44; - if (yych <= '9') goto yy118; - goto yy44; + if (yych <= '/') goto yy47; + if (yych <= '9') goto yy121; + goto yy47; } } -yy115: - YYDEBUG(115, *YYCURSOR); +yy118: + YYDEBUG(118, *YYCURSOR); ++YYCURSOR; YYFILL(2); yych = *YYCURSOR; - YYDEBUG(116, *YYCURSOR); + YYDEBUG(119, *YYCURSOR); if (yych <= ' ') { if (yych <= '\f') { - if (yych <= 0x08) goto yy61; - if (yych <= '\n') goto yy115; - goto yy61; + if (yych <= 0x08) goto yy63; + if (yych <= '\n') goto yy118; + goto yy63; } else { - if (yych <= '\r') goto yy115; - if (yych <= 0x1F) goto yy61; - goto yy115; + if (yych <= '\r') goto yy118; + if (yych <= 0x1F) goto yy63; + goto yy118; } } else { if (yych <= '.') { - if (yych <= ',') goto yy61; - if (yych <= '-') goto yy121; - goto yy122; + if (yych <= ',') goto yy63; + if (yych <= '-') goto yy124; + goto yy125; } else { - if (yych <= '/') goto yy61; - if (yych <= '9') goto yy122; - goto yy61; + if (yych <= '/') goto yy63; + if (yych <= '9') goto yy125; + goto yy63; } } -yy117: - YYDEBUG(117, *YYCURSOR); +yy120: + YYDEBUG(120, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == '.') goto yy118; - if (yych <= '/') goto yy44; - if (yych >= ':') goto yy44; -yy118: - YYDEBUG(118, *YYCURSOR); + if (yych == '.') goto yy121; + if (yych <= '/') goto yy47; + if (yych >= ':') goto yy47; +yy121: + YYDEBUG(121, *YYCURSOR); yyaccept = 4; YYMARKER = ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; - YYDEBUG(119, *YYCURSOR); + YYDEBUG(122, *YYCURSOR); if (yych <= ' ') { if (yych <= '\n') { - if (yych <= 0x00) goto yy120; - if (yych <= 0x08) goto yy43; + if (yych <= 0x00) goto yy123; + if (yych <= 0x08) goto yy46; } else { - if (yych == '\r') goto yy120; - if (yych <= 0x1F) goto yy43; + if (yych == '\r') goto yy123; + if (yych <= 0x1F) goto yy46; } } else { if (yych <= '.') { - if (yych == '#') goto yy120; - if (yych <= '-') goto yy43; - goto yy118; + if (yych == '#') goto yy123; + if (yych <= '-') goto yy46; + goto yy121; } else { - if (yych <= '/') goto yy43; - if (yych <= '9') goto yy118; - if (yych <= ':') goto yy67; - goto yy43; + if (yych <= '/') goto yy46; + if (yych <= '9') goto yy121; + if (yych <= ':') goto yy62; + goto yy46; } } -yy120: - YYDEBUG(120, *YYCURSOR); +yy123: + YYDEBUG(123, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 73 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 74 "sapi/phpdbg/phpdbg_lexer.l" { char *text = yytext + 2; while (*++text < '0'); yylval->num = atoi(text); return T_REQ_ID; } -#line 1184 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" -yy121: - YYDEBUG(121, *YYCURSOR); +#line 1218 "sapi/phpdbg/phpdbg_lexer.c" +yy124: + YYDEBUG(124, *YYCURSOR); yych = *++YYCURSOR; - if (yych == '.') goto yy122; - if (yych <= '/') goto yy61; - if (yych >= ':') goto yy61; -yy122: - YYDEBUG(122, *YYCURSOR); + if (yych == '.') goto yy125; + if (yych <= '/') goto yy63; + if (yych >= ':') goto yy63; +yy125: + YYDEBUG(125, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(123, *YYCURSOR); - if (yych == '.') goto yy122; - if (yych <= '/') goto yy120; - if (yych <= '9') goto yy122; - goto yy120; + YYDEBUG(126, *YYCURSOR); + if (yych == '.') goto yy125; + if (yych <= '/') goto yy123; + if (yych <= '9') goto yy125; + goto yy123; } /* *********************************** */ yyc_PRE_RAW: @@ -1235,155 +1269,155 @@ yyc_PRE_RAW: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; - YYDEBUG(124, *YYCURSOR); + YYDEBUG(127, *YYCURSOR); YYFILL(2); yych = *YYCURSOR; if (yybm[0+yych] & 16) { - goto yy128; + goto yy131; } if (yych <= '\r') { if (yych <= 0x08) { - if (yych <= 0x00) goto yy131; - goto yy133; + if (yych <= 0x00) goto yy134; + goto yy136; } else { - if (yych <= '\t') goto yy126; - if (yych <= '\f') goto yy133; + if (yych <= '\t') goto yy129; + if (yych <= '\f') goto yy136; } } else { if (yych <= ' ') { - if (yych <= 0x1F) goto yy133; + if (yych <= 0x1F) goto yy136; } else { - if (yych == '-') goto yy132; - goto yy133; + if (yych == '-') goto yy135; + goto yy136; } } -yy126: - YYDEBUG(126, *YYCURSOR); +yy129: + YYDEBUG(129, *YYCURSOR); ++YYCURSOR; if ((yych = *YYCURSOR) <= '\f') { - if (yych <= 0x00) goto yy143; - if (yych <= 0x08) goto yy127; - if (yych <= '\n') goto yy143; + if (yych <= 0x00) goto yy146; + if (yych <= 0x08) goto yy130; + if (yych <= '\n') goto yy146; } else { - if (yych <= '\r') goto yy143; - if (yych == ' ') goto yy143; + if (yych <= '\r') goto yy146; + if (yych == ' ') goto yy146; } -yy127: - YYDEBUG(127, *YYCURSOR); +yy130: + YYDEBUG(130, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 169 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 171 "sapi/phpdbg/phpdbg_lexer.l" { YYSETCONDITION(RAW); YYCURSOR = LEX(text); goto restart; } -#line 1282 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" -yy128: - YYDEBUG(128, *YYCURSOR); +#line 1316 "sapi/phpdbg/phpdbg_lexer.c" +yy131: + YYDEBUG(131, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(129, *YYCURSOR); + YYDEBUG(132, *YYCURSOR); if (yybm[0+yych] & 128) { - goto yy142; + goto yy145; } - if (yych <= 0x00) goto yy141; - if (yych == '\n') goto yy128; -yy130: - YYDEBUG(130, *YYCURSOR); + if (yych <= 0x00) goto yy144; + if (yych == '\n') goto yy131; +yy133: + YYDEBUG(133, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 69 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 70 "sapi/phpdbg/phpdbg_lexer.l" { return 0; } -#line 1301 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" -yy131: - YYDEBUG(131, *YYCURSOR); +#line 1335 "sapi/phpdbg/phpdbg_lexer.c" +yy134: + YYDEBUG(134, *YYCURSOR); yych = *++YYCURSOR; - goto yy127; -yy132: - YYDEBUG(132, *YYCURSOR); + goto yy130; +yy135: + YYDEBUG(135, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'r') goto yy134; - goto yy127; -yy133: - YYDEBUG(133, *YYCURSOR); + if (yych == 'r') goto yy137; + goto yy130; +yy136: + YYDEBUG(136, *YYCURSOR); yych = *++YYCURSOR; - goto yy127; -yy134: - YYDEBUG(134, *YYCURSOR); + goto yy130; +yy137: + YYDEBUG(137, *YYCURSOR); ++YYCURSOR; YYFILL(2); yych = *YYCURSOR; - YYDEBUG(135, *YYCURSOR); + YYDEBUG(138, *YYCURSOR); if (yybm[0+yych] & 32) { - goto yy134; + goto yy137; } if (yych <= '.') { - if (yych <= ',') goto yy136; - if (yych <= '-') goto yy137; - goto yy138; + if (yych <= ',') goto yy139; + if (yych <= '-') goto yy140; + goto yy141; } else { - if (yych <= '/') goto yy136; - if (yych <= '9') goto yy138; + if (yych <= '/') goto yy139; + if (yych <= '9') goto yy141; } -yy136: - YYDEBUG(136, *YYCURSOR); +yy139: + YYDEBUG(139, *YYCURSOR); YYCURSOR = YYMARKER; - goto yy127; -yy137: - YYDEBUG(137, *YYCURSOR); + goto yy130; +yy140: + YYDEBUG(140, *YYCURSOR); yych = *++YYCURSOR; if (yybm[0+yych] & 64) { - goto yy138; + goto yy141; } - goto yy136; -yy138: - YYDEBUG(138, *YYCURSOR); + goto yy139; +yy141: + YYDEBUG(141, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(139, *YYCURSOR); + YYDEBUG(142, *YYCURSOR); if (yybm[0+yych] & 64) { - goto yy138; + goto yy141; } - YYDEBUG(140, *YYCURSOR); + YYDEBUG(143, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 73 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 74 "sapi/phpdbg/phpdbg_lexer.l" { char *text = yytext + 2; while (*++text < '0'); yylval->num = atoi(text); return T_REQ_ID; } -#line 1362 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" -yy141: - YYDEBUG(141, *YYCURSOR); +#line 1396 "sapi/phpdbg/phpdbg_lexer.c" +yy144: + YYDEBUG(144, *YYCURSOR); yych = *++YYCURSOR; - goto yy130; -yy142: - YYDEBUG(142, *YYCURSOR); + goto yy133; +yy145: + YYDEBUG(145, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; -yy143: - YYDEBUG(143, *YYCURSOR); +yy146: + YYDEBUG(146, *YYCURSOR); if (yybm[0+yych] & 128) { - goto yy142; + goto yy145; } - if (yych <= 0x00) goto yy141; - if (yych == '\n') goto yy128; - YYDEBUG(144, *YYCURSOR); + if (yych <= 0x00) goto yy144; + if (yych == '\n') goto yy131; + YYDEBUG(147, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 147 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 149 "sapi/phpdbg/phpdbg_lexer.l" { /* ignore whitespace */ goto restart; } -#line 1387 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" +#line 1421 "sapi/phpdbg/phpdbg_lexer.c" } /* *********************************** */ yyc_RAW: @@ -1422,103 +1456,103 @@ yyc_RAW: 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; - YYDEBUG(145, *YYCURSOR); + YYDEBUG(148, *YYCURSOR); YYFILL(1); yych = *YYCURSOR; if (yybm[0+yych] & 32) { - goto yy147; + goto yy150; } - if (yych <= 0x00) goto yy153; - if (yych == '\n') goto yy150; - goto yy154; -yy147: - YYDEBUG(147, *YYCURSOR); + if (yych <= 0x00) goto yy156; + if (yych == '\n') goto yy153; + goto yy157; +yy150: + YYDEBUG(150, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(148, *YYCURSOR); + YYDEBUG(151, *YYCURSOR); if (yybm[0+yych] & 32) { - goto yy147; + goto yy150; } - if (yych <= 0x00) goto yy153; - if (yych == '\n') goto yy150; - goto yy154; -yy149: - YYDEBUG(149, *YYCURSOR); + if (yych <= 0x00) goto yy156; + if (yych == '\n') goto yy153; + goto yy157; +yy152: + YYDEBUG(152, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 140 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 142 "sapi/phpdbg/phpdbg_lexer.l" { phpdbg_init_param(yylval, STR_PARAM); yylval->str = zend_strndup(yytext, yyleng); yylval->len = yyleng; return T_INPUT; } -#line 1457 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" -yy150: - YYDEBUG(150, *YYCURSOR); +#line 1491 "sapi/phpdbg/phpdbg_lexer.c" +yy153: + YYDEBUG(153, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(151, *YYCURSOR); + YYDEBUG(154, *YYCURSOR); if (yybm[0+yych] & 64) { - goto yy150; + goto yy153; } if (yych <= '\f') { - if (yych <= 0x00) goto yy153; - if (yych == '\t') goto yy156; + if (yych <= 0x00) goto yy156; + if (yych == '\t') goto yy159; } else { - if (yych <= '\r') goto yy156; - if (yych == ' ') goto yy156; + if (yych <= '\r') goto yy159; + if (yych == ' ') goto yy159; } -yy152: - YYDEBUG(152, *YYCURSOR); +yy155: + YYDEBUG(155, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 69 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 70 "sapi/phpdbg/phpdbg_lexer.l" { return 0; } -#line 1481 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" -yy153: - YYDEBUG(153, *YYCURSOR); +#line 1515 "sapi/phpdbg/phpdbg_lexer.c" +yy156: + YYDEBUG(156, *YYCURSOR); yych = *++YYCURSOR; - goto yy152; -yy154: - YYDEBUG(154, *YYCURSOR); + goto yy155; +yy157: + YYDEBUG(157, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(155, *YYCURSOR); + YYDEBUG(158, *YYCURSOR); if (yybm[0+yych] & 128) { - goto yy154; + goto yy157; } - goto yy149; -yy156: - YYDEBUG(156, *YYCURSOR); + goto yy152; +yy159: + YYDEBUG(159, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(157, *YYCURSOR); + YYDEBUG(160, *YYCURSOR); if (yybm[0+yych] & 64) { - goto yy150; + goto yy153; } if (yych <= '\f') { - if (yych <= 0x00) goto yy153; - if (yych == '\t') goto yy156; + if (yych <= 0x00) goto yy156; + if (yych == '\t') goto yy159; } else { - if (yych <= '\r') goto yy156; - if (yych == ' ') goto yy156; + if (yych <= '\r') goto yy159; + if (yych == ' ') goto yy159; } - YYDEBUG(158, *YYCURSOR); + YYDEBUG(161, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 147 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 149 "sapi/phpdbg/phpdbg_lexer.l" { /* ignore whitespace */ goto restart; } -#line 1520 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.c" +#line 1554 "sapi/phpdbg/phpdbg_lexer.c" } } -#line 183 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_lexer.l" +#line 185 "sapi/phpdbg/phpdbg_lexer.l" } diff --git a/sapi/phpdbg/phpdbg_lexer.l b/sapi/phpdbg/phpdbg_lexer.l index 7fca70f57a..35ca744400 100644 --- a/sapi/phpdbg/phpdbg_lexer.l +++ b/sapi/phpdbg/phpdbg_lexer.l @@ -60,6 +60,7 @@ T_RUN_SHORT "r" WS [ \r\n\t]+ DIGITS [-]?[0-9\.]+ ID [^ \r\n\t:#\000]+ +GENERIC_ID ([^ \r\n\t:#\000]|":\\")+ ADDR [0][x][a-fA-F0-9]+ OPCODE (ZEND_|zend_)([A-Za-z])+ INPUT [^\n\000]+ @@ -70,7 +71,7 @@ INPUT [^\n\000]+ return 0; } -<PRE_RAW, NORMAL>[-][r]{WS}?{DIGITS} { +<PRE_RAW, NORMAL>"-r"{WS}?{DIGITS} { char *text = yytext + 2; while (*++text < '0'); yylval->num = atoi(text); @@ -83,22 +84,23 @@ INPUT [^\n\000]+ return T_IF; } -<NORMAL>{ID}[:]{1}[//]{2} { - phpdbg_init_param(yylval, STR_PARAM); - yylval->str = zend_strndup(yytext, yyleng); - yylval->len = yyleng; - return T_PROTO; -} -<NORMAL>[#]{1} { +<NORMAL>"#" { return T_POUND; } -<NORMAL>[:]{2} { +<NORMAL>"::" { return T_DCOLON; } -<NORMAL>[:]{1}/[^\\] { +<NORMAL>":"/[^\\] { return T_COLON; } +<NORMAL>{ID}"://" { + phpdbg_init_param(yylval, STR_PARAM); + yylval->str = zend_strndup(yytext, yyleng); + yylval->len = yyleng; + return T_PROTO; +} + <NORMAL>({T_YES}|{T_ON}|{T_ENABLED}|{T_TRUE}){WS} { phpdbg_init_param(yylval, NUMERIC_PARAM); yylval->num = 1; @@ -130,7 +132,7 @@ INPUT [^\n\000]+ return T_OPCODE; } -<NORMAL>{ID} { +<NORMAL>{GENERIC_ID} { phpdbg_init_param(yylval, STR_PARAM); yylval->str = zend_strndup(yytext, yyleng); yylval->len = yyleng; diff --git a/sapi/phpdbg/phpdbg_list.c b/sapi/phpdbg/phpdbg_list.c index 6d5e894930..3d64c8b077 100644 --- a/sapi/phpdbg/phpdbg_list.c +++ b/sapi/phpdbg/phpdbg_list.c @@ -240,24 +240,19 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type) { char *bufptr, *endptr; char resolved_path_buf[MAXPATHLEN]; - if (zend_stream_fixup(file, &data.buf, &data.len) == FAILURE) { + if (zend_stream_fixup(file, &bufptr, &data.len) == FAILURE) { return NULL; } + data.buf = NULL; + if (data.len > 0) { + data.buf = emalloc(data.len + 1); + memcpy(data.buf, bufptr, data.len); + data.buf[data.len] = 0; + } data.filename = filename; data.line[0] = 0; - if (file->handle.stream.mmap.old_closer) { - /* do not unmap */ - file->handle.stream.closer = file->handle.stream.mmap.old_closer; - } - -#if HAVE_MMAP - if (file->handle.stream.mmap.map) { - data.map = file->handle.stream.mmap.map; - } -#endif - fake.type = ZEND_HANDLE_MAPPED; fake.handle.stream.mmap.buf = data.buf; fake.handle.stream.mmap.len = data.len; @@ -278,22 +273,54 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type) { } dataptr->lines = ++line; dataptr->line[line] = endptr - data.buf; - dataptr = erealloc(dataptr, sizeof(phpdbg_file_source) + sizeof(uint) * line); + ret = PHPDBG_G(compile_file)(&fake, type); + + if (ret == NULL) { + efree(data.buf); + efree(dataptr); + return NULL; + } + + dataptr = erealloc(dataptr, sizeof(phpdbg_file_source) + sizeof(uint) * line); zend_hash_str_add_ptr(&PHPDBG_G(file_sources), filename, strlen(filename), dataptr); phpdbg_resolve_pending_file_break(filename); - ret = PHPDBG_G(compile_file)(&fake, type); - fake.opened_path = NULL; zend_file_handle_dtor(&fake); + return ret; +} + +zend_op_array *phpdbg_init_compile_file(zend_file_handle *file, int type) { + char *filename = (char *)(file->opened_path ? ZSTR_VAL(file->opened_path) : file->filename); + char resolved_path_buf[MAXPATHLEN]; + zend_op_array *ret; + phpdbg_file_source *dataptr; + + if (VCWD_REALPATH(filename, resolved_path_buf)) { + filename = resolved_path_buf; + } + + ret = PHPDBG_G(init_compile_file)(file, type); + + if (ret == NULL) { + return NULL; + } + + dataptr = zend_hash_str_find_ptr(&PHPDBG_G(file_sources), filename, strlen(filename)); + ZEND_ASSERT(dataptr != NULL); + dataptr->op_array = ret; - if (dataptr->op_array->refcount) { - ++*dataptr->op_array->refcount; - } else { - dataptr->op_array->refcount = emalloc(sizeof(uint32_t)); - *dataptr->op_array->refcount = 2; + dataptr->destroy_op_array = 1; + if (dataptr->op_array) { + if (dataptr->op_array->refcount) { + ++*dataptr->op_array->refcount; + } else { + dataptr->op_array->refcount = emalloc(sizeof(uint32_t)); + *dataptr->op_array->refcount = 2; + dataptr->destroy_op_array = 0; + } } return ret; @@ -302,16 +329,14 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type) { void phpdbg_free_file_source(zval *zv) { phpdbg_file_source *data = Z_PTR_P(zv); -#if HAVE_MMAP - if (data->map) { - munmap(data->map, data->len + ZEND_MMAP_AHEAD); - } else -#endif if (data->buf) { efree(data->buf); } - if (destroy_op_array(data->op_array)) { + if (!data->destroy_op_array) { + efree(data->op_array->refcount); + } + if (!data->destroy_op_array || destroy_op_array(data->op_array)) { efree(data->op_array); } @@ -323,3 +348,8 @@ void phpdbg_init_list(void) { zend_hash_init(&PHPDBG_G(file_sources), 1, NULL, (dtor_func_t) phpdbg_free_file_source, 0); zend_compile_file = phpdbg_compile_file; } + +void phpdbg_list_update(void) { + PHPDBG_G(init_compile_file) = zend_compile_file; + zend_compile_file = phpdbg_init_compile_file; +} diff --git a/sapi/phpdbg/phpdbg_list.h b/sapi/phpdbg/phpdbg_list.h index bfaef06248..8530ea264d 100644 --- a/sapi/phpdbg/phpdbg_list.h +++ b/sapi/phpdbg/phpdbg_list.h @@ -39,6 +39,7 @@ void phpdbg_list_file(zend_string *, uint, int, uint); extern const phpdbg_command_t phpdbg_list_commands[]; void phpdbg_init_list(void); +void phpdbg_list_update(void); typedef struct { char *filename; @@ -48,6 +49,7 @@ typedef struct { void *map; #endif zend_op_array *op_array; + zend_bool destroy_op_array; uint lines; uint line[1]; } phpdbg_file_source; diff --git a/sapi/phpdbg/phpdbg_opcode.c b/sapi/phpdbg/phpdbg_opcode.c index 4361872a79..092fcb985c 100644 --- a/sapi/phpdbg/phpdbg_opcode.c +++ b/sapi/phpdbg/phpdbg_opcode.c @@ -143,7 +143,7 @@ char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op) /*{{{ */ /* RESULT */ switch (op->opcode) { case ZEND_CATCH: - spprintf(&decode[2], 0, "%" PRIu32, op->result.num); + spprintf(&decode[3], 0, "%" PRIu32, op->result.num); break; default: decode[3] = phpdbg_decode_op(ops, &op->result, op->result_type); diff --git a/sapi/phpdbg/phpdbg_out.c b/sapi/phpdbg/phpdbg_out.c index cd9a4acaa0..c771b439d1 100644 --- a/sapi/phpdbg/phpdbg_out.c +++ b/sapi/phpdbg/phpdbg_out.c @@ -1281,6 +1281,7 @@ PHPDBG_API int phpdbg_out_internal(int fd, const char *fmt, ...) { len = phpdbg_mixed_write(fd, buffer, buflen); } + efree(buffer); return len; } diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index 5ad3fea79d..9d40d000c2 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -418,12 +418,13 @@ PHPDBG_COMMAND(exec) /* {{{ */ VCWD_CHDIR_FILE(res); *SG(request_info).argv = PHPDBG_G(exec); - php_hash_environment(); + php_build_argv(NULL, &PG(http_globals)[TRACK_VARS_SERVER]); phpdbg_notice("exec", "type=\"set\" context=\"%s\"", "Set execution context: %s", PHPDBG_G(exec)); if (PHPDBG_G(in_execution)) { phpdbg_clean(1); + return SUCCESS; } phpdbg_compile(); @@ -678,7 +679,7 @@ PHPDBG_COMMAND(run) /* {{{ */ SG(request_info).argv = erealloc(argv, ++argc * sizeof(char *)); SG(request_info).argc = argc; - php_hash_environment(); + php_build_argv(NULL, &PG(http_globals)[TRACK_VARS_SERVER]); } zend_try { @@ -689,13 +690,10 @@ PHPDBG_COMMAND(run) /* {{{ */ } zend_catch { PHPDBG_G(in_execution) = 0; - if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) { - zend_bailout(); - } - if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { - phpdbg_error("stop", "type=\"bailout\"", "Caught exit/error from VM"); restore = 0; + } else { + zend_bailout(); } } zend_end_try(); @@ -708,11 +706,13 @@ PHPDBG_COMMAND(run) /* {{{ */ if (EG(exception)) { phpdbg_handle_exception(); } - } - phpdbg_clean(1); + PHPDBG_G(in_execution) = 1; + } PHPDBG_G(flags) &= ~PHPDBG_IS_RUNNING; + + phpdbg_clean(1); } else { phpdbg_error("inactive", "type=\"nocontext\"", "Nothing to execute!"); } @@ -744,6 +744,7 @@ PHPDBG_COMMAND(ev) /* {{{ */ zend_execute_data *original_execute_data = EG(current_execute_data); zend_class_entry *original_scope = EG(scope); zend_vm_stack original_stack = EG(vm_stack); + zend_object *ex = NULL; PHPDBG_OUTPUT_BACKUP(); @@ -769,6 +770,7 @@ PHPDBG_COMMAND(ev) /* {{{ */ zend_try { if (zend_eval_stringl(param->str, param->len, &retval, "eval()'d code") == SUCCESS) { if (EG(exception)) { + ex = EG(exception); zend_exception_error(EG(exception), E_ERROR); } else { phpdbg_xml("<eval %r>"); @@ -783,11 +785,16 @@ PHPDBG_COMMAND(ev) /* {{{ */ } } } zend_catch { + PHPDBG_G(unclean_eval) = 1; + if (ex) { + OBJ_RELEASE(ex); + } EG(current_execute_data) = original_execute_data; EG(scope) = original_scope; EG(vm_stack_top) = original_stack->top; EG(vm_stack_end) = original_stack->end; EG(vm_stack) = original_stack; + EG(exit_status) = 0; } zend_end_try(); PHPDBG_G(flags) &= ~PHPDBG_IN_EVAL; @@ -1185,14 +1192,10 @@ PHPDBG_COMMAND(register) /* {{{ */ PHPDBG_COMMAND(quit) /* {{{ */ { - /* don't allow this to loop, ever ... */ - if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { - PHPDBG_G(flags) |= PHPDBG_IS_QUITTING; - PHPDBG_G(flags) &= ~(PHPDBG_IS_RUNNING | PHPDBG_IS_CLEANING); - zend_bailout(); - } + PHPDBG_G(flags) |= PHPDBG_IS_QUITTING; + PHPDBG_G(flags) &= ~PHPDBG_IS_CLEANING; - return PHPDBG_NEXT; + return SUCCESS; } /* }}} */ PHPDBG_COMMAND(clean) /* {{{ */ @@ -1211,8 +1214,6 @@ PHPDBG_COMMAND(clean) /* {{{ */ phpdbg_writeln("clean", "constants=\"%d\"", "Constants %d", zend_hash_num_elements(EG(zend_constants))); phpdbg_writeln("clean", "includes=\"%d\"", "Includes %d", zend_hash_num_elements(&EG(included_files))); - PHPDBG_G(flags) &= ~PHPDBG_IS_RUNNING; - phpdbg_clean(1); phpdbg_xml("</cleaninfo>"); @@ -1291,7 +1292,7 @@ int phpdbg_interactive(zend_bool allow_async_unsafe) /* {{{ */ PHPDBG_G(flags) |= PHPDBG_IS_INTERACTIVE; while (ret == SUCCESS || ret == FAILURE) { - if ((PHPDBG_G(flags) & (PHPDBG_IS_STOPPING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_STOPPING) { + if (PHPDBG_G(flags) & PHPDBG_IS_STOPPING) { zend_bailout(); } @@ -1370,15 +1371,14 @@ void phpdbg_clean(zend_bool full) /* {{{ */ { /* this is implicitly required */ if (PHPDBG_G(ops)) { - destroy_op_array(PHPDBG_G(ops)); - efree(PHPDBG_G(ops)); + if (destroy_op_array(PHPDBG_G(ops))) { + efree(PHPDBG_G(ops)); + } PHPDBG_G(ops) = NULL; } if (full) { PHPDBG_G(flags) |= PHPDBG_IS_CLEANING; - - zend_bailout(); } } /* }}} */ diff --git a/sapi/phpdbg/phpdbg_prompt.h b/sapi/phpdbg/phpdbg_prompt.h index 25c0b4f71f..9dda175915 100644 --- a/sapi/phpdbg/phpdbg_prompt.h +++ b/sapi/phpdbg/phpdbg_prompt.h @@ -64,11 +64,6 @@ PHPDBG_COMMAND(wait); /* }}} */ /* {{{ prompt commands */ extern const phpdbg_command_t phpdbg_prompt_commands[]; /* }}} */ -/* {{{ */ -#if PHP_VERSION_ID >= 50500 void phpdbg_execute_ex(zend_execute_data *execute_data); -#else -void phpdbg_execute_ex(zend_op_array *op_array); -#endif /* }}} */ #endif /* PHPDBG_PROMPT_H */ diff --git a/sapi/phpdbg/phpdbg_sigsafe.h b/sapi/phpdbg/phpdbg_sigsafe.h index e5d0f34b43..e27b12c76c 100644 --- a/sapi/phpdbg/phpdbg_sigsafe.h +++ b/sapi/phpdbg/phpdbg_sigsafe.h @@ -1,10 +1,7 @@ #ifndef PHPDBG_SIGSAFE_H #define PHPDBG_SIGSAFE_H -//#include "zend_mm_structs.h" - -#define PHPDBG_SIGSAFE_MEM_SIZE ZEND_MM_CHUNK_SIZE -//(1 << 20) +#define PHPDBG_SIGSAFE_MEM_SIZE ZEND_MM_CHUNK_SIZE // (1 << 20) #include "zend.h" diff --git a/sapi/phpdbg/phpdbg_utils.c b/sapi/phpdbg/phpdbg_utils.c index 2e1e1ed70c..4d45066cfa 100644 --- a/sapi/phpdbg/phpdbg_utils.c +++ b/sapi/phpdbg/phpdbg_utils.c @@ -166,16 +166,20 @@ PHPDBG_API const char *phpdbg_current_file(void) /* {{{ */ PHPDBG_API const zend_function *phpdbg_get_function(const char *fname, const char *cname) /* {{{ */ { zend_function *func = NULL; - zend_string *lfname = zend_string_alloc(strlen(fname), 0); - memcpy(ZSTR_VAL(lfname), zend_str_tolower_dup(fname, ZSTR_LEN(lfname)), ZSTR_LEN(lfname) + 1); + zend_string *lfname = zend_string_init(fname, strlen(fname), 0); + zend_string *tmp = zend_string_tolower(lfname); + zend_string_release(lfname); + lfname = tmp; if (cname) { zend_class_entry *ce; - zend_string *lcname = zend_string_alloc(strlen(cname), 0); - memcpy(ZSTR_VAL(lcname), zend_str_tolower_dup(cname, ZSTR_LEN(lcname)), ZSTR_LEN(lcname) + 1); + zend_string *lcname = zend_string_init(cname, strlen(cname), 0); + tmp = zend_string_tolower(lcname); + zend_string_release(lcname); + lcname = tmp; ce = zend_lookup_class(lcname); - efree(lcname); + zend_string_release(lcname); if (ce) { func = zend_hash_find_ptr(&ce->function_table, lfname); @@ -184,7 +188,7 @@ PHPDBG_API const zend_function *phpdbg_get_function(const char *fname, const cha func = zend_hash_find_ptr(EG(function_table), lfname); } - efree(lfname); + zend_string_release(lfname); return func; } /* }}} */ diff --git a/sapi/phpdbg/tests/normal_exit.phpt b/sapi/phpdbg/tests/normal_exit.phpt new file mode 100644 index 0000000000..692614e98f --- /dev/null +++ b/sapi/phpdbg/tests/normal_exit.phpt @@ -0,0 +1,15 @@ +--TEST-- +A script with die() must end "normally" +--PHPDBG-- +r +q +--EXPECTF-- +[Successful compilation of %s] +prompt> [Script ended normally] +prompt> +--FILE-- +<?php + +(function($argv) { + die(); +})($argv); diff --git a/sapi/phpdbg/zend_mm_structs.h b/sapi/phpdbg/zend_mm_structs.h deleted file mode 100644 index ca64069e0f..0000000000 --- a/sapi/phpdbg/zend_mm_structs.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef ZEND_MM_STRUCTS_H -#define ZEND_MM_STRUCTS_H - -/* structs and macros defined in Zend/zend_alloc.c - Needed for realizing watchpoints and sigsafe memory */ - -#include "zend.h" - -#ifndef ZEND_MM_COOKIES -# define ZEND_MM_COOKIES ZEND_DEBUG -#endif - -#define ZEND_MM_CACHE 1 -#ifndef ZEND_MM_CACHE_STAT -# define ZEND_MM_CACHE_STAT 0 -#endif - -typedef struct _zend_mm_block_info { -#if ZEND_MM_COOKIES - size_t _cookie; -#endif - size_t _size; - size_t _prev; -} zend_mm_block_info; - -typedef struct _zend_mm_small_free_block { - zend_mm_block_info info; -#if ZEND_DEBUG - unsigned int magic; -#ifdef ZTS - THREAD_T thread_id; -#endif -#endif - struct _zend_mm_free_block *prev_free_block; - struct _zend_mm_free_block *next_free_block; -} zend_mm_small_free_block; - -typedef struct _zend_mm_free_block { - zend_mm_block_info info; -#if ZEND_DEBUG - unsigned int magic; -#ifdef ZTS - THREAD_T thread_id; -#endif -#endif - struct _zend_mm_free_block *prev_free_block; - struct _zend_mm_free_block *next_free_block; - - struct _zend_mm_free_block **parent; - struct _zend_mm_free_block *child[2]; -} zend_mm_free_block; - -#define ZEND_MM_SMALL_FREE_BUCKET(heap, index) \ - (zend_mm_free_block *) ((char *)&heap->free_buckets[index * 2] + \ - sizeof(zend_mm_free_block *) * 2 - \ - sizeof(zend_mm_small_free_block)) - -#define ZEND_MM_REST_BUCKET(heap) \ - (zend_mm_free_block *)((char *)&heap->rest_buckets[0] + \ - sizeof(zend_mm_free_block *) * 2 - \ - sizeof(zend_mm_small_free_block)) - -#define ZEND_MM_NUM_BUCKETS (sizeof(size_t) << 3) -struct _zend_mm_heap { - int use_zend_alloc; - void *(*_malloc)(size_t); - void (*_free)(void *); - void *(*_realloc)(void *, size_t); - size_t free_bitmap; - size_t large_free_bitmap; - size_t block_size; - size_t compact_size; - zend_mm_segment *segments_list; - zend_mm_storage *storage; - size_t real_size; - size_t real_peak; - size_t limit; - size_t size; - size_t peak; - size_t reserve_size; - void *reserve; - int overflow; - int internal; -#if ZEND_MM_CACHE - unsigned int cached; - zend_mm_free_block *cache[ZEND_MM_NUM_BUCKETS]; -#endif - zend_mm_free_block *free_buckets[ZEND_MM_NUM_BUCKETS*2]; - zend_mm_free_block *large_free_buckets[ZEND_MM_NUM_BUCKETS]; - zend_mm_free_block *rest_buckets[2]; - int rest_count; -#if ZEND_MM_CACHE_STAT - struct { - int count; - int max_count; - int hit; - int miss; - } cache_stat[ZEND_MM_NUM_BUCKETS+1]; -#endif -}; - -#endif |
