From: krakjoe Date: Fri, 22 Nov 2013 09:09:54 +0000 (+0000) Subject: better handling of sigint X-Git-Tag: php-5.6.0alpha1~110^2~143^2~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a6bd3807c44fcd7e27c5d7135f843f2c69e536db;p=php better handling of sigint info literals command --- diff --git a/phpdbg.c b/phpdbg.c index d417a89158..27fedee9b4 100644 --- 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) /* {{{ */ diff --git a/phpdbg.h b/phpdbg.h index 967cd8fb0b..1cff51ee9f 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -100,6 +100,7 @@ #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) diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index d7d8c0d4fc..75b55dfb69 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -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(¶m, input TSRMLS_CC); break; diff --git a/phpdbg_info.c b/phpdbg_info.c index 09c91d5af6..a3a3f01989 100644 --- a/phpdbg_info.c +++ b/phpdbg_info.c @@ -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( diff --git a/phpdbg_info.h b/phpdbg_info.h index 5e88b731cb..727a3d6f65 100644 --- a/phpdbg_info.h +++ b/phpdbg_info.h @@ -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 }; diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 7099ecb6f7..fdd60449bf 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -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; } /* }}} */