【问题标题】:VSCode debugger skips breakpointsVSCode 调试器跳过断点
【发布时间】:2020-01-27 06:22:51
【问题描述】:

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

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

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

settings.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
}

launch.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:/"

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

【问题讨论】:

    标签: php windows visual-studio-code xdebug


    【解决方案1】:

    我为这个问题苦苦挣扎了一年多,但在我的案例中发现了问题。

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

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

    【讨论】:

      【解决方案2】:

      用于制作日志:网络服务器可能不允许写入 c:/ - 您可能想要使用 c:/temp(或任何您的临时目录路径)。

      至于不停止,可能是你的网络服务器和本地硬盘的路径不一样,需要设置“路径映射”:https://github.com/felixfbecker/vscode-php-debug/blob/master/README.md#remote-host-debugging

      【讨论】:

        猜你喜欢
        • 2020-04-23
        • 1970-01-01
        • 2013-06-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-09-28
        • 1970-01-01
        相关资源
        最近更新 更多