Mads
Mads

Reputation: 75

Xdebug stops at non-existing breakpoints in VS Code

Most of the time, I have no problems Xdebug debugging my PHP code in VS Code. But lately, VS Code has started ignoring my breakpoints and instead stopping at random function declarations.

i.e. it will stop at function x($a) in the function below instead of stopping at the breakpoint:

function x($a) {
    // Some code, including a line with a breakpoint
}

Even though the debugging stops at function declarations, I can't step into the code in the functions. Aka. I can't debug anything :panic:

My launch.json:

"version": "0.2.0",
"configurations": [
{
    "name": "Listen for XDebug",
    "type": "php",
    "request": "launch",
    "port": 9090
},
{
    "name": "Launch currently open script",
    "type": "php",
    "request": "launch",
    "program": "${file}",
    "cwd": "${fileDirname}",
    "port": 9090
}
]  

Any ideas for fixing this, so my Xdebug debugging will start behaving again?

I have tried restarting VS Code and Apache + changed port numbers. Didn't help.

Versions on my system:

Upvotes: 2

Views: 800

Answers (1)

zobo
zobo

Reputation: 476

You are running an unsupported PHP and Xdebug version. This is a known problem that was fixed in Xdebug 2.9.1. The problem comes from the resolved_breakpoints issue implemented in the php-debug extension. As a workaround you can disable this feature by adding this to your launch.json configuration

      "xdebugSettings": {
        "resolved_breakpoints": "0"
      },

A more in depth analysis and links to Xdebug issue can be found in my last response: https://github.com/xdebug/vscode-php-debug/issues/629

However this should not stop you from stepping further. Do you have some variables in you watch panel? In Xdebug before 3.1.0 evaling broken code caused the debug engine to stop running correctly (exceptions were not caught correctly).

Upvotes: 3

Related Questions