Permalink
Browse files

Merge branch 'xdebug_2_5'

  • Loading branch information...
2 parents 69afb44 + 49bca0d commit 2fab54c52b4ddcb7592c237ae7d383f2b5da1801 @derickr derickr committed Jan 8, 2017
Showing with 94 additions and 7 deletions.
  1. +3 −0 tests/bug01073.phpt
  2. +22 −0 tests/bug01385.inc
  3. +42 −0 tests/bug01385.phpt
  4. +12 −3 tests/dbgp/dbgpclient.php
  5. +15 −4 xdebug_var.c
View
@@ -9,6 +9,9 @@ xdebug.collect_vars=0
xdebug.collect_params=4
xdebug.collect_return=0
xdebug.collect_assignments=0
+xdebug.var_display_max_children=128
+xdebug.var_display_max_data=512
+xdebug.var_display_max_depth=3
--FILE--
<?php
$tf = xdebug_start_trace(sys_get_temp_dir() . '/'. uniqid('xdt', TRUE));
View
@@ -0,0 +1,22 @@
+<?php
+$v = "";
+
+class Foo
+{
+ private $a;
+ public function __construct($a) {
+ $this->a = $a;
+ }
+}
+class Bar extends Foo
+{
+ public $a;
+ public function __construct($fooA, $a) {
+ parent::__construct($fooA);
+ $this->a = $a;
+ }
+}
+
+$v = new Foo(new Bar(new Foo(new Foo(2)), 1));
+
+var_dump($v); // breakpoint
View
@@ -0,0 +1,42 @@
+--TEST--
+Test for bug #1385: Can not fetch IS_INDIRECT private properties
+--SKIPIF--
+<?php if (getenv("SKIP_DBGP_TESTS")) { exit("skip Excluding DBGp tests"); } ?>
+--FILE--
+<?php
+require 'dbgp/dbgpclient.php';
+$data = file_get_contents(dirname(__FILE__) . '/bug01385.inc');
+
+$commands = array(
+ 'step_into',
+ 'breakpoint_set -t line -n 22',
+ 'run',
+ 'property_get -d 0 -c 0 -n $v->a->*Foo*a->a',
+ 'property_get -d 0 -c 0 -n $v->a->a'
+);
+
+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:///%sxdebug-dbgp-test.php" language="PHP" xdebug:language_version="" 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-%d 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:///%sxdebug-dbgp-test.php" lineno="2"></xdebug:message></response>
+
+-> breakpoint_set -i 2 -t line -n 22
+<?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:///%sxdebug-dbgp-test.php" lineno="22"></xdebug:message></response>
+
+-> property_get -i 4 -d 0 -c 0 -n $v->a->*Foo*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="4"><property name="$v-&gt;a-&gt;*Foo*a-&gt;a" fullname="$v-&gt;a-&gt;*Foo*a-&gt;a" type="object" classname="Foo" children="1" numchildren="1" page="0" pagesize="32"><property name="a" fullname="$v-&gt;a-&gt;*Foo*a-&gt;a-&gt;a" facet="private" type="int"><![CDATA[2]]></property></property></response>
+
+-> property_get -i 5 -d 0 -c 0 -n $v->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"><property name="$v-&gt;a-&gt;a" fullname="$v-&gt;a-&gt;a" type="int"><![CDATA[1]]></property></response>
@@ -4,7 +4,8 @@
class DebugClient
{
- protected $port = 9991;
+ // free port will be selected automatically by the operating system
+ protected $port = 0;
private $tmpDir;
@@ -33,9 +34,15 @@ public function __construct()
$this->tmpDir = sys_get_temp_dir();
}
- private function open()
+ private function open( &$errno, &$errstr )
{
$socket = @stream_socket_server( $this->getAddress(), $errno, $errstr );
+ if ( $socket )
+ {
+ $name = stream_socket_get_name( $socket, false );
+ $name = explode( ":", $name );
+ $this->port = array_pop( $name );
+ }
return $socket;
}
@@ -106,10 +113,12 @@ function runTest( $data, array $commands, array $ini_options = null )
{
file_put_contents( $this->tmpDir . '/xdebug-dbgp-test.php', $data );
$i = 1;
- $socket = $this->open();
+ $socket = $this->open( $errno, $errstr );
if ( $socket === false )
{
echo "Could not create socket server - already in use?\n";
+ echo "Error: {$errstr}, errno: {$errno}\n";
+ echo "Address: {$this->getAddress()}\n";
return;
}
$php = $this->launchPhp( $ppipes, $ini_options );
View
@@ -177,10 +177,6 @@ zval *xdebug_get_zval(zend_execute_data *zdata, int node_type, const znode_op *n
inline static HashTable *fetch_ht_from_zval(zval *z TSRMLS_DC)
{
- if (Z_TYPE_P(z) == IS_REFERENCE) {
- z = &z->value.ref->val;
- }
-
switch (Z_TYPE_P(z)) {
case IS_ARRAY:
return Z_ARRVAL_P(z);
@@ -196,6 +192,13 @@ inline static char *fetch_classname_from_zval(zval *z, int *length, zend_class_e
{
zend_string *class_name;
+ if (Z_TYPE_P(z) == IS_INDIRECT) {
+ z = z->value.zv;
+ }
+ if (Z_TYPE_P(z) == IS_REFERENCE) {
+ z = &z->value.ref->val;
+ }
+
if (Z_TYPE_P(z) != IS_OBJECT) {
return NULL;
}
@@ -285,6 +288,13 @@ static zval* fetch_zval_from_symbol_table(zval *parent, char* name, unsigned int
HashTable *myht;
if (parent) {
+ if (Z_TYPE_P(parent) == IS_INDIRECT) {
+ parent = parent->value.zv;
+ }
+ if (Z_TYPE_P(parent) == IS_REFERENCE) {
+ parent = &parent->value.ref->val;
+ }
+
ht = fetch_ht_from_zval(parent TSRMLS_CC);
}
@@ -469,6 +479,7 @@ static zval* fetch_zval_from_symbol_table(zval *parent, char* name, unsigned int
if (element) {
free(element);
}
+
return retval_p;
}

0 comments on commit 2fab54c

Please sign in to comment.