Skip to content

Commit

Permalink
Fixed issue xdebug#797: Xdebug crashes when fetching static properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
derickr committed Apr 23, 2012
1 parent 3ff4076 commit cc7fd70
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 54 deletions.
28 changes: 15 additions & 13 deletions tests/bug00797.inc
@@ -1,17 +1,19 @@
<?php <?php
class Base { $a = new A;
static public $property = true;

class A {
static public function basetest( ) { // private $a;
echo 'blah blah blah';
}
}


class Test extends Base { function __construct() {
public function test( ) { $this->a = B::foo();
static::basetest( ); }
}
} }


$test = new Test; class B {
$test->test( ); private $b;

static public function foo() {
return "I'm alive!";
}
}
?>
52 changes: 11 additions & 41 deletions tests/bug00797.phpt
Expand Up @@ -6,16 +6,10 @@ require 'dbgp/dbgpclient.php';
$data = file_get_contents(dirname(__FILE__) . '/bug00797.inc'); $data = file_get_contents(dirname(__FILE__) . '/bug00797.inc');


$commands = array( $commands = array(
'breakpoint_set -t line -n 6 -f file:///tmp/xdebug-dbgp-test.php', 'step_into',
'run', 'step_into',
'stack_get', 'step_into',
'stack_get -d 0',
'context_get -d 1',
'property_get -d 1 -n $this',
'property_get -d 1 -n $this::property',
'context_get -d 0', 'context_get -d 0',
'property_get -d 0 -n ::',
'property_get -d 0 -n ::property',
); );


dbgpRun( $data, $commands ); dbgpRun( $data, $commands );
Expand All @@ -24,42 +18,18 @@ dbgpRun( $data, $commands );
<?xml version="1.0" encoding="iso-8859-1"?> <?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-2012 by Derick Rethans]]></copyright></init> <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-2012 by Derick Rethans]]></copyright></init>


-> breakpoint_set -i 1 -t line -n 6 -f file:///tmp/xdebug-dbgp-test.php -> step_into -i 1
<?xml version="1.0" encoding="iso-8859-1"?> <?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="1" id=""></response> <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>


-> run -i 2 -> step_into -i 2
<?xml version="1.0" encoding="iso-8859-1"?> <?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="2" status="break" reason="ok"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="6"></xdebug:message></response> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="2" status="break" reason="ok"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="8"></xdebug:message></response>


-> stack_get -i 3 -> step_into -i 3
<?xml version="1.0" encoding="iso-8859-1"?> <?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="3"><stack where="Base::basetest" level="0" type="file" filename="file:///tmp/xdebug-dbgp-test.php" lineno="6"></stack><stack where="Test-&gt;test" level="1" type="file" filename="file:///tmp/xdebug-dbgp-test.php" lineno="12"></stack><stack where="{main}" level="2" type="file" filename="file:///tmp/xdebug-dbgp-test.php" lineno="16"></stack></response> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="3" status="break" reason="ok"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="16"></xdebug:message></response>


-> stack_get -i 4 -d 0 -> context_get -i 4 -d 0
<?xml version="1.0" encoding="iso-8859-1"?> <?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="4"><stack where="Base::basetest" level="0" type="file" filename="file:///tmp/xdebug-dbgp-test.php" lineno="6"></stack></response> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="4" context="0"><property name="::" fullname="::" type="object" classname="B" children="1" numchildren="1"></property></response>

-> context_get -i 5 -d 1
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="5" context="0"><property name="$this" fullname="$this" address="" type="object" classname="Test" children="1" numchildren="1" page="0" pagesize="32"><property name="property" fullname="$this::property" facet="static public" address="" type="bool"><![CDATA[1]]></property></property></response>

-> property_get -i 6 -d 1 -n $this
<?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="6"><property name="$this" fullname="$this" address="" type="object" classname="Test" children="1" numchildren="1" page="0" pagesize="32"><property name="property" fullname="$this::property" facet="static public" address="" type="bool"><![CDATA[1]]></property></property></response>

-> property_get -i 7 -d 1 -n $this::property
<?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="7"><property name="$this::property" fullname="$this::property" address="" type="bool"><![CDATA[1]]></property></response>

-> context_get -i 8 -d 0
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="8" context="0"><property name="::" fullname="::" type="object" classname="Base" children="1" numchildren="1"><property name="::property" fullname="::property" address="" type="bool" facet="static public"><![CDATA[1]]></property></property></response>

-> property_get -i 9 -d 0 -n ::
<?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="9" status="break" reason="ok"><error code="300"><message><![CDATA[can not get property]]></message></error></response>

-> property_get -i 10 -d 0 -n ::property
<?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="10"><property name="::property" fullname="::property" address="" type="bool"><![CDATA[1]]></property></response>
4 changes: 4 additions & 0 deletions xdebug_var.c
Expand Up @@ -1067,6 +1067,10 @@ void xdebug_attach_property_with_contents(zend_property_info *prop_info XDEBUG_Z
class_entry = va_arg(args, zend_class_entry *); class_entry = va_arg(args, zend_class_entry *);
class_name = va_arg(args, char *); class_name = va_arg(args, char *);


if ((prop_info->flags & ZEND_ACC_STATIC) == 0) {
return;
}

modifier = xdebug_get_property_info(prop_info->name, prop_info->name_length, &prop_name, &prop_class_name); modifier = xdebug_get_property_info(prop_info->name, prop_info->name_length, &prop_name, &prop_class_name);


if (strcmp(modifier, "private") != 0 || strcmp(class_name, prop_class_name) == 0) { if (strcmp(modifier, "private") != 0 || strcmp(class_name, prop_class_name) == 0) {
Expand Down

0 comments on commit cc7fd70

Please sign in to comment.