Browse Source

Fix misbehaviors with uncaught exceptions and finally or eval

pull/1428/head
Bob Weinand 11 years ago
parent
commit
75a3de0cd8
  1. 43
      sapi/phpdbg/phpdbg_prompt.c
  2. 6
      sapi/phpdbg/phpdbg_utils.c

43
sapi/phpdbg/phpdbg_prompt.c

@ -659,6 +659,7 @@ PHPDBG_COMMAND(run) /* {{{ */
char **argv = emalloc(5 * sizeof(char *));
int argc = 0;
int i;
/* TODO allow proper escaping with \, "" and '' here */
char *argv_str = strtok(param->str, " ");
while (argv_str) {
@ -767,15 +768,19 @@ PHPDBG_COMMAND(ev) /* {{{ */
PHPDBG_G(flags) |= PHPDBG_IN_EVAL;
zend_try {
if (zend_eval_stringl(param->str, param->len, &retval, "eval()'d code") == SUCCESS) {
phpdbg_xml("<eval %r>");
if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) {
zval *zvp = &retval;
phpdbg_xml_var_dump(zvp);
if (EG(exception)) {
zend_exception_error(EG(exception), E_ERROR);
} else {
phpdbg_xml("<eval %r>");
if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) {
zval *zvp = &retval;
phpdbg_xml_var_dump(zvp);
}
zend_print_zval_r(&retval, 0);
phpdbg_xml("</eval>");
phpdbg_out("\n");
zval_ptr_dtor(&retval);
}
zend_print_zval_r(&retval, 0);
phpdbg_xml("</eval>");
phpdbg_out("\n");
zval_ptr_dtor(&retval);
}
} zend_catch {
EG(current_execute_data) = original_execute_data;
@ -784,6 +789,7 @@ PHPDBG_COMMAND(ev) /* {{{ */
EG(vm_stack_end) = original_stack->end;
EG(vm_stack) = original_stack;
} zend_end_try();
PHPDBG_G(flags) &= ~PHPDBG_IN_EVAL;
/* switch stepping back on */
@ -1391,18 +1397,17 @@ void phpdbg_clean(zend_bool full) /* {{{ */
\
switch (phpdbg_interactive(allow_async_unsafe)) { \
zval zv; \
default: \
case PHPDBG_LEAVE: \
case PHPDBG_FINISH: \
case PHPDBG_UNTIL: \
case PHPDBG_NEXT: \
if (exception) { \
Z_OBJ(zv) = exception; \
zend_throw_exception_internal(&zv); \
} \
/* fallthrough */ \
case PHPDBG_LEAVE: \
case PHPDBG_FINISH: \
case PHPDBG_UNTIL: \
case PHPDBG_NEXT:{ \
default: \
goto next; \
} \
} \
} while (0)
@ -1431,7 +1436,7 @@ void phpdbg_execute_ex(zend_execute_data *execute_data) /* {{{ */
#endif
/* check for uncaught exceptions */
if (exception && PHPDBG_G(handled_exception) != exception) {
if (exception && PHPDBG_G(handled_exception) != exception && !(PHPDBG_G(flags) & PHPDBG_IN_EVAL)) {
zend_execute_data *prev_ex = execute_data;
zval zv, rv;
zend_string *file, *msg;
@ -1464,16 +1469,14 @@ void phpdbg_execute_ex(zend_execute_data *execute_data) /* {{{ */
}
ex_is_caught:
/* allow conditional breakpoints and
initialization to access the vm uninterrupted */
if ((PHPDBG_G(flags) & PHPDBG_IN_COND_BP) ||
(PHPDBG_G(flags) & PHPDBG_IS_INITIALIZING)) {
/* allow conditional breakpoints and initialization to access the vm uninterrupted */
if (PHPDBG_G(flags) & (PHPDBG_IN_COND_BP | PHPDBG_IS_INITIALIZING)) {
/* skip possible breakpoints */
goto next;
}
/* perform seek operation */
if (PHPDBG_G(flags) & PHPDBG_SEEK_MASK) {
if ((PHPDBG_G(flags) & PHPDBG_SEEK_MASK) && !(PHPDBG_G(flags) & PHPDBG_IN_EVAL)) {
/* current address */
zend_ulong address = (zend_ulong) execute_data->opline;

6
sapi/phpdbg/phpdbg_utils.c

@ -728,11 +728,11 @@ PHPDBG_API zend_bool phpdbg_check_caught_ex(zend_execute_data *execute_data, zen
op_num = op - op_array->opcodes;
for (i = 0; i < op_array->last_try_catch && op_array->try_catch_array[i].try_op < op_num; i++) {
for (i = 0; i < op_array->last_try_catch && op_array->try_catch_array[i].try_op <= op_num; i++) {
uint32_t catch = op_array->try_catch_array[i].catch_op, finally = op_array->try_catch_array[i].finally_op;
if (op_num <= catch || op_num <= finally) {
if (finally && finally < catch) {
return 0;
if (finally) {
return 1;
}
do {

Loading…
Cancel
Save