Skip to content

Commit 6ef869c

Browse files
committed
Merged pull request xdebug#999
2 parents 0dd42ea + 6e1701d commit 6ef869c

File tree

5 files changed

+80
-5
lines changed

5 files changed

+80
-5
lines changed

src/debugger/handler_dbgp.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
+----------------------------------------------------------------------+
33
| Xdebug |
44
+----------------------------------------------------------------------+
5-
| Copyright (c) 2002-2023 Derick Rethans |
5+
| Copyright (c) 2002-2025 Derick Rethans |
66
+----------------------------------------------------------------------+
77
| This source file is subject to version 1.01 of the Xdebug license, |
88
| that is bundled with this package in the file LICENSE, and is |
@@ -2982,8 +2982,8 @@ int xdebug_dbgp_user_notify(xdebug_con *context, zend_string *filename, long lin
29822982
xdebug_xml_add_attribute(response, "xmlns:xdebug", "https://xdebug.org/dbgp/xdebug");
29832983
xdebug_xml_add_attribute(response, "name", "user");
29842984

2985-
options = (xdebug_var_export_options*) context->options;
2986-
options->encode_as_extended_property = 0;
2985+
options = xdebug_var_export_options_from_ini();
2986+
options->extended_properties = 1;
29872987

29882988
location_node = xdebug_xml_node_init("xdebug:location");
29892989
if (filename) {
@@ -3007,6 +3007,8 @@ int xdebug_dbgp_user_notify(xdebug_con *context, zend_string *filename, long lin
30073007

30083008
send_message(context, response);
30093009
xdebug_xml_node_dtor(response);
3010+
xdfree(options->runtime);
3011+
xdfree(options);
30103012

30113013
return 1;
30123014
}

src/lib/var.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ xdebug_var_export_options* xdebug_var_export_options_from_ini(void)
971971
options->max_depth = 0;
972972
}
973973

974-
options->runtime = (xdebug_var_runtime_page*) xdmalloc((options->max_depth + 1) * sizeof(xdebug_var_runtime_page));
974+
options->runtime = (xdebug_var_runtime_page*) xdcalloc((options->max_depth + 1), sizeof(xdebug_var_runtime_page));
975975
options->no_decoration = 0;
976976

977977
return options;

tests/debugger/xdebug_notify-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ $commands = array(
1717
'detach',
1818
);
1919

20-
dbgpRunFile( $filename, $commands );
20+
dbgpRunFile( $filename, $commands, [ 'xdebug.var_display_max_children' => 32 ] );
2121
?>
2222
--EXPECTF--
2323
<?xml version="1.0" encoding="iso-8859-1"?>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
--TEST--
2+
xdebug_notify() with custom settings
3+
--SKIPIF--
4+
<?php
5+
require __DIR__ . '/../utils.inc';
6+
check_reqs('dbgp');
7+
?>
8+
--FILE--
9+
<?php
10+
require 'dbgp/dbgpclient.php';
11+
$filename = dirname(__FILE__) . '/xdebug_notify_complex.inc';
12+
13+
$commands = array(
14+
'feature_set -n notify_ok -v 1',
15+
'feature_set -n extended_properties -v 1',
16+
'run',
17+
'detach',
18+
);
19+
20+
dbgpRunFile( $filename, $commands, [ 'xdebug.var_display_max_depth' => 1, 'xdebug.var_display_max_children' => 4, 'xdebug.var_display_max_data' => 4 ] );
21+
?>
22+
--EXPECTF--
23+
<?xml version="1.0" encoding="iso-8859-1"?>
24+
<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file://xdebug_notify_complex.inc" language="PHP" xdebug:language_version="" protocol_version="1.0" appid=""><engine version=""><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2099 by Derick Rethans]]></copyright></init>
25+
26+
-> feature_set -i 1 -n notify_ok -v 1
27+
<?xml version="1.0" encoding="iso-8859-1"?>
28+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="notify_ok" success="1"></response>
29+
30+
-> feature_set -i 2 -n extended_properties -v 1
31+
<?xml version="1.0" encoding="iso-8859-1"?>
32+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="extended_properties" success="1"></response>
33+
34+
-> run -i 3
35+
<?xml version="1.0" encoding="iso-8859-1"?>
36+
<notify xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" name="user"><xdebug:location filename="file://xdebug_notify_complex.inc" lineno="20"></xdebug:location><property type="array" children="1" numchildren="3" page="0" pagesize="4"><property name="0" type="array" children="1" numchildren="1"></property><property name="1" type="array" children="1" numchildren="1"></property><property name="2" type="array" children="1" numchildren="1"></property></property></notify>
37+
38+
<?xml version="1.0" encoding="iso-8859-1"?>
39+
<notify xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" name="user"><xdebug:location filename="file://xdebug_notify_complex.inc" lineno="20"></xdebug:location><property type="array" children="1" numchildren="3" page="0" pagesize="2"><property name="0" type="array" children="1" numchildren="1" page="0" pagesize="2"><property name="two" fullname="[&quot;two&quot;]" type="array" children="1" numchildren="1"></property></property><property name="1" type="array" children="1" numchildren="1" page="0" pagesize="2"><property name="long_string" fullname="[&quot;long_string&quot;]" type="string" size="1024" encoding="base64"><![CDATA[YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE=]]></property></property></property></notify>
40+
41+
<?xml version="1.0" encoding="iso-8859-1"?>
42+
<notify xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" name="user"><xdebug:location filename="file://xdebug_notify_complex.inc" lineno="20"></xdebug:location><property type="array" children="1" numchildren="3" page="0" pagesize="2"><property name="0" type="array" children="1" numchildren="1" page="0" pagesize="2"><property name="two" fullname="[&quot;two&quot;]" type="array" children="1" numchildren="1" page="0" pagesize="2"><property name="trois" fullname="[&quot;two&quot;][&quot;trois&quot;]" type="array" children="1" numchildren="1" page="0" pagesize="2"><property name="0" fullname="[&quot;two&quot;][&quot;trois&quot;][0]" type="string" size="3" encoding="base64"><![CDATA[YmFy]]></property></property></property></property><property name="1" type="array" children="1" numchildren="1" page="0" pagesize="2"><property name="long_string" fullname="[&quot;long_string&quot;]" type="string" size="1024" encoding="base64"><![CDATA[YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE=]]></property></property></property></notify>
43+
44+
<?xml version="1.0" encoding="iso-8859-1"?>
45+
<notify xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" name="user"><xdebug:location filename="file://xdebug_notify_complex.inc" lineno="20"></xdebug:location><property type="array" children="1" numchildren="3" page="0" pagesize="16"><property name="0" type="array" children="1" numchildren="1" page="0" pagesize="16"><property name="two" fullname="[&quot;two&quot;]" type="array" children="1" numchildren="1" page="0" pagesize="16"><property name="trois" fullname="[&quot;two&quot;][&quot;trois&quot;]" type="array" children="1" numchildren="1" page="0" pagesize="16"><property name="0" fullname="[&quot;two&quot;][&quot;trois&quot;][0]" type="string" size="3" encoding="base64"><![CDATA[YmFy]]></property></property></property></property><property name="1" type="array" children="1" numchildren="1" page="0" pagesize="16"><property name="long_string" fullname="[&quot;long_string&quot;]" type="string" size="1024" encoding="base64"><![CDATA[YWFhYQ==]]></property></property><property name="2" type="array" children="1" numchildren="1" page="0" pagesize="16"><property name="letters" fullname="[&quot;letters&quot;]" type="array" children="1" numchildren="24" page="0" pagesize="16"><property name="0" fullname="[&quot;letters&quot;][0]" type="string" size="1" encoding="base64"><![CDATA[YQ==]]></property><property name="1" fullname="[&quot;letters&quot;][1]" type="string" size="1" encoding="base64"><![CDATA[Yg==]]></property><property name="2" fullname="[&quot;letters&quot;][2]" type="string" size="1" encoding="base64"><![CDATA[Yw==]]></property><property name="3" fullname="[&quot;letters&quot;][3]" type="string" size="1" encoding="base64"><![CDATA[ZA==]]></property><property name="4" fullname="[&quot;letters&quot;][4]" type="string" size="1" encoding="base64"><![CDATA[ZQ==]]></property><property name="5" fullname="[&quot;letters&quot;][5]" type="string" size="1" encoding="base64"><![CDATA[Zg==]]></property><property name="6" fullname="[&quot;letters&quot;][6]" type="string" size="1" encoding="base64"><![CDATA[Zw==]]></property><property name="7" fullname="[&quot;letters&quot;][7]" type="string" size="1" encoding="base64"><![CDATA[aA==]]></property><property name="8" fullname="[&quot;letters&quot;][8]" type="string" size="1" encoding="base64"><![CDATA[aQ==]]></property><property name="9" fullname="[&quot;letters&quot;][9]" type="string" size="1" encoding="base64"><![CDATA[ag==]]></property><property name="10" fullname="[&quot;letters&quot;][10]" type="string" size="1" encoding="base64"><![CDATA[aw==]]></property><property name="11" fullname="[&quot;letters&quot;][11]" type="string" size="1" encoding="base64"><![CDATA[bA==]]></property><property name="12" fullname="[&quot;letters&quot;][12]" type="string" size="1" encoding="base64"><![CDATA[bQ==]]></property><property name="13" fullname="[&quot;letters&quot;][13]" type="string" size="1" encoding="base64"><![CDATA[bg==]]></property><property name="14" fullname="[&quot;letters&quot;][14]" type="string" size="1" encoding="base64"><![CDATA[bw==]]></property><property name="15" fullname="[&quot;letters&quot;][15]" type="string" size="1" encoding="base64"><![CDATA[cA==]]></property></property></property></property></notify>
46+
47+
<?xml version="1.0" encoding="iso-8859-1"?>
48+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="3" status="stopping" reason="ok"></response>
49+
50+
-> detach -i 4
51+
<?xml version="1.0" encoding="iso-8859-1"?>
52+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="detach" transaction_id="4" status="stopping" reason="ok"></response>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
$test = [
3+
[ 'two' => [ 'trois' => [ 'bar' ] ] ],
4+
[ 'long_string' => str_repeat( 'a', 1024 ) ],
5+
[ 'letters' => range( 'a', 'x' ) ],
6+
];
7+
8+
$settings = [
9+
[], // use default passed on command line
10+
[ 'xdebug.var_display_max_depth' => 2, 'xdebug.var_display_max_children' => 2, 'xdebug.var_display_max_data' => 32 ],
11+
[ 'xdebug.var_display_max_depth' => -1, 'xdebug.var_display_max_children' => 2, 'xdebug.var_display_max_data' => 32 ],
12+
[ 'xdebug.var_display_max_depth' => -1, 'xdebug.var_display_max_children' => 16, 'xdebug.var_display_max_data' => 4 ],
13+
];
14+
15+
foreach ($settings as $setting_group) {
16+
foreach ($setting_group as $setting => $value) {
17+
ini_set($setting, $value);
18+
}
19+
20+
xdebug_notify($test);
21+
}

0 commit comments

Comments
 (0)