Skip to content

Commit

Permalink
Fixed issue #1181: Remote debugging does not handle exceptions after …
Browse files Browse the repository at this point in the history
…using zend_read_property
  • Loading branch information
derickr committed Nov 22, 2015
1 parent c4092b6 commit 8883a3f
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/bug01181.inc
@@ -0,0 +1,23 @@
<?php

class BaseClass {
protected $protected = [1, 2, 3];
private $private = ['a', 'b', 'c'];
}

class DerivedClass extends BaseClass {
function __get($name)
{
throw new \Exception('Derived class getter called with: ' . $name);
}
}

try {
$test = new DerivedClass();
echo "Statement to break on.\n"; // Breakpoint here
}
catch (\Exception $e) {
echo $e->getMessage();
}
echo "Statement after try/catch\n";
?>
42 changes: 42 additions & 0 deletions tests/bug01181.phpt
@@ -0,0 +1,42 @@
--TEST--
Test for bug #1181: Derived class with __get gets called on fetching base class private property
--SKIPIF--
<?php if (getenv("SKIP_DBGP_TESTS")) { exit("skip Excluding DBGp tests"); } ?>
--FILE--
<?php
require 'dbgp/dbgpclient.php';
$data = file_get_contents(dirname(__FILE__) . '/bug01181.inc');

$commands = array(
'step_into',
'breakpoint_set -t line -n 17',
'run',
'property_get -n $test->*BaseClass*private',
'step_into',
);

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="3"></xdebug:message></response>

-> breakpoint_set -i 2 -t line -n 17
<?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="17"></xdebug:message></response>

-> property_get -i 4 -n $test->*BaseClass*private
<?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="4"><property name="$test-&gt;*BaseClass*private" fullname="$test-&gt;*BaseClass*private" address="" type="array" children="1" numchildren="3" page="0" pagesize="32"><property name="0" fullname="$test-&gt;*BaseClass*private[0]" address="" type="string" size="1" encoding="base64"><![CDATA[YQ==]]></property><property name="1" fullname="$test-&gt;*BaseClass*private[1]" address="" type="string" size="1" encoding="base64"><![CDATA[Yg==]]></property><property name="2" fullname="$test-&gt;*BaseClass*private[2]" address="" type="string" size="1" encoding="base64"><![CDATA[Yw==]]></property></property></response>

-> step_into -i 5
<?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="5" status="break" reason="ok"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="22"></xdebug:message></response>
4 changes: 4 additions & 0 deletions xdebug_var.c
Expand Up @@ -524,6 +524,10 @@ static zval* fetch_zval_from_symbol_table(zval *parent, char* name, unsigned int
retval_p = tmp_val;
goto cleanup;
}

if (EG(exception)) {
zend_clear_exception();
}
}

/* Then we try a public property */
Expand Down

0 comments on commit 8883a3f

Please sign in to comment.