]> granicus.if.org Git - php/commitdiff
Fix last commit, and do not output unnecessary information
authorBob Weinand <bobwei9@hotmail.com>
Sun, 26 Oct 2014 21:21:18 +0000 (22:21 +0100)
committerBob Weinand <bobwei9@hotmail.com>
Sun, 26 Oct 2014 23:00:18 +0000 (00:00 +0100)
phpdbg.c
phpdbg.h
phpdbg_io.c
phpdbg_prompt.c
tests/commands/0104_clean.test

index 3e31f76898a0503e073f6d04aceddf75ff5d715c..b7fb5e5afc43cd01e38303ee0684c71dc0dd23a1 100644 (file)
--- a/phpdbg.c
+++ b/phpdbg.c
@@ -544,7 +544,7 @@ static void php_sapi_phpdbg_log_message(char *message TSRMLS_DC) /* {{{ */
 
 static int php_sapi_phpdbg_deactivate(TSRMLS_D) /* {{{ */
 {
-       if ((PHPDBG_G(flags) & (PHPDBG_IS_CLEANING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_CLEANING) {
+       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);
@@ -554,7 +554,7 @@ static int php_sapi_phpdbg_deactivate(TSRMLS_D) /* {{{ */
                pg->oplog = PHPDBG_G(oplog);
                pg->prompt[0] = PHPDBG_G(prompt)[0];
                pg->prompt[1] = PHPDBG_G(prompt)[1];
-               memset(pg->colors, PHPDBG_G(colors), sizeof(pg->colors));
+               memcpy(pg->colors, PHPDBG_G(colors), sizeof(pg->colors));
                pg->eol = PHPDBG_G(eol);
                pg->flags = PHPDBG_G(flags) & PHPDBG_PRESERVE_FLAGS_MASK;
        }
@@ -1035,7 +1035,7 @@ int main(int argc, char **argv) /* {{{ */
        zend_ulong flags;
        char *php_optarg;
        int php_optind, opt, show_banner = 1;
-       long cleaning = 0;
+       long cleaning = -1;
        zend_bool remote = 0;
        int step = 0;
        zend_phpdbg_globals *settings = NULL;
@@ -1491,21 +1491,20 @@ phpdbg_main:
                /* Make stdin, stdout and stderr accessible from PHP scripts */
                phpdbg_register_file_handles(TSRMLS_C);
 
-               if (show_banner) {
+               if (show_banner && cleaning < 2) {
                        /* print blurb */
-                       phpdbg_welcome((cleaning > 0) TSRMLS_CC);
+                       phpdbg_welcome(cleaning == 1 TSRMLS_CC);
                }
 
-               /* auto compile */
-               if (PHPDBG_G(exec)) {
-                       phpdbg_compile(TSRMLS_C);
-               }
+               cleaning = -1;
 
                /* initialize from file */
                PHPDBG_G(flags) |= PHPDBG_IS_INITIALIZING;
                zend_try {
                        phpdbg_init(init_file, init_file_len, init_file_default TSRMLS_CC);
+                       PHPDBG_G(flags) |= PHPDBG_DISCARD_OUTPUT;
                        phpdbg_try_file_init(bp_tmp_file, strlen(bp_tmp_file), 0 TSRMLS_CC);
+                       PHPDBG_G(flags) &= ~PHPDBG_DISCARD_OUTPUT;
                } zend_end_try();
                PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING;
                
@@ -1514,14 +1513,24 @@ phpdbg_main:
                        goto phpdbg_out;
                }
 
+               /* auto compile */
+               if (PHPDBG_G(exec)) {
+                       if (settings) {
+                               PHPDBG_G(flags) |= PHPDBG_DISCARD_OUTPUT;
+                       }
+                       phpdbg_compile(TSRMLS_C);
+                       PHPDBG_G(flags) &= ~PHPDBG_DISCARD_OUTPUT;
+               }
+
                /* step from here, not through init */
                if (step) {
                        PHPDBG_G(flags) |= PHPDBG_IS_STEPPING;
                }
 
                if (phpdbg_startup_run) {
-                       /* no need to try{}, run does it ... */
-                       PHPDBG_COMMAND_HANDLER(run)(NULL TSRMLS_CC);
+                       zend_try {
+                               PHPDBG_COMMAND_HANDLER(run)(NULL TSRMLS_CC);
+                       } zend_end_try();
                        if (phpdbg_startup_run > 1) {
                                /* if -r is on the command line more than once just quit */
                                goto phpdbg_out;
@@ -1537,7 +1546,9 @@ phpdbg_interact:
                        } zend_catch {
                                if ((PHPDBG_G(flags) & PHPDBG_IS_CLEANING)) {
                                        FILE *bp_tmp_fp = fopen(bp_tmp_file, "w");
+                                       PHPDBG_G(flags) |= PHPDBG_DISCARD_OUTPUT;
                                        phpdbg_export_breakpoints(bp_tmp_fp TSRMLS_CC);
+                                       PHPDBG_G(flags) &= ~PHPDBG_DISCARD_OUTPUT;
                                        fclose(bp_tmp_fp);
                                        cleaning = 1;
                                } else {
@@ -1589,9 +1600,13 @@ phpdbg_out:
        } __except(phpdbg_exception_handler_win32(xp = GetExceptionInformation())) {
                phpdbg_error("segfault", "", "Access violation (Segementation fault) encountered\ntrying to abort cleanly...");
        }
-/* phpdbg_out: */
 #endif
 
+               if (cleaning <= 0) {
+                       PHPDBG_G(flags) &= ~PHPDBG_IS_CLEANING;
+                       cleaning = -1;
+               }
+
                {
                        int i;
                        /* free argv */
@@ -1638,9 +1653,10 @@ phpdbg_out:
 
                if ((PHPDBG_G(flags) & (PHPDBG_IS_QUITTING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_RUNNING) {
                        phpdbg_notice("stop", "type=\"normal\"", "Script ended normally");
+                       cleaning++;
                }
 
-               if ((PHPDBG_G(flags) & (PHPDBG_IS_CLEANING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_CLEANING) {
+               if ((PHPDBG_G(flags) & PHPDBG_IS_STOPPING) == PHPDBG_IS_CLEANING) {
                        settings = PHPDBG_G(backup);
                }
 
@@ -1654,7 +1670,7 @@ phpdbg_out:
 
        }
 
-       if (cleaning || remote) {
+       if (cleaning > 0 || remote) {
                goto phpdbg_main;
        }
 
index 57ea7ee570f1e09d1201586e4262cae2ca1b68aa..65bdcd0d6f3ef83b69e3fcc5028b0d8d506bbb30 100644 (file)
--- a/phpdbg.h
+++ b/phpdbg.h
@@ -177,12 +177,14 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC);
 
 #define PHPDBG_IN_SIGNAL_HANDLER      (1ULL<<33)
 
+#define PHPDBG_DISCARD_OUTPUT         (1ULL<<34)
+
 #define PHPDBG_SEEK_MASK              (PHPDBG_IN_UNTIL | PHPDBG_IN_FINISH | PHPDBG_IN_LEAVE)
 #define PHPDBG_BP_RESOLVE_MASK       (PHPDBG_HAS_FUNCTION_OPLINE_BP | PHPDBG_HAS_METHOD_OPLINE_BP | PHPDBG_HAS_FILE_OPLINE_BP)
 #define PHPDBG_BP_MASK                (PHPDBG_HAS_FILE_BP | PHPDBG_HAS_SYM_BP | PHPDBG_HAS_METHOD_BP | PHPDBG_HAS_OPLINE_BP | PHPDBG_HAS_COND_BP | PHPDBG_HAS_OPCODE_BP | PHPDBG_HAS_FUNCTION_OPLINE_BP | PHPDBG_HAS_METHOD_OPLINE_BP | PHPDBG_HAS_FILE_OPLINE_BP)
 #define PHPDBG_IS_STOPPING            (PHPDBG_IS_QUITTING | PHPDBG_IS_CLEANING)
 
-#define PHPDBG_PRESERVE_FLAGS_MASK    (PHPDBG_SHOW_REFCOUNTS | PHPDBG_IS_STEPONEVAL | PHPDBG_IS_BP_ENABLED | PHPDBG_STEP_OPCODE)
+#define PHPDBG_PRESERVE_FLAGS_MASK    (PHPDBG_SHOW_REFCOUNTS | PHPDBG_IS_STEPONEVAL | PHPDBG_IS_BP_ENABLED | PHPDBG_STEP_OPCODE | PHPDBG_IS_QUIET | PHPDBG_IS_COLOURED)
 
 #ifndef _WIN32
 #      define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET | PHPDBG_IS_COLOURED | PHPDBG_IS_BP_ENABLED)
index a2a5c5969f491520c2ed9ba35e21ee3bfe70bdba..6908a687d7ed0dbd46b9ebe696fece6231d24675 100644 (file)
@@ -187,6 +187,10 @@ PHPDBG_API int phpdbg_mixed_read(int sock, char *ptr, int len, int tmo TSRMLS_DC
 
 
 PHPDBG_API int phpdbg_mixed_write(int sock, const char *ptr, int len TSRMLS_DC) {
+       if (PHPDBG_G(flags) & PHPDBG_DISCARD_OUTPUT) {
+               return 0;
+       }
+
        if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) {
                return phpdbg_send_bytes(sock, ptr, len);
        }
index a2e4d41042d65386decfb0ad7abb4b8b9a97b5af..fd4af2c3cd70d4fff50cb50f61b2fbeec52dde57 100644 (file)
@@ -263,7 +263,7 @@ void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_
                                                goto next_line;
                                        }
 
-                                       {
+                                       zend_try {
                                                char *input = phpdbg_read_input(cmd TSRMLS_CC);
                                                phpdbg_param_t stack;
 
@@ -287,7 +287,12 @@ void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_
 
                                                phpdbg_stack_free(&stack);
                                                phpdbg_destroy_input(&input TSRMLS_CC);
-                                       }
+                                       } zend_catch {
+                                               PHPDBG_G(flags) &= ~(PHPDBG_IS_RUNNING | PHPDBG_IS_CLEANING);
+                                               if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) {
+                                                       zend_bailout();
+                                               }
+                                       } zend_end_try();
                                }
 next_line:
                                line++;
@@ -1160,6 +1165,8 @@ 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 TSRMLS_CC);
 
        phpdbg_xml("</cleaninfo>");
index d50903c479ead7557721f59545fb90485f6a0c26..2c7660ad60ebc33d3cdead53463560d9f0f18896 100644 (file)
@@ -9,7 +9,6 @@
 #Functions  %d
 #Constants  %d
 #Includes   %d
-#[Nothing to execute!]
 #################################################
 clean
 quit