]> granicus.if.org Git - php/commitdiff
better handling of sigint
authorkrakjoe <joe.watkins@live.co.uk>
Fri, 22 Nov 2013 09:09:54 +0000 (09:09 +0000)
committerkrakjoe <joe.watkins@live.co.uk>
Fri, 22 Nov 2013 09:09:54 +0000 (09:09 +0000)
info literals command

phpdbg.c
phpdbg.h
phpdbg_cmd.c
phpdbg_info.c
phpdbg_info.h
phpdbg_prompt.c

index d417a89158d27819f4bfb916ed9026b58b20f2e7..27fedee9b45d8c8fd3b9c739019164b8a8e08c8b 100644 (file)
--- a/phpdbg.c
+++ b/phpdbg.c
@@ -437,7 +437,18 @@ static void phpdbg_welcome(zend_bool cleaning TSRMLS_DC) /* {{{ */
 static inline void phpdbg_sigint_handler(int signo) /* {{{ */
 {
        TSRMLS_FETCH();
-       PHPDBG_G(flags) |= PHPDBG_IS_SIGNALED;
+       
+       if (EG(in_execution)) {
+               /* we don't want to set signalled while phpdbg is interactive */
+               if (!(PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE)) {
+                       PHPDBG_G(flags) |= PHPDBG_IS_SIGNALED;
+               }
+       } else {
+               /* if we are not executing then just provide advice */
+               phpdbg_writeln(EMPTY);
+               phpdbg_error(
+                       "Please leave phpdbg gracefully !");
+       }
 } /* }}} */
 
 int main(int argc, char **argv) /* {{{ */
index 967cd8fb0beaa68842eda957069566a6c6d6fcf0..1cff51ee9f6bf9525c05aeacf14b8d4eebccad96 100644 (file)
--- a/phpdbg.h
+++ b/phpdbg.h
 #define PHPDBG_IS_STEPONEVAL   (1<<17)
 #define PHPDBG_IS_INITIALIZING (1<<18)
 #define PHPDBG_IS_SIGNALED      (1<<19)
+#define PHPDBG_IS_INTERACTIVE  (1<<20)
 
 #ifndef _WIN32
 #   define PHPDBG_DEFAULT_FLAGS    (PHPDBG_IS_QUIET|PHPDBG_IS_COLOURED)
index d7d8c0d4fcd0d8e998fa2ba3f683977d62201d3b..75b55dfb693e9a1d013fd649d4b8630167923ebf 100644 (file)
@@ -377,10 +377,12 @@ int phpdbg_do_cmd(const phpdbg_command_t *command, phpdbg_input_t *input TSRMLS_
                                        }
                                }
 
-                               PHPDBG_G(lcmd) = (phpdbg_command_t*) command;
-                               phpdbg_clear_param(
-                                       &PHPDBG_G(lparam) TSRMLS_CC);
-                               PHPDBG_G(lparam) = param;
+                               if (!(PHPDBG_G(flags) & PHPDBG_IS_INITIALIZING)) {
+                                       PHPDBG_G(lcmd) = (phpdbg_command_t*) command;
+                                       phpdbg_clear_param(
+                                               &PHPDBG_G(lparam) TSRMLS_CC);
+                                       PHPDBG_G(lparam) = param;
+                               }
 
                                rc = command->handler(&param, input TSRMLS_CC);
                                break;
index 09c91d5af68e21d2e2618c76c165466ce95927f8..a3a3f01989e8753c9c1ce1696036911f61ef5fcf 100644 (file)
@@ -144,6 +144,28 @@ PHPDBG_INFO(vars) /* {{{ */
        return SUCCESS;
 } /* }}} */
 
+PHPDBG_INFO(literal) /* {{{ */
+{
+       if (EG(in_execution) && EG(active_op_array)) {
+               zend_uint literal =0;
+               phpdbg_notice(
+                       "Literal Constants %d", EG(active_op_array)->last_literal-1);
+               
+               while (literal < EG(active_op_array)->last_literal) {
+                       phpdbg_write("|-------- C%lu -------> [", literal);
+                       zend_print_zval(
+                               &EG(active_op_array)->literals[literal].constant, 0);
+                       phpdbg_write("]");
+                       phpdbg_writeln(EMPTY);
+                       literal++;
+               }
+       } else {
+               phpdbg_error("Not executing !");
+       }
+       
+       return SUCCESS;
+} /* }}} */
+
 static inline void phpdbg_print_class_name(zend_class_entry **ce TSRMLS_DC) /* {{{ */
 {
        phpdbg_write(
index 5e88b731cb0cdaceafcf233fc51ea437c43f4d9b..727a3d6f65d0a7748817941310a4c8bcb6bdb080 100644 (file)
@@ -29,13 +29,15 @@ PHPDBG_INFO(classes);
 PHPDBG_INFO(funcs);
 PHPDBG_INFO(error);
 PHPDBG_INFO(vars);
+PHPDBG_INFO(literal);
 
 static const phpdbg_command_t phpdbg_info_commands[] = {
-    PHPDBG_COMMAND_D_EX(files,   "lists included files",  'F', info_files,   NULL, 0),
-    PHPDBG_COMMAND_D_EX(classes, "lists loaded classes",  'c', info_classes, NULL, 0),
-    PHPDBG_COMMAND_D_EX(funcs,   "lists loaded classes",  'f', info_funcs,   NULL, 0),
-    PHPDBG_COMMAND_D_EX(error,   "show the last error",   'e', info_error,   NULL, 0),
-    PHPDBG_COMMAND_D_EX(vars,    "show active variables", 'v', info_vars,    NULL, 0),
+    PHPDBG_COMMAND_D_EX(files,         "lists included files",                         'F', info_files,   NULL, 0),
+    PHPDBG_COMMAND_D_EX(classes,       "lists loaded classes",                         'c', info_classes, NULL, 0),
+    PHPDBG_COMMAND_D_EX(funcs,         "lists loaded classes",                         'f', info_funcs,   NULL, 0),
+    PHPDBG_COMMAND_D_EX(error,         "show the last error",                          'e', info_error,   NULL, 0),
+    PHPDBG_COMMAND_D_EX(vars,          "show active variables",                        'v', info_vars,    NULL, 0),
+    PHPDBG_COMMAND_D_EX(literal,       "show active literal constants",        'l', info_literal, NULL, 0),
     PHPDBG_END_COMMAND
 };
 
index 7099ecb6f72a9d79d978a5ad316ff80d9fb9ed6b..fdd60449bf10079dfe2917f71584651bf9e42072 100644 (file)
@@ -980,8 +980,10 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */
 {
        int ret = SUCCESS;
 
-       phpdbg_input_t *input = phpdbg_read_input(NULL TSRMLS_CC);
+       PHPDBG_G(flags) |= PHPDBG_IS_INTERACTIVE;
 
+       phpdbg_input_t *input = phpdbg_read_input(NULL TSRMLS_CC);
+       
        if (input && input->length > 0L) {
                do {
                        switch (ret = phpdbg_do_cmd(phpdbg_prompt_commands, input TSRMLS_CC)) {
@@ -1021,6 +1023,8 @@ last:
 
 out:
        phpdbg_destroy_input(&input TSRMLS_CC);
+       
+       PHPDBG_G(flags) &= ~PHPDBG_IS_INTERACTIVE;
 
        return ret;
 } /* }}} */