Xdebug Update: July 2019

  • You are here: Free PHP » Uncategorized » Xdebug Update: July 2019

Xdebug Update: July 2019

This is another of the monthly update reports in which I explain what happened with Xdebug development in this past month. It will be published on the first Tuesday after the 5th of each month. Patreon supporters will get it earlier, on the first of each month. You can become a patron here to support my work on Xdebug. More supporters, means that I can dedicate more of my time to improving Xdebug.

In July, I worked on Xdebug for about 20 hours, still a little bit less than normal due to holidays. I worked on the following things:

2.8.0beta1 Release

On July 25th, the same day that PHP 7.4.0beta1 was released, I made Xdebug's 2.8.0beta1 release. PHP 7.4 had changed some internal structures that required changes in Xdebug. You have to use the Xdebug 2.8.0beta1 release with PHP 7.4.0beta1.

This first beta release mainly makes Xdebug compatible again with PHP, but also addresses a bunch of issues that were reported, including a fix for Code Coverage collections, and a few issues related to obtaining the correct PID (Process Identifier) number for debugging. It also addresses an issue with NULL bytes and the DBGp protocol.

NULL bytes in the DBGp protocol

In PHP, it is possible to have NULL bytes in variable, key, and property names by using \0, such as in:

<?php $name = "with_\0_null_char";
$$name = 42;
??>

The DBGp protocol represents variable names through the name attribute of the property element in its XML format:

However, if a name has a NULL character, Xdebug would generate the following XML:

The problem is however, that XML does not allow for NULL bytes in attribute names. The above XML is therefore not well-formed. When the DBGp protocol was designed many many years ago, this issue was not thought off, and hence, the DBGp protocol could not represent these NULL bytes in variable, key, and property names. If you look at the first XML snippet (with name="$name"), then you can see that the DBGp protocol does handle this for the values. In this case, it added the encoding="base64" attribute, and encoded the string "with_\0_null_char" as d2l0aF8AX251bGxfY2hhcg==.

A while ago, for Xdebug 2.6, I addressed this problem by an update to the DBGp protocol to include extended properties. When the IDE enables this feature, Xdebug will then communicate names and values through a base64 encoded value in a sub-element, such as:

What I had failed to see is that it also possible that class names can have NULL characters in their name—when you use anonymous classes:

<?php $a = new class { };
var_dump( $a );
??>

This would still be communicated as:

The fix for issue #1682 fixes this, by checking whether either of name, value, or class name has an XML incompatible character. If that is the case, and the `extended_properties`` feature has been enabled by the IDE through the protocol, then Xdebug will communicate this value in the new format:

Truncated by Planet PHP, read more at the original (another 2298 bytes)

Powered by Gewgley