- install perl debug extension for vs code, install PadWalker module for extension’s dependency
- 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"
}
]
}
- set breakpoint and enjoy debug
- 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)