【问题标题】:Xdebug stops at non-existing breakpoints in VS CodeXdebug 在 VS Code 中不存在的断点处停止
【发布时间】:2021-12-23 00:05:33
【问题描述】:

大多数时候,我在 VS Code 中调试我的 PHP 代码 Xdebug 没有问题。但最近,VS Code 开始忽略我的断点,而是在随机函数声明处停止。

即它将在下面函数中的function x($a) 处停止,而不是在断点处停止:

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

即使调试在函数声明处停止,我也无法进入函数中的代码。阿卡。我无法调试任何东西:恐慌:

我的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
}
]  

有什么想法可以解决这个问题,这样我的 Xdebug 调试就会重新开始吗?

我已尝试重新启动 VS Code 和 Apache + 更改端口号。没有帮助。

我系统上的版本:

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

【问题讨论】:

  • 确定你有最新版本吗?
  • 最新版本是什么?它以前工作过。由于某种原因,它在几天前停止工作。
  • @Mads 首先说明您的操作系统、PHP 和 Xdebug 版本以及显示您的 Xdebug 配置。您可以从phpinfo() 输出中获得所有这些信息。
  • 好点。已添加。

标签: php visual-studio-code xdebug


【解决方案1】:

您正在运行不受支持的 PHP 和 Xdebug 版本。这是一个在 Xdebug 2.9.1 中修复的已知问题。问题来自 php-debug 扩展中实现的resolved_breakpoints 问题。 作为一种解决方法,您可以通过将其添加到您的 launch.json 配置来禁用此功能

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

可以在我的上一个回复中找到更深入的分析和 Xdebug 问题的链接: https://github.com/xdebug/vscode-php-debug/issues/629

但是,这不应该阻止您更进一步。 你的手表面板中有一些变量吗?在 3.1.0 之前的 Xdebug 中,evaling 损坏的代码导致调试引擎停止正常运行(未正确捕获异常)。

【讨论】:

  • 太棒了。将我的 Xdebug 更新到 2.9.7 版解决了这个问题。非常感谢您解决了我的调试问题! :)
猜你喜欢
  • 2021-05-08
  • 2015-09-11
  • 2019-03-31
  • 2011-04-30
  • 1970-01-01
  • 1970-01-01
  • 2018-03-31
  • 1970-01-01
  • 2020-02-17
相关资源
最近更新 更多