php - Xdebug 在 VS Code 中不存在的断点处停止

标签 php visual-studio-code xdebug

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

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

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

即使调试在函数声明处停止,我也无法单步执行函数中的代码。又名。我无法调试任何东西:panic:

我的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 内部版本 19041 (Windows 10) AMD64
  • Apache 版本:Apache/2.4.51 (Win64) OpenSSL/1.1.1l PHP/7.3.31
  • Xdebug 版本:2.8.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

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

关于php - Xdebug 在 VS Code 中不存在的断点处停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69912456/

相关文章:

mysql - 我还有哪些其他选项可以简化 WordPress 内存利用率?

PHP oop 如何以更简单的方式调用另一个类方法?

php - 正则表达式获取 "any_characters((number,number))"

visual-studio-code - 如何配置 VS Code 以记住代理设置 (Windows)

php - qcachegrind错误: Unknown file format.从php xdebug生成的文件

ubuntu - Sublime Text 3(带有 Xdebug 客户端插件)+ Vagrant VM(Ubuntu)

php - 如何在 Heroku 中将 Mysql 命令与 ClearDB 一起使用?

php - 调用数组上的成员函数失败()

java - 如何在 Visual Studio Code 中找到 Java 的类路径?

visual-studio-code - 如何设置热键将光标移出引号/括号?