Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed bug #987: Hidden property names not shown.

  • Loading branch information...
commit 4d8d5b7092f134e6e5a51a0ea2e6932930a29da9 1 parent d0e1782
@derickr derickr authored
View
1  tests/bug00778.inc
@@ -4,4 +4,5 @@ $xml = '<?xml version="1.0" encoding="UTF-8" ?>
</root>';
$temp = simplexml_load_string($xml, "SimpleXMLElement", LIBXML_NOERROR);
echo "It works?";
+var_dump($temp);
?>
View
2  tests/bug00778.phpt
@@ -38,7 +38,7 @@ dbgpRun( $data, $commands );
-> context_get -i 5
<?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="$temp" fullname="$temp" address="" type="object" classname="SimpleXMLElement" children="1" numchildren="1" page="0" pagesize="32"></property><property name="$xml" fullname="$xml" address="" type="string" size="54" encoding="base64"><![CDATA[PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiID8+Cjxyb290Pgo8L3Jvb3Q+]]></property></response>
+<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="5" context="0"><property name="$temp" fullname="$temp" address="" type="object" classname="SimpleXMLElement" children="1" numchildren="1" page="0" pagesize="32"><property name="0" fullname="$temp-&gt;0" facet="public" address="" type="string" size="1" encoding="base64"><![CDATA[Cg==]]></property></property><property name="$xml" fullname="$xml" address="" type="string" size="54" encoding="base64"><![CDATA[PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiID8+Cjxyb290Pgo8L3Jvb3Q+]]></property></response>
-> detach -i 6
<?xml version="1.0" encoding="iso-8859-1"?>
View
23 tests/bug00987-001.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Test for bug #987: Hidden property names not shown with var_dump (CLI)
+--INI--
+html_errors=0
+xdebug.cli_color=0
+xdebug.default_enable=1
+--FILE--
+<?php
+$object = (object) array('key' => 'value', 1 => 0, -4 => "foo", 3.14 => false);
+
+var_dump($object);
+?>
+--EXPECTF--
+class stdClass#1 (4) {
+ public $key =>
+ string(5) "value"
+ public ${1} =>
+ int(0)
+ public ${-4} =>
+ string(3) "foo"
+ public ${3} =>
+ bool(false)
+}
View
20 tests/bug00987-002.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Test for bug #987: Hidden property names not shown with var_dump (HTML)
+--INI--
+html_errors=1
+xdebug.cli_color=0
+xdebug.default_enable=1
+--FILE--
+<?php
+$object = (object) array('key' => 'value', 1 => 0, -4 => "foo", 3.14 => false);
+
+var_dump($object);
+?>
+--EXPECTF--
+<pre class='xdebug-var-dump' dir='ltr'>
+<b>object</b>(<i>stdClass</i>)[<i>1</i>]
+ <i>public</i> 'key' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'value'</font> <i>(length=5)</i>
+ <i>public</i> 1 <font color='#888a85'>=&gt;</font> <small>int</small> <font color='#4e9a06'>0</font>
+ <i>public</i> -4 <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'foo'</font> <i>(length=3)</i>
+ <i>public</i> 3 <font color='#888a85'>=&gt;</font> <small>boolean</small> <font color='#75507b'>false</font>
+</pre>
View
23 tests/bug00987-003.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Test for bug #987: Hidden property names not shown with var_dump (CLI colours)
+--INI--
+html_errors=0
+xdebug.cli_color=2
+xdebug.default_enable=1
+--FILE--
+<?php
+$object = (object) array('key' => 'value', 1 => 0, -4 => "foo", 3.14 => false);
+
+var_dump($object);
+?>
+--EXPECTF--
+class stdClass#1 (4) {
+ public $key =>
+ string(5) "value"
+ public ${1} =>
+ int(0)
+ public ${-4} =>
+ string(3) "foo"
+ public ${3} =>
+ bool(false)
+}
View
25 tests/bug00987-004.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Test for bug #987: Hidden property names not shown with stack trace
+--INI--
+html_errors=0
+xdebug.cli_color=0
+xdebug.default_enable=1
+error_reporting=-1
+xdebug.collect_params=4
+xdebug.show_local_vars=0
+--FILE--
+<?php
+$object = (object) array('key' => 'value', 1 => 0, -4 => "foo", 3.14 => false);
+
+function foo($a, $b)
+{
+}
+
+foo($object);
+?>
+--EXPECTF--
+Warning: Missing argument 2 for foo(), called in %sbug00987-004.php on line 8 and defined in %sbug00987-004.php on line 4
+
+Call Stack:
+ %f %d 1. {main}() %sbug00987-004.php:0
+ %f %d 2. foo($a = class stdClass { public $key = 'value'; public $1 = 0; public $-4 = 'foo'; public $3 = FALSE }, $b = ???) %sbug00987-004.php:8
View
17 tests/bug00987-005.inc
@@ -0,0 +1,17 @@
+<?php
+$a = new StdClass;
+$a->foo = 1;
+$a->bar = 2;
+$a->baz = array( false, 3.14, "foo" );
+class b { static $foo = 73; }; $a->b = new b;
+$o = (object) array(
+ 'key' => 'value',
+ 1 => 0,
+ -4 => "foo",
+ 3.14 => false,
+ -2 => array( 5, 6, 7, 8 => array( "a", "b", "c" ) ),
+ 5 => $a,
+ );
+
+echo gettype($o), "\n";
+?>
View
85 tests/bug00987-005.phpt
@@ -0,0 +1,85 @@
+--TEST--
+Test for bug #987: Hidden property names not shown while debugging
+--FILE--
+<?php
+require 'dbgp/dbgpclient.php';
+$data = file_get_contents(dirname(__FILE__) . '/bug00987-005.inc');
+
+$commands = array(
+ 'step_into',
+ 'breakpoint_set -t line -n 16',
+ 'run',
+ 'property_get -n $o',
+ 'property_get -n $o->-4',
+ 'property_get -n $o->3',
+ 'property_get -n $o->-2[2]',
+ 'property_get -n $o->-2[8]',
+ 'property_get -n $o->-2[8]["c"]',
+ 'property_get -n $o->5',
+ 'property_get -n $o->5->bar',
+ 'property_get -n $o->5->baz[2]',
+ 'property_get -n $o->5->b',
+ 'property_get -n $o->5->b::foo',
+);
+
+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-2013 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 line -n 16
+<?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="16"></xdebug:message></response>
+
+-> property_get -i 4 -n $o
+<?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="$o" fullname="$o" address="" type="object" classname="stdClass" children="1" numchildren="6" page="0" pagesize="32"><property name="key" fullname="$o-&gt;key" facet="public" address="" type="string" size="5" encoding="base64"><![CDATA[dmFsdWU=]]></property><property name="1" fullname="$o-&gt;1" facet="public" address="" type="int"><![CDATA[0]]></property><property name="-4" fullname="$o-&gt;-4" facet="public" address="" type="string" size="3" encoding="base64"><![CDATA[Zm9v]]></property><property name="3" fullname="$o-&gt;3" facet="public" address="" type="bool"><![CDATA[0]]></property><property name="-2" fullname="$o-&gt;-2" facet="public" address="" type="array" children="1" numchildren="4"></property><property name="5" fullname="$o-&gt;5" facet="public" address="" type="object" classname="stdClass" children="1" numchildren="4"></property></property></response>
+
+-> property_get -i 5 -n $o->-4
+<?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="$o-&gt;-4" fullname="$o-&gt;-4" address="" type="string" size="3" encoding="base64"><![CDATA[Zm9v]]></property></response>
+
+-> property_get -i 6 -n $o->3
+<?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="$o-&gt;3" fullname="$o-&gt;3" address="" type="bool"><![CDATA[0]]></property></response>
+
+-> property_get -i 7 -n $o->-2[2]
+<?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="$o-&gt;-2[2]" fullname="$o-&gt;-2[2]" address="" type="int"><![CDATA[7]]></property></response>
+
+-> property_get -i 8 -n $o->-2[8]
+<?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="8"><property name="$o-&gt;-2[8]" fullname="$o-&gt;-2[8]" address="" type="array" children="1" numchildren="3" page="0" pagesize="32"><property name="0" fullname="$o-&gt;-2[8][0]" address="" type="string" size="1" encoding="base64"><![CDATA[YQ==]]></property><property name="1" fullname="$o-&gt;-2[8][1]" address="" type="string" size="1" encoding="base64"><![CDATA[Yg==]]></property><property name="2" fullname="$o-&gt;-2[8][2]" address="" type="string" size="1" encoding="base64"><![CDATA[Yw==]]></property></property></response>
+
+-> property_get -i 9 -n $o->-2[8]["c"]
+<?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 -n $o->5
+<?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="$o-&gt;5" fullname="$o-&gt;5" address="" type="object" classname="stdClass" children="1" numchildren="4" page="0" pagesize="32"><property name="foo" fullname="$o-&gt;5-&gt;foo" facet="public" address="" type="int"><![CDATA[1]]></property><property name="bar" fullname="$o-&gt;5-&gt;bar" facet="public" address="" type="int"><![CDATA[2]]></property><property name="baz" fullname="$o-&gt;5-&gt;baz" facet="public" address="" type="array" children="1" numchildren="3"></property><property name="b" fullname="$o-&gt;5-&gt;b" facet="public" address="" type="object" classname="b" children="1" numchildren="1"></property></property></response>
+
+-> property_get -i 11 -n $o->5->bar
+<?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="11"><property name="$o-&gt;5-&gt;bar" fullname="$o-&gt;5-&gt;bar" address="" type="int"><![CDATA[2]]></property></response>
+
+-> property_get -i 12 -n $o->5->baz[2]
+<?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="12"><property name="$o-&gt;5-&gt;baz[2]" fullname="$o-&gt;5-&gt;baz[2]" address="" type="string" size="3" encoding="base64"><![CDATA[Zm9v]]></property></response>
+
+-> property_get -i 13 -n $o->5->b
+<?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="13"><property name="$o-&gt;5-&gt;b" fullname="$o-&gt;5-&gt;b" address="" type="object" classname="b" children="1" numchildren="1" page="0" pagesize="32"><property name="foo" fullname="$o-&gt;5-&gt;b::foo" facet="static public" address="" type="int"><![CDATA[73]]></property></property></response>
+
+-> property_get -i 14 -n $o->5->b::foo
+<?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="14"><property name="$o-&gt;5-&gt;b::foo" fullname="$o-&gt;5-&gt;b::foo" address="" type="int"><![CDATA[73]]></property></response>
View
23 tests/bug00987-006.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Test for bug #987: Hidden property names not shown with var_dump
+--INI--
+html_errors=0
+xdebug.cli_color=0
+xdebug.default_enable=1
+error_reporting=-1
+xdebug.collect_params=4
+xdebug.show_local_vars=0
+--FILE--
+<?php
+$xml = '<?xml version="1.0" encoding="UTF-8" ?>
+<root>
+</root>';
+$temp = simplexml_load_string($xml, "SimpleXMLElement", LIBXML_NOERROR);
+var_dump($temp);
+?>
+--EXPECTF--
+class SimpleXMLElement#1 (1) {
+ public ${0} =>
+ string(1) "
+"
+}
View
4 xdebug_handler_dbgp.c
@@ -452,7 +452,7 @@ static zval* fetch_zval_from_symbol_table(HashTable *ht, char* name, int name_le
/* First we try a public property */
element = prepare_search_key(name, &element_length, "", 0);
- if (ht && zend_hash_find(ht, element, element_length + 1, (void **) &retval_pp) == SUCCESS) {
+ if (ht && zend_symtable_find(ht, element, element_length + 1, (void **) &retval_pp) == SUCCESS) {
retval_p = *retval_pp;
goto cleanup;
}
@@ -599,7 +599,7 @@ static zval* get_symbol_contents_zval(char* name, int name_length TSRMLS_DC)
state = 1;
}
break;
- case 3:
+ case 3: /* Parsing in [...] */
/* Associative arrays */
if (*p[0] == '\'' || *p[0] == '"') {
state = 4;
View
31 xdebug_var.c
@@ -355,6 +355,8 @@ static int xdebug_object_element_export(zval **zv XDEBUG_ZEND_HASH_APPLY_TSRMLS_
} else {
xdebug_str_add(str, xdebug_sprintf("%s ${%s}:%s = ", modifier, prop_class_name, prop_name), 1);
}
+ } else {
+ xdebug_str_add(str, xdebug_sprintf("public $%d = ", hash_key->h), 1);
}
xdebug_var_export(zv, str, level + 2, debug_zval, options TSRMLS_CC);
xdebug_str_addl(str, "; ", 2, 0);
@@ -665,6 +667,10 @@ static int xdebug_object_element_export_text_ansi(zval **zv XDEBUG_ZEND_HASH_APP
xdebug_str_add(str, xdebug_sprintf("%s%s%s%s%s $%s %s=>%s\n",
ANSI_COLOR_MODIFIER, ANSI_COLOR_BOLD, modifier, ANSI_COLOR_BOLD_OFF, ANSI_COLOR_RESET,
prop_name, ANSI_COLOR_POINTER, ANSI_COLOR_RESET), 1);
+ } else {
+ xdebug_str_add(str, xdebug_sprintf("%s%spublic%s%s ${%d} %s=>%s\n",
+ ANSI_COLOR_MODIFIER, ANSI_COLOR_BOLD, ANSI_COLOR_BOLD_OFF, ANSI_COLOR_RESET,
+ hash_key->h, ANSI_COLOR_POINTER, ANSI_COLOR_RESET), 1);
}
xdebug_var_export_text_ansi(zv, str, mode, level + 1, debug_zval, options TSRMLS_CC);
}
@@ -912,6 +918,7 @@ typedef struct
char type;
char *name;
int name_len;
+ ulong index;
zval *zv;
} xdebug_object_item;
@@ -929,6 +936,7 @@ static int object_item_add_to_merged_hash(zval **zv XDEBUG_ZEND_HASH_APPLY_TSRML
item->zv = *zv;
item->name = (char *) hash_key->arKey;
item->name_len = hash_key->nKeyLength;
+ item->index = hash_key->h;
zend_hash_next_index_insert(merged, &item, sizeof(xdebug_object_item*), NULL);
@@ -1044,9 +1052,11 @@ static int xdebug_object_element_export_xml_node(xdebug_object_item **item XDEBU
if (options->runtime[level].current_element_nr >= options->runtime[level].start_element_nr &&
options->runtime[level].current_element_nr < options->runtime[level].end_element_nr)
{
+ node = xdebug_xml_node_init("property");
+
if ((*item)->name_len != 0) {
modifier = xdebug_get_property_info((*item)->name, (*item)->name_len, &prop_name, &prop_class_name);
- node = xdebug_xml_node_init("property");
+
if (strcmp(modifier, "private") != 0 || strcmp(class_name, prop_class_name) == 0) {
xdebug_xml_add_attribute_ex(node, "name", xdstrdup(prop_name), 0, 1);
} else {
@@ -1061,14 +1071,21 @@ static int xdebug_object_element_export_xml_node(xdebug_object_item **item XDEBU
}
xdebug_xml_add_attribute_ex(node, "fullname", full_name, 0, 1);
}
- xdebug_xml_add_attribute_ex(node, "facet", xdebug_sprintf("%s%s", (*item)->type == XDEBUG_OBJECT_ITEM_TYPE_STATIC_PROPERTY ? "static " : "", modifier), 0, 1);
-
- xdebug_xml_add_attribute_ex(node, "address", xdebug_sprintf("%ld", (long) (*item)->zv), 0, 1);
+ } else { /* Numerical property name */
+ modifier = "public";
- xdebug_xml_add_child(parent, node);
+ xdebug_xml_add_attribute_ex(node, "name", xdebug_sprintf("%ld", (*item)->index), 0, 1);
- xdebug_var_export_xml_node(&((*item)->zv), full_name, node, options, level + 1 TSRMLS_CC);
+ if (parent_name) {
+ full_name = xdebug_sprintf("%s%s%ld", parent_name, (*item)->type == XDEBUG_OBJECT_ITEM_TYPE_STATIC_PROPERTY ? "::" : "->", (*item)->index);
+ xdebug_xml_add_attribute_ex(node, "fullname", full_name, 0, 1);
+ }
}
+
+ xdebug_xml_add_attribute_ex(node, "facet", xdebug_sprintf("%s%s", (*item)->type == XDEBUG_OBJECT_ITEM_TYPE_STATIC_PROPERTY ? "static " : "", modifier), 0, 1);
+ xdebug_xml_add_attribute_ex(node, "address", xdebug_sprintf("%ld", (long) (*item)->zv), 0, 1);
+ xdebug_xml_add_child(parent, node);
+ xdebug_var_export_xml_node(&((*item)->zv), full_name, node, options, level + 1 TSRMLS_CC);
}
options->runtime[level].current_element_nr++;
return 0;
@@ -1456,6 +1473,8 @@ static int xdebug_object_element_export_fancy(zval **zv XDEBUG_ZEND_HASH_APPLY_T
} else {
xdebug_str_add(str, xdebug_sprintf("<i>%s</i> '%s' <small>(%s)</small> <font color='%s'>=&gt;</font> ", modifier, prop_name, prop_class_name, COLOR_POINTER), 1);
}
+ } else {
+ xdebug_str_add(str, xdebug_sprintf("<i>public</i> %d <font color='%s'>=&gt;</font> ", hash_key->h, COLOR_POINTER), 1);
}
xdebug_var_export_fancy(zv, str, level + 1, debug_zval, options TSRMLS_CC);
}
Please sign in to comment.
Something went wrong with that request. Please try again.