1

I'm having an issue with Visual Studio Code and Xdebug.

My System:

I'm using a Windows 10 system with IIS webserver and PHP version 7.4. I've downloaded and installed Xdebug with the last version (2.9.0) successfully (see the excerpt from the php.ini below). Visual Studio Code is configured for using Xdebug (see launch.json file below).

My issue is:

When I set a breakpoint, it stops at this breakpoint. So far so good. But if I press then "Step into" (F11) or "Step over" (F10) buttons, nothing is happening at all. The initial breakpoint is still highlighted - it stays at the breakpoint.

enter image description here

Maybe something is configured wrong, but actually I can't figure out what it is.

See here the configuration files:

php.ini:

[XDEBUG]
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = localhost
xdebug.remote_port = 9000
xdebug.remote_autostart = 1
xdebug.idekey=VSCODE
xdebug.remote_log ="C:\temp\xdebug.log"

[PHP_XDEBUG-2.9.0-7.4-VC15-NTS]
zend_extension = "C:\Program Files (x86)\PHP\v7.4\ext\php_xdebug-2.9.0-7.4-vc15-nts-x86_64.dll"

launch.json of Visual Studio Code:

{
    // Verwendet IntelliSense zum Ermitteln möglicher Attribute.
    // Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen.
    // Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000,
            "ignore": [
                "**/vendor/**/*.php"
            ]
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000
        }
    ]
}
7
  • 1
    Make a log by setting in php.ini: xdebug.remote_log=/tmp/xdebug.org, and then tail -f /tmp/xdebug.org it to see what happens on the wire.
    – Derick
    Commented Jan 15, 2020 at 9:59
  • 1
    Many thanks. That helped to figure out the problem. The issue was, that there were breakpoints on deleted files.
    – dns_nx
    Commented Jan 15, 2020 at 10:43
  • 1
    That shouldn't cause a problem though. What happened in your log? (Or can you share it, while pointing out where it went wrong through bugs.xdebug.org )
    – Derick
    Commented Jan 15, 2020 at 14:09
  • 1
    File a bug report with the log attached at bugs.xdebug.org then, so we can have a check whether it's not a bug in Xdebug.
    – Derick
    Commented Jan 17, 2020 at 11:42
  • 1
    @Derick I've created a bug report there. ID 0001735
    – dns_nx
    Commented Jan 17, 2020 at 12:29

1 Answer 1

3

This turned out to be a bug in Xdebug, which would happen when the following points are all true:

  • An error handler converted a warning/notice into an Exception
  • An exception breakpoint was set on this specific Exception, or a wild card exception breakpoint was set
  • The DBGp eval command, which IDEs often use to implement watches, created a warning or notice, in this case, due to an undefined variable.

The cause was that although the eval command turns of breakpoints with a breakpoints_allowed flag until it has been run, the breakpoint handler for exceptions did not check whether this breakpoints_allowed flag was actually set.

The fix is to check for the breakpoints_allowed flag in the handler for exception breakpoints, and will be part of the upcoming Xdebug 2.9.2 release. If you don't want to wait, download Xdebug from Github and make sure to use the xdebug_2_9 branch (unless you want to go really experimental).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.