com php-src: better handling of sigint info literals command: phpdbg.c phpdbg.h phpdbg_cmd.c phpdbg_info.c phpdbg_info .h phpdbg_prompt.c

From: Date: Fri, 22 Nov 2013 09:09:54 +0000
Subject: com php-src: better handling of sigint info literals command: phpdbg.c phpdbg.h phpdbg_cmd.c phpdbg_info.c phpdbg_info .h phpdbg_prompt.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-74721@lists.php.net to get a copy of this message
Commit: a6bd3807c44fcd7e27c5d7135f843f2c69e536db Author: krakjoe <joe.watkins@live.co.uk> Fri, 22 Nov 2013 09:09:54 +0000 Parents: ae505ca3392a02c0c6702bf3b41a0e2e037634e6 Branches: PHP-5.6 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a6bd3807c44fcd7e27c5d7135f843f2c69e536db Log: better handling of sigint info literals command Changed paths: M phpdbg.c M phpdbg.h M phpdbg_cmd.c M phpdbg_info.c M phpdbg_info.h M phpdbg_prompt.c Diff: diff --git a/phpdbg.c b/phpdbg.c index d417a89..27fedee 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 967cd8f..1cff51e 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 d7d8c0d..75b55df 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(&param, input TSRMLS_CC); break; diff --git a/phpdbg_info.c b/phpdbg_info.c index 09c91d5..a3a3f01 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 5e88b73..727a3d6 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 7099ecb..fdd6044 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; } /* }}} */

« previous php.cvs (#74721) next »