Closed hoehrmann closed 5 years ago
One use case to consider:
It seems to me that remote debugging sessions should, perhaps at user option, have a longer lifetime than the first script that might connect to it. Suppose you have a bash script that configures an environment for several Perl scripts and you want to debug one of the scripts. It should be possible to start a remote debugging session in vscode and then run something like the following:
% export PERLDB_OPTS='RemotePort=localhost:5000'
% export PERL5OPT=-d
% bash -x script-that-calls-several-perl-scripts.sh
If the remote debugging session endures until the user decides to end it, this should work fine. If however we end the debugging session when the first script terminates, the user has only bad options, they would, for instance, have to fiddle with the bash script to make sure the debugger is launched only once.
The same problem probably exists when the first Perl script forks a child and then terminates itself, like a daemon might do to run in the background, we would not get to the point where the user could debug the forked child since the launch process has gone already.
Pondering a launch.json
option to give users control over this:
sessions: 'single' | 'watch' | 'break'
The current behaviour could be single
.
In watch
mode multiple sessions are accepted, probably with an extended lifetime of the debug session (users might have to manually terminate it, or there might be a configurable timeout?).
The break
mode is like watch
except that new sessions, child processes, are stopped on entry.
Fixed by merging my PR in https://github.com/raix/vscode-perl-debug/commit/2cda8962aef231fdbb70013e54559563afbcb9db
Over at https://github.com/pullhub/vscode-perl-debug/tree/fork I am playing with multi-session/multi-target support, mainly to support
fork
(as a diff, https://github.com/pullhub/vscode-perl-debug/commit/7676bf375c794470f77f521c1feb5d02d05cfcd1 should do for the moment). Suppose the Perl script to be debugged is on a remote server:$localPort
for the Perl debuggerlocalhost:$localPort
toremote:$remotePort
PERLDB_OPTS='RemotePort=localhost:$remotePort' perl -d script.pl
on the remote serverAt the moment the extension would simply refuse the new connection...
It seems vscode needs a new debug adapter instance for each new process / debug session. That pretty much leaves only one option, one
perlDebug.ts
instance has to be a relay for other instances (since we cannot simply hand over sockets from one process to the other).So my changes linked above have a simple proxy server that makes an accepted connection indirectly attachable for a new
perlDebug.ts
process. Basically:perlDebug#1
listens onip:1
debugger#1
connects onip:1
debugger#2
connects onip:1
perlDebug#1
listens onip:2
perlDebug#2
perlDebug#2
attaches toip:2
perlDebug#2
talks throughperlDebug#1
todebugger#2
There probably is no better way to do this while maintaining proper process isolation. My code works, but I am not yet happy with where things live and lifecycle management is a bit broken.
I am currently trying to unify
LaunchRequestArguments
withLaunchOptions
to simplify howperlDebug.ts
andadapter.ts
do launches. I kinda would like to lift »perlDebug#1
listens onip:2
« out ofremoteSession.ts
but I am not clear on where things should go.