Home > database >  Xdebug stops at non-existing breakpoints in VS Code
Xdebug stops at non-existing breakpoints in VS Code

Time:11-13

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:

  • System: Windows NT LAPTOP-612BINLI 10.0 build 19041 (Windows 10) AMD64
  • Apache Version: Apache/2.4.51 (Win64) OpenSSL/1.1.1l PHP/7.3.31
  • Xdebug Version: 2.8.1

CodePudding user response:

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).

  • Related