com php-src: noquit on fatal errors clean command to clear environment: phpdbg.c phpdbg_help.c phpdbg_help.h phpdbg_promp t.c

From: Date: Mon, 11 Nov 2013 08:02:04 +0000
Subject: com php-src: noquit on fatal errors clean command to clear environment: phpdbg.c phpdbg_help.c phpdbg_help.h phpdbg_promp t.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-75148@lists.php.net to get a copy of this message
Commit: b77508f25094684f0197e1a2337ddec6143512ec Author: krakjoe <joe.watkins@live.co.uk> Mon, 11 Nov 2013 08:02:04 +0000 Parents: b5da4267761367f0c8eecdad6fe830e784e74bdc Branches: PHP-5.6 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b77508f25094684f0197e1a2337ddec6143512ec Log: noquit on fatal errors clean command to clear environment Changed paths: M phpdbg.c M phpdbg_help.c M phpdbg_help.h M phpdbg_prompt.c Diff: diff --git a/phpdbg.c b/phpdbg.c index e7cb57d..3d4908c 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 4b218f3..1143091 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 ed67a3f..b48409f 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 9c05171..f8a203c 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"),

« previous php.cvs (#75148) next »