From: Bob Weinand Date: Sun, 23 Mar 2014 22:32:13 +0000 (+0100) Subject: Merge branch 'master' into watchpoints_recursive X-Git-Tag: php-5.6.0beta2~1^2~37^2~23 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c86ba551ac4011dd8320ba6b620ab3bcca0821c7;p=php Merge branch 'master' into watchpoints_recursive Conflicts: phpdbg.c phpdbg_utils.c phpdbg_utils.h --- c86ba551ac4011dd8320ba6b620ab3bcca0821c7 diff --cc config.m4 index 9e2d210580,dd6d425893..14c00bd377 --- a/config.m4 +++ b/config.m4 @@@ -18,11 -18,16 +18,16 @@@ if test "$PHP_PHPDBG" != "no"; the fi PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE" - PHP_PHPDBG_FILES="phpdbg.c phpdbg_prompt.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_info.c phpdbg_cmd.c phpdbg_set.c phpdbg_frame.c" + PHP_PHPDBG_FILES="phpdbg.c phpdbg_prompt.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_info.c phpdbg_cmd.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_btree.c" + if test "$PHP_READLINE" != "no"; then + PHPDBG_EXTRA_LIBS="-lreadline" + fi + PHP_SUBST(PHP_PHPDBG_CFLAGS) PHP_SUBST(PHP_PHPDBG_FILES) - + PHP_SUBST(PHPDBG_EXTRA_LIBS) + PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/phpdbg/Makefile.frag]) PHP_SELECT_SAPI(phpdbg, program, $PHP_PHPDBG_FILES, $PHP_PHPDBG_CFLAGS, [$(SAPI_PHPDBG_PATH)]) diff --cc config.w32 index 7501847726,1ea862f59e..fcc2b61a87 --- a/config.w32 +++ b/config.w32 @@@ -1,7 -1,7 +1,7 @@@ - ARG_ENABLE('phpdbg', 'Build phpdbg', 'yes'); + ARG_ENABLE('phpdbg', 'Build phpdbg', 'no'); ARG_ENABLE('phpdbgs', 'Build phpdbg shared', 'no'); -PHPDBG_SOURCES='phpdbg.c phpdbg_prompt.c phpdbg_cmd.c phpdbg_info.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_set.c phpdbg_frame.c'; +PHPDBG_SOURCES='phpdbg.c phpdbg_prompt.c phpdbg_cmd.c phpdbg_info.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_win.c phpdbg_btree.c'; PHPDBG_DLL='php' + PHP_VERSION + 'phpdbg.dll'; PHPDBG_EXE='phpdbg.exe'; @@@ -14,5 -14,6 +14,5 @@@ if (PHP_PHPDBG == "yes") if (PHP_PHPDBGS == "yes") { SAPI('phpdbgs', PHPDBG_SOURCES, PHPDBG_DLL, '/D PHP_PHPDBG_EXPORTS /I win32'); ADD_FLAG("LIBS_PHPDBGS", "ws2_32.lib user32.lib"); + DEFINE("CFLAGS", configure_subst.item("CFLAGS") + " /EHa"); - } + } - - diff --cc phpdbg.c index 6bb52b0bbc,7676687e71..32992ab6da --- a/phpdbg.c +++ b/phpdbg.c @@@ -213,16 -208,16 +213,16 @@@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) / return SUCCESS; } /* }}} */ -/* {{{ proto mixed phpdbg_exec(string context) +/* {{{ proto mixed phpdbg_exec(string context) Attempt to set the execution context for phpdbg If the execution context was set previously it is returned - If the execution context was not set previously boolean true is returned + If the execution context was not set previously boolean true is returned If the request to set the context fails, boolean false is returned, and an E_WARNING raised */ -static PHP_FUNCTION(phpdbg_exec) +static PHP_FUNCTION(phpdbg_exec) { char *exec = NULL; - zend_ulong exec_len = 0L; - + int exec_len = 0; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &exec, &exec_len) == FAILURE) { return; } @@@ -1144,52 -1137,27 +1166,54 @@@ phpdbg_main } phpdbg->ini_entries = ini_entries; - + if (phpdbg->startup(phpdbg) == SUCCESS) { +#ifdef _WIN32 + EXCEPTION_POINTERS *xp; + __try { +#endif + zend_mm_heap *mm_heap = zend_mm_set_heap(NULL TSRMLS_CC); +#if ZEND_DEBUG + if (!mm_heap->use_zend_alloc) { + mm_heap->_malloc = malloc; + mm_heap->_realloc = realloc; + mm_heap->_free = free; +#endif + PHPDBG_G(original_free_function) = mm_heap->_free; + mm_heap->_free = phpdbg_watch_efree; + mm_heap->use_zend_alloc = 0; +#if ZEND_DEBUG + } +#endif + zend_mm_set_heap(mm_heap TSRMLS_CC); + + zend_activate(TSRMLS_C); + +#if defined(ZEND_SIGNALS) && !defined(_WIN32) + zend_try { + zend_signal_activate(TSRMLS_C); + } zend_end_try(); +#endif + +#if defined(ZEND_SIGNALS) && !defined(_WIN32) + zend_try { zend_sigaction(SIGSEGV, &signal_struct, &PHPDBG_G(old_sigsegv_signal) TSRMLS_CC); } zend_end_try(); + zend_try { zend_sigaction(SIGBUS, &signal_struct, &PHPDBG_G(old_sigsegv_signal) TSRMLS_CC); } zend_end_try(); +#elif !defined(_WIN32) + sigaction(SIGSEGV, &signal_struct, &PHPDBG_G(old_sigsegv_signal)); + sigaction(SIGBUS, &signal_struct, &PHPDBG_G(old_sigsegv_signal)); +#endif + + php_request_startup(TSRMLS_C); + /* do not install sigint handlers for remote consoles */ /* sending SIGINT then provides a decent way of shutting down the server */ -#ifdef ZEND_SIGNALS -# ifndef _WIN32 +#if defined(ZEND_SIGNALS) && !defined(_WIN32) if (listen[0] < 0) { -# endif - zend_try { - zend_signal_activate(TSRMLS_C); - zend_signal(SIGINT, phpdbg_sigint_handler TSRMLS_CC); - } zend_end_try(); -# ifndef _WIN32 + zend_try { zend_signal(SIGINT, phpdbg_sigint_handler TSRMLS_CC); } zend_end_try(); } -# endif -#else -# ifndef _WIN32 +#elif !defined(_WIN32) if (listen[0] < 0) { -# endif +#endif signal(SIGINT, phpdbg_sigint_handler); #ifndef _WIN32 } diff --cc phpdbg_prompt.c index 70d567d5dc,e53a5e68b1..6868f9781a --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@@ -51,13 -51,12 +51,12 @@@ const phpdbg_command_t phpdbg_prompt_co PHPDBG_COMMAND_D(break, "set breakpoint", 'b', phpdbg_break_commands, 1), PHPDBG_COMMAND_D(back, "show trace", 't', NULL, 0), PHPDBG_COMMAND_D(frame, "switch to a frame", 'f', NULL, 1), - PHPDBG_COMMAND_D(list, "lists some code", 'l', phpdbg_list_commands, 2), - PHPDBG_COMMAND_D(info, "displays some informations", 'i', phpdbg_info_commands, 1), + PHPDBG_COMMAND_D(list, "lists some code", 'l', phpdbg_list_commands, 2), + PHPDBG_COMMAND_D(info, "displays some informations", 'i', phpdbg_info_commands, 1), PHPDBG_COMMAND_D(clean, "clean the execution environment", 'X', NULL, 0), PHPDBG_COMMAND_D(clear, "clear breakpoints", 'C', NULL, 0), - PHPDBG_COMMAND_D(help, "show help menu", 'h', phpdbg_help_commands, 2), + PHPDBG_COMMAND_D(help, "show help menu", 'h', phpdbg_help_commands, 2), PHPDBG_COMMAND_D(quiet, "silence some output", 'Q', NULL, 1), - PHPDBG_COMMAND_D(aliases, "show alias list", 'a', NULL, 0), PHPDBG_COMMAND_D(set, "set phpdbg configuration", 'S', phpdbg_set_commands, 1), PHPDBG_COMMAND_D(register,"register a function", 'R', NULL, 1), PHPDBG_COMMAND_D(source, "execute a phpdbginit", '.', NULL, 1), diff --cc phpdbg_utils.c index 337f31f0ad,d64d9ad686..111673d44f --- a/phpdbg_utils.c +++ b/phpdbg_utils.c @@@ -386,20 -388,21 +388,38 @@@ PHPDBG_API const char *phpdbg_get_promp return PHPDBG_G(prompt)[1]; } /* }}} */ +int phpdbg_rebuild_symtable(TSRMLS_D) { + if (!EG(active_op_array)) { + phpdbg_error("No active op array!"); + return FAILURE; + } + + if (!EG(active_symbol_table)) { + zend_rebuild_symbol_table(TSRMLS_C); + + if (!EG(active_symbol_table)) { + phpdbg_error("No active symbol table!"); + return FAILURE; + } + } + + return SUCCESS; +} ++ + PHPDBG_API int phpdbg_get_terminal_width(TSRMLS_D) /* {{{ */ + { + int columns; + #ifdef _WIN32 + CONSOLE_SCREEN_BUFFER_INFO csbi; + + GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); + columns = csbi.srWindow.Right - csbi.srWindow.Left + 1; + #elif defined(HAVE_SYS_IOCTL_H) + struct winsize w; + + columns = ioctl(fileno(stdout), TIOCGWINSZ, &w) == 0 ? w.ws_col : 100; + #else + columns = 100; + #endif + return columns; + } /* }}} */ - diff --cc phpdbg_utils.h index 27f2c7d841,ee7ff3f5bd..69c4763018 --- a/phpdbg_utils.h +++ b/phpdbg_utils.h @@@ -107,6 -107,7 +107,9 @@@ PHPDBG_API const phpdbg_color_t* phpdbg PHPDBG_API void phpdbg_set_prompt(const char* TSRMLS_DC); PHPDBG_API const char *phpdbg_get_prompt(TSRMLS_D); /* }}} */ + /* {{{ Console Width */ + PHPDBG_API int phpdbg_get_terminal_width(TSRMLS_D); /* }}} */ + +int phpdbg_rebuild_symtable(TSRMLS_D); + #endif /* PHPDBG_UTILS_H */