xdebug / vscode-php-debug

PHP Debug Adapter for Visual Studio Code 🐞⛔
MIT License
763 stars 178 forks source link

Feature request: Add regex patterns for PHP tracebacks so that line number is detected. #961

Open Poikilos opened 1 month ago

Poikilos commented 1 month ago

When clicking a file in a PHP traceback, the file path is processed but not the line number.

This issue (and related API hook) is difficult to find online do to very common keywords in my issue like "line number". I would like there to be a handler to add new regex to the Debug Console. I would expect a debug handler to be the best place for this to be implemented, so VSCode PHP Debug seems like the best place to request the feature. However, I have working regex that would fix the issue (demonstrated using an extension for handling links in files, not the debug console (yet)):

If you have any info, please explain how to handle and manipulate links in the Debug Console. Perhaps dlevs would implement the feature there or I would help program the feature here or there.

PHP version: 8.2.18 Xdebug version: 3.3.2, VS Code extension version: 1.34.0

Everything below can basically be ignored, since it is not relevant and the issue can be reproduced with a working Xdebug configuration any PHP script that has an error in it.

Your 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": 9003
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 0,
            "runtimeArgs": [
                "-dxdebug.start_with_request=yes"
            ],
            "env": {
                "XDEBUG_MODE": "debug,develop",
                "XDEBUG_CONFIG": "client_port=${port}"
            }
        },
        {
            "name": "Launch Built-in web server",
            "type": "php",
            "request": "launch",
            "runtimeArgs": [
                "-dxdebug.mode=debug",
                "-dxdebug.start_with_request=yes",
                "-S",
                "localhost:0"
            ],
            "program": "",
            "cwd": "${workspaceRoot}",
            "port": 9003,
            "serverReadyAction": {
                "pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
                "uriFormat": "http://localhost:%s",
                "action": "openExternally"
            }
        }
    ]
}

Xdebug php.ini config: zend_extension = xdebug

Xdebug logfile (from setting xdebug.log in php.ini): N/A (any working configuration) VS Code extension logfile (from setting "log": true in launch.json): N/A (any working configuration)

Code snippet to reproduce: Any PHP file with errors

zobo commented 1 month ago

Hi!

I don't think this can be done in the Debug Adapter, but I'll look around in this is somehow extendable. We can open an issue with vscode if it is not.