com php-src: fixup until/leave/finish: phpdbg.h phpdbg_prompt .c
| From: | Bob Weinand | Date: | Mon, 18 Nov 2013 01:44:46 +0000 |
| Subject: | com php-src: fixup until/leave/finish: phpdbg.h phpdbg_prompt .c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-74857@lists.php.net to get a copy of this message | ||
Commit: 07c0dc00cba29c392f560867c9bcffeeaa265550
Author: krakjoe <joe.watkins@live.co.uk> Mon, 18 Nov 2013 01:44:46 +0000
Parents: f9a66f0d4472747918923464869ff167ac8c3243
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=07c0dc00cba29c392f560867c9bcffeeaa265550
Log:
fixup until/leave/finish
Changed paths:
M phpdbg.h
M phpdbg_prompt.c
Diff:
diff --git a/phpdbg.h b/phpdbg.h
index 99a5908..bf528ed 100644
--- a/phpdbg.h
+++ b/phpdbg.h
@@ -91,6 +91,10 @@
#define PHPDBG_IS_COLOURED (1<<11)
#define PHPDBG_IS_CLEANING (1<<12)
+#define PHPDBG_IN_UNTIL (1<<13)
+#define PHPDBG_IN_FINISH (1<<14)
+#define PHPDBG_IN_LEAVE (1<<15)
+
#ifndef _WIN32
# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_COLOURED)
#else
@@ -113,6 +117,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
phpdbg_param_t *lparam; /* last param */
zend_ulong flags; /* phpdbg flags */
FILE *oplog; /* opline log */
+ zend_ulong seek; /* seek opline */
ZEND_END_MODULE_GLOBALS(phpdbg)
/* }}} */
diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c
index 96645f5..15d91a0 100644
--- a/phpdbg_prompt.c
+++ b/phpdbg_prompt..c
@@ -314,16 +314,51 @@ static PHPDBG_COMMAND(next) /* {{{ */
static PHPDBG_COMMAND(until) /* {{{ */
{
+ if (!EG(in_execution)) {
+ phpdbg_error("Not executing");
+ return SUCCESS;
+ }
+
+ PHPDBG_G(flags) |= PHPDBG_IN_UNTIL;
+ {
+ zend_uint next = 0,
+ self = (EG(current_execute_data)->opline - EG(active_op_array)->opcodes);
+ zend_op *opline = &EG(active_op_array)->opcodes[self];
+
+ for (next = self; next < EG(active_op_array)->last; next++) {
+ if (EG(active_op_array)->opcodes[next].lineno != opline->lineno) {
+ PHPDBG_G(seek) = (zend_ulong) &EG(active_op_array)->opcodes[next];
+ break;
+ }
+ }
+ }
+
return PHPDBG_UNTIL;
} /* }}} */
static PHPDBG_COMMAND(finish) /* {{{ */
{
+ if (!EG(in_execution)) {
+ phpdbg_error("Not executing");
+ return SUCCESS;
+ }
+
+ PHPDBG_G(flags) |= PHPDBG_IN_FINISH;
+ PHPDBG_G(seek) = (zend_ulong)
&(EG(active_op_array)->opcodes[EG(active_op_array)->last-2]);
+
return PHPDBG_FINISH;
} /* }}} */
static PHPDBG_COMMAND(leave) /* {{{ */
{
+ if (!EG(in_execution)) {
+ phpdbg_error("Not executing");
+ return SUCCESS;
+ }
+
+ PHPDBG_G(flags) |= PHPDBG_IN_LEAVE;
+ PHPDBG_G(seek) = (zend_ulong)
&(EG(active_op_array)->opcodes[EG(active_op_array)->last-2]);
+
return PHPDBG_LEAVE;
} /* }}} */
@@ -938,10 +973,6 @@ void phpdbg_execute_ex(zend_op_array *op_array TSRMLS_DC) /* {{{ */
zend_bool nested = 0;
#endif
zend_bool original_in_execution = EG(in_execution);
- int last_step = 0;
- uint last_lineno;
- const char *last_file;
- zend_op *last_op = NULL;
#if PHP_VERSION_ID < 50500
if (EG(exception)) {
@@ -979,7 +1010,7 @@ zend_vm_enter:
);\
\
do {\
- switch (last_step = phpdbg_interactive(TSRMLS_C)) {\
+ switch (phpdbg_interactive(TSRMLS_C)) {\
case PHPDBG_LEAVE:\
case PHPDBG_FINISH:\
case PHPDBG_UNTIL:\
@@ -997,27 +1028,28 @@ zend_vm_enter:
}
/* 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;
+ if (PHPDBG_G(flags) & PHPDBG_IN_UNTIL) {
+ if (((zend_ulong)execute_data->opline) == PHPDBG_G(seek)) {
+ PHPDBG_G(flags) &= ~PHPDBG_IN_UNTIL;
+ } else {
+ /* skip possible breakpoints */
+ goto next;
+ }
}
/* run to finish */
- if (last_step == PHPDBG_FINISH) {
- if (execute_data->opline < last_op) {
- /* skip possible breakpoints */
- goto next;
- } else {
- last_step = 0;
- last_op = NULL;
+ if (PHPDBG_G(flags) & PHPDBG_IN_FINISH) {
+ if (((zend_ulong)execute_data->opline) == PHPDBG_G(seek)) {
+ PHPDBG_G(flags) &= ~PHPDBG_IN_FINISH;
}
+ /* skip possible breakpoints */
+ goto next;
}
/* break for leave */
- if (last_step == PHPDBG_LEAVE) {
- if (execute_data->opline == last_op) {
+ if (PHPDBG_G(flags) & PHPDBG_IN_LEAVE) {
+ if (((zend_ulong)execute_data->opline) == PHPDBG_G(seek)) {
+ PHPDBG_G(flags) &= ~PHPDBG_IN_LEAVE;
phpdbg_notice(
"Breaking for leave at %s:%u",
zend_get_executed_filename(TSRMLS_C),
@@ -1074,23 +1106,6 @@ zend_vm_enter:
}
next:
- last_lineno = execute_data->opline->lineno;
- last_file = execute_data->op_array->filename;
-
- 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);
if (PHPDBG_G(vmret) > 0) {