]> granicus.if.org Git - php/commitdiff
noquit on fatal errors
authorkrakjoe <joe.watkins@live.co.uk>
Mon, 11 Nov 2013 08:02:04 +0000 (08:02 +0000)
committerkrakjoe <joe.watkins@live.co.uk>
Mon, 11 Nov 2013 08:02:04 +0000 (08:02 +0000)
clean command to clear environment

phpdbg.c
phpdbg_help.c
phpdbg_help.h
phpdbg_prompt.c

index e7cb57d10c7239a7b5292f7efd1b0010b2fab8ac..3d4908cf62b8c93e9bcbec242b128f5dc132f1cb 100644 (file)
--- 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);
                }
index 4b218f31d2ff4bb702675c57a9fb710d04048f49..11430916c8046551d6d84dcb8ea5a47a567f86ee 100644 (file)
@@ -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");
index ed67a3fec21fa15f5094208cc44dd8ffc5bb34a3..b48409f487e186b9c1af5622438a57a8212ce1d9 100644 (file)
@@ -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}
index 9c0517119e09522f1a30ccdff3e646301e1eef09..f8a203c50ecbbbcd8499a12b0abd11c39fe85d7c 100644 (file)
@@ -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"),