Closed daihanhle closed 1 year ago
Please provide some more informations, e.g. lauch.json, example program you try to debug, log output with logLevel = 2
I'm having the same issue. My launch.json looks like this.
{
"version": "0.2.0",
"configurations": [
{
"type": "perl",
"request": "launch",
"name": "Perl-Debug",
"program": "${file}",
"stopOnEntry": true,
"reloadModules": true
}
]
}
I assume this is in the same folder as the .pl file?
Do you have move information on what needs to be done on how to get debugging to work?
Thanks.
Please set loglevel = 2 in the plugin configuration and send the output of the perl language server from the output panel.
Hello @richterger! same here, trying to debug a simple hello world app
Perl 5.18 @ ubuntu 18
Debug console: No DB::DB routine defined at /home/ubuntu/test/main.pm line 7.
Code of main.pm:
sub main() {
print("hello world\n");
}
main();
exit;
Language server basically says at some point DA: stderr No DB::DB routine defined at /home/ubuntu/test/main.pm line 6.
which is when i call main(); because I have one line empty at the begining, this is the full output:
running: {} coros: {}
DAx: connect from 127.0.0.1:44492
DAx: start aio read, buffer len = 0
DAx: start aio read, buffer len = 0
DAx: end aio read cnt=21, buffer len = 21
DAx: line=<Content-Length: 451>
DAx: start aio read, buffer len = 0
DAx: end aio read cnt=2, buffer len = 2
DAx: line=<>
DAx: read data={"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"perl","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us","supportsProgressReporting":true,"supportsInvalidatedEvent":true,"supportsMemoryReferences":true,"supportsArgsCanBeInterpretedByShell":true},"type":"request","seq":1}
DAx: read header={ "Content-Length" => 451 }
DAx: ---> Request: {
"command" : "initialize",
"seq" : 1,
"arguments" : {
"adapterID" : "perl",
"supportsProgressReporting" : true,
"supportsInvalidatedEvent" : true,
"supportsRunInTerminalRequest" : true,
"locale" : "en-us",
"linesStartAt1" : true,
"supportsVariablePaging" : true,
"columnsStartAt1" : true,
"supportsMemoryReferences" : true,
"pathFormat" : "path",
"clientName" : "Visual Studio Code",
"clientID" : "vscode",
"supportsArgsCanBeInterpretedByShell" : true,
"supportsVariableType" : true
},
"type" : "request"
}
DAx: handle_req id=-1
DAx: apply_all_roles (Perl::LanguageServer=HASH(0x56007c873760), Perl::LanguageServer::Methods::DebugAdapter, Perl/LanguageServer/Methods/DebugAdapter.pm)
DAx: method=_dapreq_initialize
DA: <--- Response: {
"request_seq" : 1,
"command" : "initialize",
"seq" : 1,
"body" : {
"supportsHitConditionalBreakpoints" : false,
"supportsValueFormattingOptions" : false,
"supportsRestartRequest" : false,
"supportsGotoTargetsRequest" : false,
"supportsModulesRequest" : true,
"completionTriggerCharacters" : [],
"supportsReadMemoryRequest" : false,
"supportsDelayedStackTraceLoading" : true,
"additionalModuleColumns" : [],
"exceptionBreakpointFilters" : [],
"supportsDisassembleRequest" : false,
"supportsSetExpression" : true,
"supportsStepBack" : false,
"supportTerminateDebuggee" : true,
"supportsConditionalBreakpoints" : true,
"supportsConfigurationDoneRequest" : true,
"supportsExceptionOptions" : false,
"supportsRestartFrame" : false,
"supportsCompletionsRequest" : false,
"supportedChecksumAlgorithms" : [],
"supportsExceptionInfoRequest" : false,
"supportsDataBreakpoints" : false,
"supportsFunctionBreakpoints" : false,
"supportsTerminateRequest" : true,
"supportsStepInTargetsRequest" : false,
"supportsBreakpointLocationsRequest" : true,
"supportsLoadedSourcesRequest" : true,
"supportsSetVariable" : true,
"supportsTerminateThreadsRequest" : true,
"supportsLogPoints" : false,
"supportsEvaluateForHovers" : true,
"supportsCancelRequest" : true
},
"type" : "response",
"success" : true
}
DA: done handle_req id=-1
DA: start aio read, buffer len = 0
DA: start aio read, buffer len = 0
DA: end aio read cnt=21, buffer len = 21
DA: line=<Content-Length: 270>
DA: start aio read, buffer len = 0
DA: end aio read cnt=2, buffer len = 2
DA: line=<>
DA: read data={"command":"launch","arguments":{"type":"perl","request":"launch","name":"Perl-Debug","program":"/home/ubuntu/test/main.pm","stopOnEntry":true,"reloadModules":false,"__configurationTarget":6,"__sessionId":"b80d7928-5035-4f99-870f-83ab0ee8dbaa"},"type":"request","seq":2}
DA: read header={ "Content-Length" => 270 }
DA: ---> Request: {
"type" : "request",
"seq" : 2,
"arguments" : {
"type" : "perl",
"reloadModules" : false,
"program" : "/home/ubuntu/test/main.pm",
"name" : "Perl-Debug",
"__configurationTarget" : 6,
"__sessionId" : "b80d7928-5035-4f99-870f-83ab0ee8dbaa",
"request" : "launch",
"stopOnEntry" : true
},
"command" : "launch"
}
DA: handle_req id=-2
DA: method=_dapreq_launch
DA: start /home/ubuntu/.plenv/versions/5.18.2/bin/perl5.18.2 -I /home/ubuntu/.plenv/versions/5.18.2/lib/perl5/site_perl/5.18.2/x86_64-linux-thread-multi -d /home/ubuntu/test/main.pm
DA: /home/ubuntu/.plenv/versions/5.18.2/bin/perl5.18.2 -I /home/ubuntu/.plenv/versions/5.18.2/lib/perl5/site_perl/5.18.2/x86_64-linux-thread-multi -d /home/ubuntu/test/main.pm started
DA: <--- Notification: {
"jsonrpc" : "2.0",
"body" : {
"systemProcessId" : 22116,
"startMethod" : "launch",
"isLocalProcess" : true,
"name" : "/home/ubuntu/test/main.pm"
},
"event" : "process",
"type" : "event"
}
DA: <--- Response: {
"command" : "launch",
"request_seq" : 2,
"seq" : 2,
"body" : {},
"success" : true,
"type" : "response"
}
DA: done handle_req id=-2
DA: start aio read, buffer len = 0
DA: start aio read, buffer len = 0
DAx: connect from 127.0.0.1:44494
DAx: start aio read, buffer len = 0
DAx: start aio read, buffer len = 0
DAx: end aio read cnt=, buffer len =
DA: stderr No DB::DB routine defined at /home/ubuntu/test/main.pm line 6.
DA: <--- Notification: {
"jsonrpc" : "2.0",
"type" : "event",
"event" : "output",
"body" : {
"output" : "No DB::DB routine defined at /home/ubuntu/test/main.pm line 6.\r\n",
"category" : "stderr"
}
}
DA: /home/ubuntu/.plenv/versions/5.18.2/bin/perl5.18.2 -I /home/ubuntu/.plenv/versions/5.18.2/lib/perl5/site_perl/5.18.2/x86_64-linux-thread-multi -d /home/ubuntu/test/main.pm ended
DA: <--- Notification: {
"body" : null,
"event" : "terminated",
"type" : "event",
"jsonrpc" : "2.0"
}
DA: <--- Notification: {
"jsonrpc" : "2.0",
"event" : "exited",
"body" : {
"exitCode" : 255
},
"type" : "event"
}
DA: end aio read cnt=20, buffer len = 20
DA: line=<Content-Length: 52>
DA: start aio read, buffer len = 0
DA: end aio read cnt=2, buffer len = 2
DA: line=<>
DA: read data={"command":"loadedSources","type":"request","seq":3}
DA: read header={ "Content-Length" => 52 }
DA: ---> Request: {
"command" : "loadedSources",
"seq" : 3,
"type" : "request"
}
DA: handle_req id=-3
DA: method=_dapreq_loadedSources
DA: <--- Response: {
"success" : true,
"type" : "response",
"seq" : 3,
"body" : {
"sources" : [
{
"path" : "/home/ubuntu/test/main.pm"
}
]
},
"command" : "loadedSources",
"request_seq" : 3
}
DA: done handle_req id=-3
DA: start aio read, buffer len = 0
DA: start aio read, buffer len = 0
DA: end aio read cnt=21, buffer len = 21
DA: line=<Content-Length: 105>
DA: start aio read, buffer len = 0
DA: end aio read cnt=2, buffer len = 2
DA: line=<>
DA: read data={"command":"disconnect","arguments":{"restart":false,"terminateDebuggee":false},"type":"request","seq":4}
DA: read header={ "Content-Length" => 105 }
DA: ---> Request: {
"seq" : 4,
"arguments" : {
"restart" : false,
"terminateDebuggee" : false
},
"type" : "request",
"command" : "disconnect"
}
DA: handle_req id=-4
DA: method=_dapreq_disconnect
DA: Send signal KILL to debuggee
DA: <--- Response: {
"type" : "response",
"success" : true,
"body" : {},
"seq" : 4,
"request_seq" : 4,
"command" : "disconnect"
}
DA: done handle_req id=-4
DA: start aio read, buffer len = 0
DA: start aio read, buffer len = 0
DA: end aio read cnt=, buffer len =
##### 80 #####
running: {} coros: {}
Known Issues
Does not yet work on windows, due to issues with reading from stdin.
lol sorry.
What do you mean by "lol sorry"?
Running your example works for me.
Could you cann the following code before the call to main()
foreach (sort keys %ENV)
{
print "$_=$ENV{$_}\n" ;
}
The output should look someting like
PERL5DB=BEGIN { $| = 1 ; require Perl::LanguageServer::DebuggerInterface }
PLSDI_OPTIONS=reload_modules
PLSDI_REMOTE=127.0.0.1:13605
PLSDI_SESSION=3656630f-51af-4077-81f4-7f2557761856
In addition, could you verify that PERL5DB is working on your system, try
PERL5DB="print 'test'" perl -d /home/ubuntu/test/main.pm
should output
No DB::DB routine defined at /tmp/pls.pl line 6.
test
Important is, that you see the output of test
I mean that I didn't read the client information, i understand that it doesn't works in windows right? My perl language server is running on ubuntu 18 under WSL2, and VS code is in windows, with WSL2 plugin.
Ty, gonna check what you requested.
Yes, it does not work on windows, because I wasn't able to find a reliable way to do a non blocking read from stdin on windows. I would be happy, if anyone knows how to do this in Perl.
this one gives me:
ubuntu@BairesRW:~/test$ PERL5DB="print 'test'" perl -d /home/ubuntu/test/main.pm No DB::DB routine defined at /home/ubuntu/test/main.pm line 1. testubuntu@BairesRW:~/test$
testubuntu@BairesRW:~/test$ perl -d main.pm
Loading DB routines from perl5db.pl version 1.39_10
Editor support available.
Enter h or 'h h' for help, or 'man perldebug' for more help.
main::(main.pm:1): foreach (sort keys %ENV)
main::(main.pm:2): {
DB<1>
I can debug from from console when running my script, i suppose the problem is trying to debug from VS code running in windows :(
It should work without problems inside of subsystem for linux on windows. Only using native windows e.g. Strawberry Perl has problems.
Is your whole vscode running inside linux or does vscode run on windows and you want debug on linux? Can you describe a little bit more about your setup please.
Wow this bring back hopes to debug from VS code !
Yes, vscode in windows, and want to debug legacy perl code in linux. My current setup is as following:
Attached some screens of my environment, as you can see i can successfully debug from the ubuntu bash invoking perl -d <scriptfile.pm>
but not from the vscode running in windows connected to the ubuntu repo in wsl
I tried it with Ubuntu 16.04 on WSL and it works for me.
Maybe something went wrong when you installed Perl::LanguageServer. What I did:
sudo apt install libanyevent-perl libclass-refresh-perl libcompiler-lexer-perl libdata-dump-perl libio-aio-perl libjson-perl libmoose-perl libpadwalker-perl libscalar-list-utils-perl
sudo cpan
force install Coro
install Perl::LangauageServer
quit
The force is necessary because you have to interrupt the test for Coro with Ctrl-C
The other posibility is, that path or include paths are different when running on the command line and when running inside of vscode
Thank you for the insight!
I’ll run that install, and recheck my include paths.
Thanks a lot!
Debugging enabled by loading DB::DB() routines @peterdragon recommended in DebuggerProcess.pm, please @richterger take a look at his pull request.
Thanks @etiennez0r
Comment copied from issue#91:
I managed to get it working with Centos 7 / perl 5.16. I sent a PR https://github.com/richterger/Perl-LanguageServer/pull/156 but briefly I added a call DB::DB() after the require to get the symbols into memory before the target program is loaded and changed the prerequisites to 5.16 and warnings so it runs on perl 5.16. Tested on Centos 7 with perl 5.16.3 and 5.32.0 from VSC and running the unit test.
Diffs
Perl/LanguageServer/DebuggerProcess.pm ../orig/Perl-LanguageServer-2.4.0/lib/Perl/LanguageServer/DebuggerProcess.pm
146c146
< $ENV{PERL5DB} = 'BEGIN { $| = 1 ; ' . $cwd . 'require Perl::LanguageServer::DebuggerInterface; DB::DB(); }' ;
---
> $ENV{PERL5DB} = 'BEGIN { $| = 1 ; ' . $cwd . 'require Perl::LanguageServer::DebuggerInterface }' ;
Perl/LanguageServer/Parser.pm ../orig/Perl-LanguageServer-2.4.0/lib/Perl/LanguageServer/Parser.pm
10c10
< use v5.16;
---
> use v5.18;
12c12
< no if $] >= 5.018, warnings => 'experimental'; # given, when, Smartmatch
---
> no warnings 'experimental' ;
14d13
< use feature 'switch';
Perl/LanguageServer.pm ../orig/Perl-LanguageServer-2.4.0/lib/Perl/LanguageServer.pm
3c3
< use v5.16;
---
> use v5.18;
Makefile.PL ../orig/Perl-LanguageServer-2.4.0/
1c1
< use v5.16;
---
> use v5.18;
pull request #156 is applied, which should fix the problem
Hi,
I install perl::languageServer on centos 7 with perl 5.18.0 when debug, the debug panel show up for only few second. nothing happen- after.
DH