diff --git a/README.md b/README.md index c46d7b15d63..c058ba070c4 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ The following switches change the default behaviour of phpdbg: - -O set oplog output file - -q do not print banner on startup - -r jump straight to run + - -E enable step through eval() *Note: passing -rr will cause phpdbg to quit after execution, rather than returning to the console* diff --git a/phpdbg.c b/phpdbg.c index 9c3ca389231..ec106775292 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -393,6 +393,7 @@ const opt_struct OPTIONS[] = { /* {{{ */ {'I', 0, "ignore init"}, {'O', 1, "opline log"}, {'r', 0, "run"}, + {'E', 0, "step-through-eval"}, {'-', 0, NULL} }; /* }}} */ @@ -569,6 +570,10 @@ phpdbg_main: case 's': /* set stepping on */ step = 1; break; + + case 'E': /* stepping through eval on */ + flags |= PHPDBG_IS_STEPONEVAL; + break; case 'b': /* set colours off */ flags &= ~PHPDBG_IS_COLOURED; diff --git a/phpdbg.h b/phpdbg.h index 889639a2ec8..2f99543c6f1 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -97,6 +97,7 @@ #define PHPDBG_SEEK_MASK (PHPDBG_IN_UNTIL|PHPDBG_IN_FINISH|PHPDBG_IN_LEAVE) #define PHPDBG_IS_REGISTERED (1<<16) +#define PHPDBG_IS_STEPONEVAL (1<<17) #ifndef _WIN32 # define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_COLOURED) diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index baa303e7176..dc41e2498f0 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -489,7 +489,9 @@ PHPDBG_COMMAND(eval) /* {{{ */ zval retval; char *code = NULL; - PHPDBG_G(flags) &= ~ PHPDBG_IS_STEPPING; + if (!(PHPDBG_G(flags) & PHPDBG_IS_STEPONEVAL)) { + PHPDBG_G(flags) &= ~ PHPDBG_IS_STEPPING; + } if (input && input->start) { code = (char*) input->start; @@ -516,7 +518,8 @@ PHPDBG_COMMAND(eval) /* {{{ */ PHPDBG_G(flags) &= ~PHPDBG_IN_EVAL; /* switch stepping back on */ - if (stepping) { + if (stepping && + !(PHPDBG_G(flags) & PHPDBG_IS_STEPONEVAL)) { PHPDBG_G(flags) |= PHPDBG_IS_STEPPING; } @@ -869,6 +872,7 @@ PHPDBG_COMMAND(help) /* {{{ */ phpdbg_writeln(" -I\tN/A\t\t\tIgnore default .phpdbginit"); phpdbg_writeln(" -O\t-Omy.oplog\t\tSets oplog output file"); phpdbg_writeln(" -r\tN/A\t\t\tRun execution context"); + phpdbg_writeln(" -E\tN/A\t\t\tEnable step through eval, careful !"); phpdbg_notice( "Note: passing -rr will cause phpdbg to quit after execution"); phpdbg_help_footer(); @@ -1184,13 +1188,15 @@ zend_vm_enter: #endif #define DO_INTERACTIVE() do {\ - phpdbg_list_file(\ - zend_get_executed_filename(TSRMLS_C), \ - 3, \ - zend_get_executed_lineno(TSRMLS_C)-1, \ - zend_get_executed_lineno(TSRMLS_C) \ - TSRMLS_CC\ - );\ + if (!(PHPDBG_G(flags) & PHPDBG_IN_EVAL)) {\ + phpdbg_list_file(\ + zend_get_executed_filename(TSRMLS_C), \ + 3, \ + zend_get_executed_lineno(TSRMLS_C)-1, \ + zend_get_executed_lineno(TSRMLS_C) \ + TSRMLS_CC\ + );\ + }\ \ do {\ switch (phpdbg_interactive(TSRMLS_C)) {\