Skip to content

Commit

Permalink
Merged pull request #224
Browse files Browse the repository at this point in the history
  • Loading branch information
derickr committed Nov 13, 2015
2 parents ff89803 + df4c8ac commit 9b5f00f
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -9,7 +9,7 @@ php:
- 7.0

before_script:
- if [ "$TRAVIS_PHP_VERSION" == 'nightly' -o "$TRAVIS_PHP_VERSION" == 7.0 ]; then echo "Not removing xdebug.ini"; else phpenv config-rm xdebug.ini; fi
- if [ "$TRAVIS_PHP_VERSION" == 'nightly' ]; then echo "Not removing xdebug.ini"; else phpenv config-rm xdebug.ini; fi
- ./.travis.scripts/compile.sh

notifications:
Expand Down
48 changes: 48 additions & 0 deletions tests/bug01203.phpt
@@ -0,0 +1,48 @@
--TEST--
Test for bug #1203: Accessing static property of a class that has no static properties crashes while remote debugging
--SKIPIF--
<?php if (!version_compare(phpversion(), "7.0", '>=')) echo "skip >= PHP 7.0 needed\n"; ?>
<?php if (getenv("SKIP_DBGP_TESTS")) { exit("skip Excluding DBGp tests"); } ?>
--FILE--
<?php
require 'dbgp/dbgpclient.php';
$data = file_get_contents(dirname(__FILE__) . '/bug01202.inc');

$commands = array(
'step_into',
'step_into',
'context_get',
'property_get -n $a',
'property_get -n $a::a',
'detach',
);

dbgpRun( $data, $commands );
?>
--EXPECT--
<?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>

-> step_into -i 2
<?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="2" status="break" reason="ok"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="9"></xdebug:message></response>

-> context_get -i 3
<?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="3" context="0"><property name="$a" fullname="$a" address="" type="object" classname="class@anonymous" children="1" numchildren="1" page="0" pagesize="32"><property name="a" fullname="$a-&gt;a" facet="public" address="" type="int"><![CDATA[42]]></property></property></response>

-> property_get -i 4 -n $a
<?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="$a" fullname="$a" address="" type="object" classname="class@anonymous" children="1" numchildren="1" page="0" pagesize="32"><property name="a" fullname="$a-&gt;a" facet="public" address="" type="int"><![CDATA[42]]></property></property></response>

-> property_get -i 5 -n $a::a
<?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" status="break" reason="ok"><error code="300"><message><![CDATA[can not get property]]></message></error></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>
12 changes: 4 additions & 8 deletions xdebug_code_coverage.c
Expand Up @@ -526,11 +526,8 @@ static void prefill_from_opcode(char *fn, zend_op opcode, int deadcode TSRMLS_DC
}
}

#if PHP_VERSION_ID >= 70000
static zend_brk_cont_element* xdebug_find_brk_cont(int nest_levels, int array_offset, zend_op_array *op_array)
#else
#if PHP_VERSION_ID < 70000
static zend_brk_cont_element* xdebug_find_brk_cont(zend_uint nest_levels, int array_offset, zend_op_array *op_array)
#endif
{
zend_brk_cont_element *jmp_to;

Expand All @@ -544,6 +541,7 @@ static zend_brk_cont_element* xdebug_find_brk_cont(zend_uint nest_levels, int ar
} while (--nest_levels > 0);
return jmp_to;
}
#endif

#define XDEBUG_ZNODE_ELEM(node,var) node.var
#if ZEND_USE_ABS_JMP_ADDR
Expand Down Expand Up @@ -587,6 +585,7 @@ static int xdebug_find_jump(zend_op_array *opa, unsigned int position, long *jmp
#endif
*jmp2 = opcode.extended_value;
return 1;
#if PHP_VERSION_ID < 70000
} else if (opcode.opcode == ZEND_BRK || opcode.opcode == ZEND_CONT) {
zend_brk_cont_element *el;

Expand All @@ -595,11 +594,7 @@ static int xdebug_find_jump(zend_op_array *opa, unsigned int position, long *jmp
&& XDEBUG_ZNODE_ELEM(opcode.op1, jmp_addr) != (zend_op*) 0xFFFFFFFF
#endif
) {
#if PHP_VERSION_ID >= 70000
el = xdebug_find_brk_cont(Z_LVAL_P(RT_CONSTANT_EX(opa, opcode.op2)), XDEBUG_ZNODE_ELEM(opcode.op1, opline_num), opa);
#else
el = xdebug_find_brk_cont(Z_LVAL_P(opcode.op2.zv), XDEBUG_ZNODE_ELEM(opcode.op1, opline_num), opa);
#endif
if (el) {
*jmp1 = opcode.opcode == ZEND_BRK ? el->brk : el->cont;
return 1;
Expand All @@ -608,6 +603,7 @@ static int xdebug_find_jump(zend_op_array *opa, unsigned int position, long *jmp
return 0;
}
}
#endif
#if PHP_VERSION_ID >= 70000
} else if (opcode.opcode == ZEND_FE_RESET_R || opcode.opcode == ZEND_FE_RESET_RW || opcode.opcode == ZEND_FE_FETCH_R || opcode.opcode == ZEND_FE_FETCH_RW) {
#else
Expand Down
11 changes: 10 additions & 1 deletion xdebug_stack.c
Expand Up @@ -1070,7 +1070,16 @@ static void xdebug_build_fname(xdebug_func *tmp, zend_execute_data *edata TSRMLS
if (edata->This.value.obj) {
tmp->type = XFUNC_MEMBER;
if (edata->func->common.scope) {
tmp->class = xdstrdup(edata->func->common.scope->name->val);
if (strcmp(edata->func->common.scope->name->val, "class@anonymous") == 0) {
tmp->class = xdebug_sprintf(
"{anonymous-class:%s:%d-%d}",
edata->func->common.scope->info.user.filename->val,
edata->func->common.scope->info.user.line_start,
edata->func->common.scope->info.user.line_end
);
} else {
tmp->class = xdstrdup(edata->func->common.scope->name->val);
}
} else {
tmp->class = xdstrdup(edata->This.value.obj->ce->name->val);
}
Expand Down
2 changes: 1 addition & 1 deletion xdebug_var.c
Expand Up @@ -383,7 +383,7 @@ static zval* fetch_zval_from_symbol_table(zval *parent, char* name, unsigned int
/* First we try a public,private,protected property */
element = prepare_search_key(name, &element_length, "", 0);
#if PHP_VERSION_ID >= 70000
if (cce && &cce->properties_info && ((zpp = zend_hash_str_find_ptr(&cce->properties_info, element, element_length)) != NULL)) {
if (cce && &cce->properties_info && ((zpp = zend_hash_str_find_ptr(&cce->properties_info, element, element_length)) != NULL) && cce->static_members_table) {
retval_p = &cce->static_members_table[zpp->offset];
#else
if (cce && &cce->properties_info && zend_hash_find(&cce->properties_info, element, element_length + 1, (void **) &zpp) == SUCCESS) {
Expand Down

0 comments on commit 9b5f00f

Please sign in to comment.