]> granicus.if.org Git - php/commitdiff
Fix breaking on HANDLE_EXCEPTION (opline_before_exception)
authorBob Weinand <bobwei9@hotmail.com>
Mon, 3 Aug 2015 15:15:26 +0000 (17:15 +0200)
committerBob Weinand <bobwei9@hotmail.com>
Mon, 3 Aug 2015 15:15:40 +0000 (17:15 +0200)
sapi/phpdbg/phpdbg_prompt.c
sapi/phpdbg/tests/exceptions_003.phpt [new file with mode: 0644]

index e920f30cdf3bb41bbb1b62d483a4fd93d4341b46..4d9bc00779226588bb590cbaeabb33f19c81af45 100644 (file)
@@ -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 (file)
index 0000000..fffe7a9
--- /dev/null
@@ -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<TO_CATCH>      ~%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--
+<?php
+
+try {
+       try {
+               x();
+       } finally {
+               print "ok\n";
+       }
+} catch (Error $e) {
+       print "caught\n";
+}
+
+?>