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

Remote debugging

Open manison opened this issue 7 years ago • 12 comments

Is it possible to set up the extension for remote debugging? Currently I use Eclipse IDE with the EPIC extension, but would prefer using VS Code if possible since the Eclipse experience is a bit cumbersome. On the remote machine I use the PERLDB_OPTS environment variable with the RemotePort option.

manison avatar Feb 07 '18 21:02 manison

Hi @manison sounds like a great feature - I haven't tried remote debugging in perl myself, so you know more about this than I.

Did you try adding the following to the launch.json configuration

  {
    "env": {
      "PERLDB_OPTS": "RemotePort=0.0.0.0:5000"
    }
  }

ref: https://github.com/raix/vscode-perl-debug#setup-notes

raix avatar Feb 08 '18 21:02 raix

Hi @raix. The PERLDB_OPTS must be specified for the remote process being debugged. The RemotePort option causes the perl debugger's stdin/stdout are "redirected" to the TCP connection specified by that option. So the debugger must start the TCP server and listen for the connection from debuggee, instead of reading the debuggee's process stdin/out. Then the remote process must be launched (perl -d with PERLDB_OPTS envs). This would be launched manually or maybe some option in launch.json would be helpful.

So far I tried using netcat as the exec option in launch.json, but now I'm on Windows and the netcat alternative for Windows uses the -d switch for detaching the console. The -d switch seems to be hardcoded in the extension at the moment and cannot be changed in launch.json.

manison avatar Feb 09 '18 07:02 manison

ok, I tried yesterday to run something like $ PERLDB_OPTS="RemotePort=localhost:5000" -d test.pl - but I got a message that it could not connect - I'll investigate further.

If I get that working I might be able to test if we can just connect to that socket instead of tty

raix avatar Feb 09 '18 08:02 raix

@manison I've added the remote debugger feature - it might get released by CI later (if all tests pass)

It's not stable yet, I have two outstanding issues:

  1. debugger output and application output is mixed - would be nice if we could prefix application output. (I'm piping error output to $DB::OUT via select($DB::OUT); - not sure if it's possible to make a "prefix" filehandler eg. error out > prefix > $DB::OUT)
  2. for now local and remote file structure have to match - need to add a "serverRoot" to the game.

Please let me know if you can help crack the application output vs. debugger output issue. (I'm not a perl expert :) )

raix avatar Feb 10 '18 22:02 raix

Great work, @raix. I'm happy to test once I'm able to download VSIX package from CI (failing right now).

debugger output and application output is mixed

Isn't there the same problem with local debugging? Output mixed in stdout? In fact I have the opposite troubles - with stdin. The debugger is consuming input intended for the application being debugged. I will open a separate issue.

for now local and remote file structure have to match

Also some mechanism to copy files to the remote before debug session starts would be handy.

Neither I'm Perl expert. In fact I'm completely new to Perl but happened in the need of debugging some Perl script. And I found your excellent extension for VS Code. Maybe some real expert can help us :)

manison avatar Feb 11 '18 20:02 manison

Then "local" debugger gets db output in stderr and application output in stdout - so they are not mixed. Ideally we should keep the two separate but it might not be possible when debugging remote.

If we should add copying as a feature, then we might have to write a completely new standalone script to run on the remote server. (I'm thinking it's a bigger project - but I've separated the debug session into "remote"/"local" so it would be a matter of adding a "customVSRemoteDebugger" session adapter on the vs side)

Yes a real perl expert would be nice

raix avatar Feb 12 '18 08:02 raix

Just fixed tests (I hope) I'm leaving out application output for now in the debug console - until I have a stable way to combine db and application output.

raix avatar Feb 12 '18 08:02 raix

released

raix avatar Feb 12 '18 09:02 raix

I see this higher up in the thread:

  1. for now local and remote file structure have to match - need to add a "serverRoot" to the game.

I have a scenario such that matching the file structure isn't possible due differences in my remote server and local environments. Is the serverRoot configuration in the works, or should I create a separate issue?

bmingles avatar May 17 '18 14:05 bmingles

@bmingles let's create a separate issue - it is related but we haven't implemented serverRoot - mostly because it ties into the general way we resolve path's - I think a new issue would be nice (then this issue could be closed - I should also add an issue for 1.)

raix avatar May 18 '18 17:05 raix

excuse me . Can I ask u a small question . After set and run the remote debuger, what else commands show I run (like "perl -d " my localip +port) from other mechine.? I mean how to make a "remote perl debug instance to connect to. "

Thanks a lot if u can offer me some links or tutorial for helping me understand perl remote debug

saxon17 avatar May 25 '18 07:05 saxon17

I think this issue can be closed. The directory mapping feature request is covered by https://github.com/raix/vscode-perl-debug/issues/45 and the stdio confusion has been fixed by https://github.com/raix/vscode-perl-debug/pull/64 so there is nothing left to do here.

hoehrmann avatar Mar 01 '19 20:03 hoehrmann