how to debug perl in vs code

  1. install perl debug extension for vs code, install PadWalker module for extension’s dependency
  2. create perl debug config, as below url
    how to create debug config
    after create the config, this is equals create launch.json under .vscode folder.
    the content looks like below:
{
    // 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": [
        
        {
            "type": "perl",
            "request": "launch",
            "name": "Perl-Debug local",
            "console": "integratedTerminal",
            "program": "${workspaceFolder}/${relativeFile}",
            "exec": "perl",
            "execArgs": [],
            "root": "${workspaceRoot}/",
            "inc": [],
            "args": [],
            "env": {},
            "debugRaw": false,
            "debugLog": false,
            "stopOnEntry": true,
            "sessions": "single"
        },
        {
            "type": "perl",
            "request": "launch",
            "name": "Perl-Debug remote",
            "console": "remote",
            "program": "${workspaceFolder}/${relativeFile}",
            "root": "${workspaceRoot}/",
            "stopOnEntry": true,
            "port": 5000,
            "sessions": "single"
        }
    ]
}
  1. set breakpoint and enjoy debug
  2. how to use remote debug with vs code
    start remote debugger
    start cmd and cd to your script folder, execute below code in windows:
# not have "" as the extension's document said, pay attention
set PERLDB_OPTS=RemotePort=localhost:5000 
perl -d script.pl

Pay attention:
it’s only support strict mode syntax, if you perl code is old, the variable panel can’t show your variable.
but you still can use debug console(cmd in visual studio code) to show it(x/p)

发布了420 篇原创文章 · 获赞 29 · 访问量 94万+

猜你喜欢

转载自blog.csdn.net/lantianjialiang/article/details/103294303