diff options
-rw-r--r-- | phpdbg.h | 42 | ||||
-rw-r--r-- | phpdbg_help.c | 15 | ||||
-rw-r--r-- | phpdbg_parser.y | 8 | ||||
-rw-r--r-- | phpdbg_prompt.c | 41 |
4 files changed, 47 insertions, 59 deletions
@@ -121,26 +121,26 @@ #define PHPDBG_IN_EVAL (1<<11) #define PHPDBG_IS_STEPPING (1<<12) -#define PHPDBG_IS_QUIET (1<<13) -#define PHPDBG_IS_QUITTING (1<<14) -#define PHPDBG_IS_COLOURED (1<<15) -#define PHPDBG_IS_CLEANING (1<<16) - -#define PHPDBG_IN_UNTIL (1<<17) -#define PHPDBG_IN_FINISH (1<<18) -#define PHPDBG_IN_LEAVE (1<<19) - -#define PHPDBG_IS_REGISTERED (1<<20) -#define PHPDBG_IS_STEPONEVAL (1<<21) -#define PHPDBG_IS_INITIALIZING (1<<22) -#define PHPDBG_IS_SIGNALED (1<<23) -#define PHPDBG_IS_INTERACTIVE (1<<24) -#define PHPDBG_IS_BP_ENABLED (1<<25) -#define PHPDBG_IS_REMOTE (1<<26) -#define PHPDBG_IS_DISCONNECTED (1<<27) - -#define PHPDBG_SHOW_REFCOUNTS (1<<28) -#define PHPDBG_STEP_OPCODE (1<<29) +#define PHPDBG_STEP_OPCODE (1<<13) +#define PHPDBG_IS_QUIET (1<<14) +#define PHPDBG_IS_QUITTING (1<<15) +#define PHPDBG_IS_COLOURED (1<<16) +#define PHPDBG_IS_CLEANING (1<<17) + +#define PHPDBG_IN_UNTIL (1<<18) +#define PHPDBG_IN_FINISH (1<<19) +#define PHPDBG_IN_LEAVE (1<<20) + +#define PHPDBG_IS_REGISTERED (1<<21) +#define PHPDBG_IS_STEPONEVAL (1<<22) +#define PHPDBG_IS_INITIALIZING (1<<23) +#define PHPDBG_IS_SIGNALED (1<<24) +#define PHPDBG_IS_INTERACTIVE (1<<25) +#define PHPDBG_IS_BP_ENABLED (1<<26) +#define PHPDBG_IS_REMOTE (1<<27) +#define PHPDBG_IS_DISCONNECTED (1<<28) + +#define PHPDBG_SHOW_REFCOUNTS (1<<29) #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) @@ -174,6 +174,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) HashTable registered; /* registered */ HashTable seek; /* seek oplines */ phpdbg_frame_t frame; /* frame */ + zend_uint last_line; /* last executed line */ #ifndef _WIN32 struct sigaction old_sigsegv_signal; /* segv signal handler */ @@ -201,7 +202,6 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) phpdbg_command_t *lcmd; /* last command */ phpdbg_param_t lparam; /* last param */ - zend_ulong lline; /* last line */ zend_ulong flags; /* phpdbg flags */ ZEND_END_MODULE_GLOBALS(phpdbg) /* }}} */ diff --git a/phpdbg_help.c b/phpdbg_help.c index f912f46787..32a78cb063 100644 --- a/phpdbg_help.c +++ b/phpdbg_help.c @@ -325,6 +325,7 @@ phpdbg_help_text_t phpdbg_help_text[] = { "**Starting and Stopping Execution**" CR " **exec** set execution context" CR " **run** attempt execution" CR +" **step** continue execution until other line is reached" CR " **continue** continue execution" CR " **until** continue execution up to the given location" CR " **finish** continue up to end of the current execution frame" CR @@ -862,20 +863,12 @@ phpdbg_help_text_t phpdbg_help_text[] = { }, {"step", -"You can enable and disable **stepping** mode at the phpdbg prompt during execution. When " -"stepping mode is enabled, execution will be step through opcode by opcode." CR CR +"Execute opcodes until beginning on next line" CR CR "**Examples**" CR CR -" $P step 1" CR -" $P s 1" CR -" Will enable stepping" CR CR -"While stepping is enabled you are presented with an interactive prompt after the execution of " -"each opcode." CR CR - -"Note that when executing the **finish** and **leave** commands, and oplines within the current " -"execution frame will be skipped in line with the command behaviour. Stepping will resume on exit " -"from the current frame." +" $P s" CR +" Will continue and break again in the next encountered line" CR CR }, {"until", diff --git a/phpdbg_parser.y b/phpdbg_parser.y index be37781cd1..4a84504e2e 100644 --- a/phpdbg_parser.y +++ b/phpdbg_parser.y @@ -147,15 +147,15 @@ parameter $$.str = $2.str; $$.len = $2.len; } + | T_RUN { + $$.type = RUN_PARAM; + $$.len = 0; + } | T_RUN T_INPUT { $$.type = RUN_PARAM; $$.str = $2.str; $$.len = $2.len; } - | T_RUN { - $$.type = RUN_PARAM; - $$.len = 0; - } | T_OPCODE { $$ = $1; } | T_ADDR { $$ = $1; } | T_LITERAL { $$ = $1; } diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index b8df289687..d93b55374e 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -43,7 +43,7 @@ int yyparse(phpdbg_param_t *stack, yyscan_t scanner); /* {{{ command declarations */ const phpdbg_command_t phpdbg_prompt_commands[] = { PHPDBG_COMMAND_D(exec, "set execution context", 'e', NULL, "s"), - PHPDBG_COMMAND_D(step, "step through execution", 's', NULL, "b"), + PHPDBG_COMMAND_D(step, "step through execution", 's', NULL, 0), PHPDBG_COMMAND_D(continue,"continue execution", 'c', NULL, 0), PHPDBG_COMMAND_D(run, "attempt execution", 'r', NULL, "|s"), PHPDBG_COMMAND_D(ev, "evaluate some code", 0, NULL, "i"), @@ -375,7 +375,10 @@ PHPDBG_COMMAND(exec) /* {{{ */ php_hash_environment(TSRMLS_C); phpdbg_notice("Set execution context: %s", PHPDBG_G(exec)); - phpdbg_compile(TSRMLS_C); + + if (phpdbg_compile(TSRMLS_C) == FAILURE) { + phpdbg_error("Failed to compile %s", PHPDBG_G(exec)); + } } else { phpdbg_notice("Execution context not changed"); } @@ -421,16 +424,9 @@ int phpdbg_compile(TSRMLS_D) /* {{{ */ PHPDBG_COMMAND(step) /* {{{ */ { - if (param->num) { - PHPDBG_G(flags) |= PHPDBG_IS_STEPPING; - } else { - PHPDBG_G(flags) &= ~PHPDBG_IS_STEPPING; - } - - phpdbg_notice("Stepping %s", - (PHPDBG_G(flags) & PHPDBG_IS_STEPPING) ? "on" : "off"); + PHPDBG_G(flags) |= PHPDBG_IS_STEPPING; - return SUCCESS; + return PHPDBG_NEXT; } /* }}} */ PHPDBG_COMMAND(continue) /* {{{ */ @@ -1230,7 +1226,6 @@ zend_vm_enter: #endif #define DO_INTERACTIVE() do { \ - PHPDBG_G(lline) = zend_get_executed_lineno(TSRMLS_C);\ if (!(PHPDBG_G(flags) & PHPDBG_IN_EVAL)) { \ phpdbg_list_file( \ zend_get_executed_filename(TSRMLS_C), \ @@ -1312,6 +1307,11 @@ zend_vm_enter: phpdbg_print_opline_ex( execute_data, &vars, 0 TSRMLS_CC); + if (PHPDBG_G(flags) & PHPDBG_IS_STEPPING && (PHPDBG_G(flags) & PHPDBG_STEP_OPCODE || execute_data->opline->lineno != PHPDBG_G(last_line))) { + PHPDBG_G(flags) &= ~PHPDBG_IS_STEPPING; + DO_INTERACTIVE(); + } + /* check if some watchpoint was hit */ { if (phpdbg_print_changed_zvals(TSRMLS_C) == SUCCESS) { @@ -1323,21 +1323,14 @@ zend_vm_enter: { phpdbg_breakbase_t *brake; - if ((PHPDBG_G(flags) & PHPDBG_BP_MASK) && - (brake = phpdbg_find_breakpoint(execute_data TSRMLS_CC))) { - phpdbg_hit_breakpoint( - brake, 1 TSRMLS_CC); + if ((PHPDBG_G(flags) & PHPDBG_BP_MASK) + && (brake = phpdbg_find_breakpoint(execute_data TSRMLS_CC)) + && (brake->type != PHPDBG_BREAK_FILE || execute_data->opline->lineno != PHPDBG_G(last_line))) { + phpdbg_hit_breakpoint(brake, 1 TSRMLS_CC); DO_INTERACTIVE(); } } - if (PHPDBG_G(flags) & PHPDBG_IS_STEPPING) { - if ((PHPDBG_G(flags) & PHPDBG_STEP_OPCODE) || - (execute_data->opline->lineno != PHPDBG_G(lline))) { - DO_INTERACTIVE(); - } - } - next: if (PHPDBG_G(flags) & PHPDBG_IS_SIGNALED) { phpdbg_writeln(EMPTY); @@ -1346,6 +1339,8 @@ next: DO_INTERACTIVE(); } + PHPDBG_G(last_line) = execute_data->opline->lineno; + PHPDBG_G(vmret) = execute_data->opline->handler(execute_data TSRMLS_CC); if (PHPDBG_G(vmret) > 0) { |