vscode-php-debug icon indicating copy to clipboard operation
vscode-php-debug copied to clipboard

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

Open Poikilos opened this issue 1 year ago • 3 comments

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)):

  • https://github.com/dlevs/vscode-regex-robin/issues/11

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

Poikilos avatar May 20 '24 03:05 Poikilos

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.

zobo avatar May 20 '24 08:05 zobo

I've looked into this again. The vscode patterns that linkifies the text is hardcoded: https://github.com/microsoft/vscode/blob/7dbf25d8427b59f519d04587e71a9d3dfb77224c/src/vs/workbench/contrib/debug/browser/linkDetector.ts#L37

However, as per this comment output evnets can be equipped with a source file and line.

I don't think this was meant to be used like this, but taking into account path mapping this could potentially work...

zobo avatar Apr 10 '25 05:04 zobo

Also, I have a hard time reproducing this format: https://github.com/dlevs/vscode-regex-robin/issues/11#issue-2304934491 whats your php.ini for Xdebug like?

zobo avatar Apr 10 '25 05:04 zobo