首页 > 解决方案 > VSCode 调试器跳过断点

问题描述

当我在 VSCode 上启动调试器时,一切似乎都在工作,因为下栏变成橙色等......但是,当我添加断点时,站点会忽略它并保持正常加载。当我在launch.json 上添加配置时,php 也不会出现。Xdebug 不会创建日志。

我仔细检查了所有路径,下载了 Xdebug 的 dll,并在 php.ini、settings.json 和 launch.json 中添加了必要的行。

php -v给我版本 7.3.5 和 WAMP 它是相同的版本(在桌面和验证http://localhost/?phpinfo=-1

设置.json

{
    "telemetry.enableTelemetry": false,
    "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
    "window.zoomLevel": -1,
    "C_Cpp.updateChannel": "Insiders",
    "arduino.path": "C:\\Program Files (x86)\\Arduino",
    "[javascript]": {
        "editor.defaultFormatter": "HookyQR.beautify"
    },
    "[html]": {
        "editor.defaultFormatter": "HookyQR.beautify"
    },
    "editor.minimap.enabled": false,
    "php.validate.enable": true,
    "php.executablePath": "c:/wamp64/bin/php/php7.3.5/php.exe",
    "php.validate.executablePath": "c:/wamp64/bin/php/php7.3.5/php.exe",
    "php.validate.run": "onSave",
    "files.associations": {
        "*.inc": "php"
    },
    "git.autofetch": true,
    "git.enableSmartCommit": true
}

启动.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [

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

php.ini

[XDebug]
zend_extension="c:/wamp64/bin/php/php7.3.5/ext/php_xdebug-2.8.0beta2-7.3-vc15-x86_64.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart=on
xdebug.remote_port = 9000
xdebug.remote_log="c:/"

我也没有收到任何错误消息。

标签: phpwindowsvisual-studio-codexdebug

解决方案


我在这个问题上苦苦挣扎了一年多,但在我的情况下发现了这个问题。

VSCode python 调试器只能识别行尾的 CRLF 或 LF,但不能同时识别两者。当文件中同时存在两者时,调试器将显示为跳过行(但它们仍会被执行)。这发生在我的案例中,因为我在调试会话中添加了代码行,并且当我使用调试器会话保存文件时,行尾字符与文件中的默认字符不同。

为了解决这个问题,我只需将 VSCode 底部蓝色条右侧的换行设置从 CRLF 更改为 LF 回到 CRLF 并保存文件。


推荐阅读