mirror of
https://github.com/php/php-src.git
synced 2026-04-02 13:43:02 +02:00
Merge branch 'master' of github.com:krakjoe/phpdbg
This commit is contained in:
5
phpdbg.h
5
phpdbg.h
@@ -59,7 +59,10 @@
|
||||
# define PHPDBG_G(v) (phpdbg_globals.v)
|
||||
#endif
|
||||
|
||||
#define PHPDBG_NEXT 2
|
||||
#define PHPDBG_NEXT 2
|
||||
#define PHPDBG_UNTIL 3
|
||||
#define PHPDBG_FINISH 4
|
||||
#define PHPDBG_LEAVE 5
|
||||
|
||||
/* {{{ tables */
|
||||
#define PHPDBG_BREAK_FILE 0
|
||||
|
||||
@@ -52,7 +52,8 @@ PHPDBG_HELP(step) /* {{{ */
|
||||
PHPDBG_HELP(next) /* {{{ */
|
||||
{
|
||||
phpdbg_help_header();
|
||||
phpdbg_writeln("While stepping through execution, or after a breakpoint, use the next command to step back into the vm and execute the next opcode");
|
||||
phpdbg_write("While stepping through execution, or after a breakpoint, ");
|
||||
phpdbg_writeln("use the next command to step back into the vm and execute the next opcode");
|
||||
phpdbg_help_footer();
|
||||
return SUCCESS;
|
||||
} /* }}} */
|
||||
@@ -60,7 +61,8 @@ PHPDBG_HELP(next) /* {{{ */
|
||||
PHPDBG_HELP(until) /* {{{ */
|
||||
{
|
||||
phpdbg_help_header();
|
||||
phpdbg_writeln("While stepping through execution, or after a breakpoint, use the until command to step back into the vm and reaches the next source line");
|
||||
phpdbg_write("While stepping through execution, or after a breakpoint, ");
|
||||
phpdbg_writeln("use the until command to step back into the vm and reaches the next source line");
|
||||
phpdbg_help_footer();
|
||||
return SUCCESS;
|
||||
} /* }}} */
|
||||
@@ -68,7 +70,19 @@ PHPDBG_HELP(until) /* {{{ */
|
||||
PHPDBG_HELP(finish) /* {{{ */
|
||||
{
|
||||
phpdbg_help_header();
|
||||
phpdbg_writeln("While stepping through execution, or after a breakpoint, use the finish command to step back into the vm and continue until the current function has returned");
|
||||
phpdbg_write("While stepping through execution, or after a breakpoint, ");
|
||||
phpdbg_writeln("use the finish command to step back into the vm and continue until the current scope has returned");
|
||||
phpdbg_writeln("Note: this allows all breakpoints that would otherwise break execution in the current scope to be skipped");
|
||||
phpdbg_help_footer();
|
||||
return SUCCESS;
|
||||
} /* }}} */
|
||||
|
||||
PHPDBG_HELP(leave) /* {{{ */
|
||||
{
|
||||
phpdbg_help_header();
|
||||
phpdbg_write("While stepping through execution, or after a breakpoint, ");
|
||||
phpdbg_writeln("use the finish command to step back into the vm and continue until the current scope is returning");
|
||||
phpdbg_writeln("Note: this allows inspection of the return value from any scope before it is returned");
|
||||
phpdbg_help_footer();
|
||||
return SUCCESS;
|
||||
} /* }}} */
|
||||
|
||||
@@ -42,6 +42,7 @@ PHPDBG_HELP(run);
|
||||
PHPDBG_HELP(eval);
|
||||
PHPDBG_HELP(until);
|
||||
PHPDBG_HELP(finish);
|
||||
PHPDBG_HELP(leave);
|
||||
PHPDBG_HELP(print);
|
||||
PHPDBG_HELP(break);
|
||||
PHPDBG_HELP(clean);
|
||||
@@ -63,6 +64,7 @@ static const phpdbg_command_t phpdbg_help_commands[] = {
|
||||
PHPDBG_HELP_D(eval, "access to eval() allows you to affect the environment during execution", 'E'),
|
||||
PHPDBG_HELP_D(until, "continue until the program reaches a source line different than the current one", 'u'),
|
||||
PHPDBG_HELP_D(finish, "continue until the current function has returned", 'f'),
|
||||
PHPDBG_HELP_D(leave, "continue until the current function is returning", 'L'),
|
||||
PHPDBG_HELP_D(print, "printing allows inspection of the execution environment", 'p'),
|
||||
PHPDBG_HELP_D(break, "breakpoints allow execution interruption", 'b'),
|
||||
PHPDBG_HELP_D(clean, "resetting the environment is useful while debugging and recompiling", 'X'),
|
||||
|
||||
@@ -40,6 +40,7 @@ static PHPDBG_COMMAND(run);
|
||||
static PHPDBG_COMMAND(eval);
|
||||
static PHPDBG_COMMAND(until);
|
||||
static PHPDBG_COMMAND(finish);
|
||||
static PHPDBG_COMMAND(leave);
|
||||
static PHPDBG_COMMAND(print);
|
||||
static PHPDBG_COMMAND(break);
|
||||
static PHPDBG_COMMAND(back);
|
||||
@@ -62,7 +63,8 @@ static const phpdbg_command_t phpdbg_prompt_commands[] = {
|
||||
PHPDBG_COMMAND_EX_D(run, "attempt execution", 'r'),
|
||||
PHPDBG_COMMAND_EX_D(eval, "evaluate some code", 'E'),
|
||||
PHPDBG_COMMAND_EX_D(until, "continue until reaches next line", 'u'),
|
||||
PHPDBG_COMMAND_EX_D(finish, "continue until reaches next line", 'f'),
|
||||
PHPDBG_COMMAND_EX_D(finish, "continue past the end of the stack", 'f'),
|
||||
PHPDBG_COMMAND_EX_D(leave, "continue until the end of the stack", 'L'),
|
||||
PHPDBG_COMMANDS_D(print, "print something", 'p', phpdbg_print_commands),
|
||||
PHPDBG_COMMANDS_D(break, "set breakpoint", 'b', phpdbg_break_commands),
|
||||
PHPDBG_COMMAND_EX_D(back, "show trace", 't'),
|
||||
@@ -318,6 +320,11 @@ static PHPDBG_COMMAND(finish) /* {{{ */
|
||||
return PHPDBG_FINISH;
|
||||
} /* }}} */
|
||||
|
||||
static PHPDBG_COMMAND(leave) /* {{{ */
|
||||
{
|
||||
return PHPDBG_LEAVE;
|
||||
} /* }}} */
|
||||
|
||||
static PHPDBG_COMMAND(run) /* {{{ */
|
||||
{
|
||||
if (EG(in_execution)) {
|
||||
@@ -838,7 +845,8 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */
|
||||
phpdbg_error("Failed to execute %s!", cmd);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case PHPDBG_LEAVE:
|
||||
case PHPDBG_FINISH:
|
||||
case PHPDBG_UNTIL:
|
||||
case PHPDBG_NEXT: {
|
||||
@@ -993,7 +1001,7 @@ void phpdbg_execute_ex(zend_op_array *op_array TSRMLS_DC) /* {{{ */
|
||||
int last_step = 0;
|
||||
uint last_lineno;
|
||||
const char *last_file;
|
||||
const zend_execute_data *last_exec = NULL, *last_prev_exec;
|
||||
zend_op *last_op = NULL;
|
||||
|
||||
#if PHP_VERSION_ID < 50500
|
||||
if (EG(exception)) {
|
||||
@@ -1032,6 +1040,7 @@ zend_vm_enter:
|
||||
\
|
||||
do {\
|
||||
switch (last_step = phpdbg_interactive(TSRMLS_C)) {\
|
||||
case PHPDBG_LEAVE:\
|
||||
case PHPDBG_FINISH:\
|
||||
case PHPDBG_UNTIL:\
|
||||
case PHPDBG_NEXT:{\
|
||||
@@ -1046,26 +1055,45 @@ zend_vm_enter:
|
||||
/* skip possible breakpoints */
|
||||
goto next;
|
||||
}
|
||||
|
||||
/* run to next line */
|
||||
if (last_step == PHPDBG_UNTIL
|
||||
&& last_file == execute_data->op_array->filename
|
||||
&& last_lineno == execute_data->opline->lineno) {
|
||||
/* skip possible breakpoints */
|
||||
goto next;
|
||||
}
|
||||
|
||||
/* run to finish */
|
||||
if (last_step == PHPDBG_FINISH) {
|
||||
if (!(execute_data->prev_execute_data == last_exec
|
||||
&& execute_data == last_prev_exec)) {
|
||||
if (execute_data->opline < last_op) {
|
||||
/* skip possible breakpoints */
|
||||
goto next;
|
||||
} else {
|
||||
last_step = 0;
|
||||
last_op = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* break for leave */
|
||||
if (last_step == PHPDBG_LEAVE) {
|
||||
if (execute_data->opline == last_op) {
|
||||
phpdbg_notice(
|
||||
"Breaking for leave at %s:%u",
|
||||
zend_get_executed_filename(TSRMLS_C),
|
||||
zend_get_executed_lineno(TSRMLS_C)
|
||||
);
|
||||
DO_INTERACTIVE();
|
||||
} else {
|
||||
/* skip possible breakpoints */
|
||||
goto next;
|
||||
}
|
||||
last_exec = NULL;
|
||||
last_prev_exec = NULL;
|
||||
}
|
||||
|
||||
/* not while in conditionals */
|
||||
phpdbg_print_opline(
|
||||
execute_data, 0 TSRMLS_CC);
|
||||
|
||||
|
||||
/* conditions cannot be executed by eval()'d code */
|
||||
if (!(PHPDBG_G(flags) & PHPDBG_IN_EVAL)
|
||||
&& (PHPDBG_G(flags) & PHPDBG_HAS_COND_BP)
|
||||
@@ -1108,10 +1136,19 @@ zend_vm_enter:
|
||||
next:
|
||||
last_lineno = execute_data->opline->lineno;
|
||||
last_file = execute_data->op_array->filename;
|
||||
|
||||
if (last_step == PHPDBG_FINISH && last_exec == NULL) {
|
||||
last_exec = execute_data;
|
||||
last_prev_exec = execute_data->prev_execute_data;
|
||||
|
||||
switch (last_step) {
|
||||
case PHPDBG_FINISH:
|
||||
if (!last_op) {
|
||||
last_op = &execute_data->op_array->opcodes[execute_data->op_array->last-1];
|
||||
}
|
||||
break;
|
||||
|
||||
case PHPDBG_LEAVE:
|
||||
if (!last_op) {
|
||||
last_op = &execute_data->op_array->opcodes[execute_data->op_array->last-2];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
PHPDBG_G(vmret) = execute_data->opline->handler(execute_data TSRMLS_CC);
|
||||
|
||||
@@ -27,10 +27,6 @@
|
||||
|
||||
#define PHPDBG_STRL(s) s, sizeof(s)-1
|
||||
|
||||
#define PHPDBG_NEXT 2
|
||||
#define PHPDBG_UNTIL 3
|
||||
#define PHPDBG_FINISH 4
|
||||
|
||||
/**
|
||||
* Command Executor
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user