From: krakjoe Date: Mon, 11 Nov 2013 08:02:04 +0000 (+0000) Subject: noquit on fatal errors X-Git-Tag: php-5.6.0alpha1~110^2~496 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b77508f25094684f0197e1a2337ddec6143512ec;p=php noquit on fatal errors clean command to clear environment --- diff --git a/phpdbg.c b/phpdbg.c index e7cb57d10c..3d4908cf62 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -353,12 +353,14 @@ int main(int argc, char *argv[]) /* {{{ */ zend_activate_modules(TSRMLS_C); } zend_end_try(); - zend_try { - do { - phpdbg_interactive(argc, argv TSRMLS_CC); - } while(!PHPDBG_G(quitting)); - } zend_end_try(); - + do { + zend_try { + phpdbg_interactive(argc, argv TSRMLS_CC); + } zend_catch { + + } zend_end_try(); + } while(!PHPDBG_G(quitting)); + if (ini_entries) { free(ini_entries); } diff --git a/phpdbg_help.c b/phpdbg_help.c index 4b218f31d2..11430916c8 100644 --- a/phpdbg_help.c +++ b/phpdbg_help.c @@ -91,6 +91,13 @@ PHPDBG_HELP(break) /* {{{ */ return SUCCESS; } /* }}} */ +PHPDBG_HELP(clean) /* {{{ */ +{ + printf("While debugging you may experience errors because of attempts to redeclare classes, constants or functions.\n"); + printf("Cleaning the environment cleans these tables, so that files can be recompiled without exiting phpdbg.\n"); + return SUCCESS; +} /* }}} */ + PHPDBG_HELP(quiet) /* {{{ */ { printf("Setting quietness on will stop the OPLINE output during execution\n"); diff --git a/phpdbg_help.h b/phpdbg_help.h index ed67a3fec2..b48409f487 100644 --- a/phpdbg_help.h +++ b/phpdbg_help.h @@ -41,6 +41,7 @@ PHPDBG_HELP(run); PHPDBG_HELP(eval); PHPDBG_HELP(print); PHPDBG_HELP(break); +PHPDBG_HELP(clean); PHPDBG_HELP(back); PHPDBG_HELP(quiet); @@ -56,6 +57,7 @@ static const phpdbg_command_t phpdbg_help_commands[] = { PHPDBG_HELP_D(eval, "access to eval() allows you to affect the environment during execution"), PHPDBG_HELP_D(print, "printing allows inspection of the execution environment"), PHPDBG_HELP_D(break, "breakpoints allow execution interruption"), + PHPDBG_HELP_D(clean, "resetting the environment is useful while debugging and recompiling"), PHPDBG_HELP_D(back, "show debug backtrace information during execution"), PHPDBG_HELP_D(quiet, "be quiet during execution"), {NULL, 0, 0} diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 9c0517119e..f8a203c50e 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -250,6 +250,30 @@ static PHPDBG_COMMAND(quit) /* {{{ */ return SUCCESS; } /* }}} */ +static int clean_non_persistent_constant_full(const zend_constant *c TSRMLS_DC) /* {{{ */ +{ + return (c->flags & CONST_PERSISTENT) ? 0 : 1; +} /* }}} */ + +static int clean_non_persistent_class_full(zend_class_entry **ce TSRMLS_DC) /* {{{ */ +{ + return ((*ce)->type == ZEND_INTERNAL_CLASS) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE; +} /* }}} */ + +static int clean_non_persistent_function_full(zend_function *function TSRMLS_DC) /* {{{ */ +{ + return (function->type == ZEND_INTERNAL_FUNCTION) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE; +} /* }}} */ + +static PHPDBG_COMMAND(clean) /* {{{ */ +{ + zend_hash_reverse_apply(EG(function_table), (apply_func_t) clean_non_persistent_function_full TSRMLS_CC); + zend_hash_reverse_apply(EG(class_table), (apply_func_t) clean_non_persistent_class_full TSRMLS_CC); + zend_hash_reverse_apply(EG(zend_constants), (apply_func_t) clean_non_persistent_constant_full TSRMLS_CC); + zend_hash_destroy(&EG(included_files)); + return SUCCESS; +} /* }}} */ + static PHPDBG_COMMAND(help) /* {{{ */ { printf("Welcome to phpdbg, the interactive PHP debugger.\n"); @@ -296,6 +320,7 @@ static const phpdbg_command_t phpdbg_prompt_commands[] = { PHPDBG_COMMAND_D(print, "print something"), PHPDBG_COMMAND_D(break, "set breakpoint"), PHPDBG_COMMAND_D(back, "show backtrace"), + PHPDBG_COMMAND_D(clean, "clean the execution environment"), PHPDBG_COMMAND_D(help, "show help menu"), PHPDBG_COMMAND_D(quiet, "silence some output"), PHPDBG_COMMAND_D(quit, "exit phpdbg"),