From: Bob Weinand Date: Mon, 3 Aug 2015 15:15:26 +0000 (+0200) Subject: Fix breaking on HANDLE_EXCEPTION (opline_before_exception) X-Git-Tag: php-7.0.0beta3~5^2~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=34596a3dddb407fc36af7cdf9da55253210da5e1;p=php Fix breaking on HANDLE_EXCEPTION (opline_before_exception) --- diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index e920f30cdf..4d9bc00779 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -1404,13 +1404,15 @@ void phpdbg_clean(zend_bool full) /* {{{ */ } } /* }}} */ -/* code may behave weirdly if EG(exception) is set */ +/* code may behave weirdly if EG(exception) is set; thus backup it */ #define DO_INTERACTIVE(allow_async_unsafe) do { \ const zend_op *backup_opline; \ + const zend_op *before_ex; \ if (exception) { \ if (EG(current_execute_data) && EG(current_execute_data)->func && ZEND_USER_CODE(EG(current_execute_data)->func->common.type)) { \ backup_opline = EG(current_execute_data)->opline; \ } \ + before_ex = EG(opline_before_exception); \ ++GC_REFCOUNT(exception); \ zend_clear_exception(); \ } \ @@ -1436,6 +1438,7 @@ void phpdbg_clean(zend_bool full) /* {{{ */ Z_OBJ(zv) = exception; \ zend_throw_exception_internal(&zv); \ } \ + EG(opline_before_exception) = before_ex; \ } \ /* fallthrough */ \ default: \ diff --git a/sapi/phpdbg/tests/exceptions_003.phpt b/sapi/phpdbg/tests/exceptions_003.phpt new file mode 100644 index 0000000000..fffe7a9296 --- /dev/null +++ b/sapi/phpdbg/tests/exceptions_003.phpt @@ -0,0 +1,54 @@ +--TEST-- +Test breaks on HANDLE_EXCEPTION +--PHPDBG-- +b 5 +r +s + +s + + +q +--EXPECTF-- +[Successful compilation of %s] +prompt> [Breakpoint #0 added at %s:5] +prompt> [Breakpoint #0 at %s:5, hits: 1] +>00005: x(); + 00006: } finally { + 00007: print "ok\n"; +prompt> [L0 %s HANDLE_EXCEPTION %s] +>00005: x(); + 00006: } finally { + 00007: print "ok\n"; +prompt> [L7 %s ECHO "ok " %s] +>00007: print "ok\n"; + 00008: } + 00009: } catch (Error $e) { +prompt> ok +[L7 %s FAST_RET ~%d J7 %s] +[L9 %s CATCH "Error" $e 1 %s] +>00005: x(); + 00006: } finally { + 00007: print "ok\n"; +prompt> [L10 %s ECHO "caught " %s] +>00010: print "caught\n"; + 00011: } + 00012: +prompt> caught +[L10 %s RETURN 1 %s] +[Script ended normally] +prompt> +--FILE-- +