Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merged pull request #158

  • Loading branch information...
commit f24ff8cf789ecb8da6362069e7cd6f35546c1a35 2 parents a12cba2 + b51cb16
@derickr authored
View
8 tests/bug01111-001.inc
@@ -0,0 +1,8 @@
+<?php
+function foo() {
+ throw new Exception();
+}
+
+foo();
+
+?>
View
40 tests/bug01111-001.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Test for bug #1105: eval does not work when debugger is stopped in xdebug_throw_exception_hook
+--FILE--
+<?php
+require 'dbgp/dbgpclient.php';
+$data = file_get_contents(dirname(__FILE__) . '/bug01111-001.inc');
+
+$commands = array(
+ 'step_into',
+ 'breakpoint_set -t exception -x Exception',
+ 'run',
+ 'eval -- ' . base64_encode('"modified"'),
+ 'detach',
+);
+
+dbgpRun( $data, $commands );
+?>
+--EXPECTF--
+<?xml version="1.0" encoding="iso-8859-1"?>
+<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///tmp/xdebug-dbgp-test.php" language="PHP" protocol_version="1.0" appid="" idekey=""><engine version=""><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2099 by Derick Rethans]]></copyright></init>
+
+-> step_into -i 1
+<?xml version="1.0" encoding="iso-8859-1"?>
+<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="1" status="break" reason="ok"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="2"></xdebug:message></response>
+
+-> breakpoint_set -i 2 -t exception -x Exception
+<?xml version="1.0" encoding="iso-8859-1"?>
+<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="2" id=""></response>
+
+-> run -i 3
+<?xml version="1.0" encoding="iso-8859-1"?>
+<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="run" transaction_id="3" status="break" reason="ok"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="3" exception="Exception"><![CDATA[]]></xdebug:message></response>
+
+-> eval -i 4 -- Im1vZGlmaWVkIg==
+<?xml version="1.0" encoding="iso-8859-1"?>
+<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="eval" transaction_id="4"><property address="" type="string" size="8" encoding="base64"><![CDATA[bW9kaWZpZWQ=]]></property></response>
+
+-> detach -i 5
+<?xml version="1.0" encoding="iso-8859-1"?>
+<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="detach" transaction_id="5" status="stopping" reason="ok"></response>
View
9 tests/bug01111-002.inc
@@ -0,0 +1,9 @@
+<?php
+function foo() {
+ $test = 'pristine';
+ throw new Exception();
+}
+
+foo();
+
+?>
View
45 tests/bug01111-002.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Test for bug #1105: eval does not work when debugger is stopped in xdebug_throw_exception_hook
+--FILE--
+<?php
+require 'dbgp/dbgpclient.php';
+$data = file_get_contents(dirname(__FILE__) . '/bug01111-002.inc');
+
+$commands = array(
+ 'step_into',
+ 'breakpoint_set -t exception -x Exception',
+ 'run',
+ 'property_set -n $test -- ' . base64_encode('"modified"'),
+ 'property_get -n $test',
+ 'detach',
+);
+
+dbgpRun( $data, $commands );
+?>
+--EXPECTF--
+<?xml version="1.0" encoding="iso-8859-1"?>
+<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///tmp/xdebug-dbgp-test.php" language="PHP" protocol_version="1.0" appid="" idekey=""><engine version=""><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2099 by Derick Rethans]]></copyright></init>
+
+-> step_into -i 1
+<?xml version="1.0" encoding="iso-8859-1"?>
+<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="1" status="break" reason="ok"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="2"></xdebug:message></response>
+
+-> breakpoint_set -i 2 -t exception -x Exception
+<?xml version="1.0" encoding="iso-8859-1"?>
+<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="2" id=""></response>
+
+-> run -i 3
+<?xml version="1.0" encoding="iso-8859-1"?>
+<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="run" transaction_id="3" status="break" reason="ok"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="4" exception="Exception"><![CDATA[]]></xdebug:message></response>
+
+-> property_set -i 4 -n $test -- Im1vZGlmaWVkIg==
+<?xml version="1.0" encoding="iso-8859-1"?>
+<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="property_set" transaction_id="4" success="1"></response>
+
+-> property_get -i 5 -n $test
+<?xml version="1.0" encoding="iso-8859-1"?>
+<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="property_get" transaction_id="5"><property name="$test" fullname="$test" address="" type="string" size="8" encoding="base64"><![CDATA[bW9kaWZpZWQ=]]></property></response>
+
+-> detach -i 6
+<?xml version="1.0" encoding="iso-8859-1"?>
+<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="detach" transaction_id="6" status="stopping" reason="ok"></response>
View
5 xdebug_handler_dbgp.c
@@ -1331,6 +1331,7 @@ static int xdebug_do_eval(char *eval_string, zval *ret_zval TSRMLS_DC)
zend_op_array *original_active_op_array = EG(active_op_array);
zend_execute_data *original_execute_data = EG(current_execute_data);
int original_no_extensions = EG(no_extensions);
+ zval *original_exception = EG(exception);
#if PHP_VERSION_ID < 50200
zend_bool original_bailout_set = EG(bailout_set);
jmp_buf original_bailout;
@@ -1353,6 +1354,9 @@ static int xdebug_do_eval(char *eval_string, zval *ret_zval TSRMLS_DC)
/* Do evaluation */
XG(breakpoints_allowed) = 0;
+ /* Reset exception in case we're triggered while being in xdebug_throw_exception_hook */
+ EG(exception) = NULL;
+
zend_first_try {
res = zend_eval_string(eval_string, ret_zval, "xdebug://debug-eval" TSRMLS_CC);
} zend_end_try();
@@ -1366,6 +1370,7 @@ static int xdebug_do_eval(char *eval_string, zval *ret_zval TSRMLS_DC)
EG(active_op_array) = original_active_op_array;
EG(current_execute_data) = original_execute_data;
EG(no_extensions) = original_no_extensions;
+ EG(exception) = original_exception;
#if PHP_VERSION_ID < 50200
EG(bailout_set) = original_bailout_set;
memcpy(&EG(bailout), &original_bailout, sizeof(jmp_buf));
Please sign in to comment.
Something went wrong with that request. Please try again.