xdebug / vscode-php-debug

PHP Debug Adapter for Visual Studio Code 🐞⛔
MIT License
771 stars 176 forks source link

Content of DateTime objects not shown when debugging #820

Closed LuWey closed 2 years ago

LuWey commented 2 years ago

I already placed this issue over at bmewburn / vscode-intelephense, but I was told that debugging related issues belong to here.

This is the link to the issue with all screenshots: https://github.com/bmewburn/vscode-intelephense/issues/2275#issue-1324660230

PHP version: 7.4.27 Xdebug version: 2.8.1

See also: phpinfo.txt

VS Code extension version:

grafik

Your launch.json:

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [

    {
      "name": "Listen for XDebug",
      "stopOnEntry":false,
      "type": "php",
      "request": "launch",
      "port": 9000
    },
    {
      "name": "Launch currently open script",
      "stopOnEntry":false,
      "type": "php",
      "request": "launch",
      "program": "${file}",
      "cwd": "${fileDirname}",
      "port": 9000
    }
  ]
}

Xdebug php.ini config:

[XDebug]
zend_extension = "c:\xampp\php\ext\php_xdebug.dll"
;zend_extension = "c:\xampp\php\ext\php_xdebug-2.9.7-7.4-vc15-x86_64.dll"
xdebug.remote_autostart = 1
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "c:\xampp\tmp"
;xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.remote_log = "c:\xampp\tmp\xdebug.txt"
xdebug.remote_port = 9000
xdebug.trace_output_dir = "c:\xampp\tmp"
;36000 = 10h
xdebug.remote_cookie_expire_time = 36000

Xdebug logfile (from setting xdebug.log in php.ini):

When running this and hovering over print_r($TestDateTime);

grafik

Then this is the content of the xdebug logfile: xdebug.txt

VS Code extension logfile (from setting "log": true in launch.json): Don't have that setting

zobo commented 2 years ago

Will try to reproduce, but you are using quite an outdated version of Xdebug and well, PHP.

What I see is that Xdebug reports no children in the DateTime object.

[3088] <- context_get -i 13 -d 0 -c 0
[3088] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="13" context="0"><property name="$TestDateTime" fullname="$TestDateTime" type="object" classname="DateTime" children="0" numchildren="0" page="0" pagesize="100"></property></response>

This is how it looks on my setup:

xd(1) -> <?xml version="1.0" encoding="iso-8859-1"?><response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="20" context="0"><property name="$TestDateTime" fullname="$TestDateTime" type="object" classname="DateTime" children="1" numchildren="3" page="0" pagesize="100"><property name="date" fullname="$TestDateTime-&gt;date" facet="public" type="string" size="26" encoding="base64"><![CDATA[MjAyMi0wOC0wNCAxNToyNDoyNy44NTc1Mjg=]]></property><property name="timezone_type" fullname="$TestDateTime-&gt;timezone_type" facet="public" type="int"><![CDATA[3]]></property><property name="timezone" fullname="$TestDateTime-&gt;timezone" facet="public" type="string" size="3" encoding="base64"><![CDATA[VVRD]]></property></property></response>

PHP 8.1.2 Xdebug 3.2.0-dev

image

zobo commented 2 years ago

I tried it now with PHP 7.4.13 and Xdebug 2.9.5 and it also works.

However 2.8.1 does not work.

I suggest you upgrade to latest Xdebug 2 or even better to Xdebug 3, but watch for changes that happen between 2 and 3.

Best.

LuWey commented 2 years ago

Although I try to avoid changing a running system at all cost, I upgraded to Xdebug 3 and problem seems to be solved. Thank you for you support!