Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Launching PTVSD debugger from VS Code #40

Closed
DonJayamanne opened this issue Feb 5, 2018 · 5 comments
Closed

Launching PTVSD debugger from VS Code #40

DonJayamanne opened this issue Feb 5, 2018 · 5 comments

Comments

@DonJayamanne
Copy link
Contributor

After having a chat with @karthiknadig I learnt that I dont and can't use ptvsd_launcher.py found in PTVS (Visual Studio), instead I can just use the PTVSD module.

This works, and I'm able to get the debugger working in VS Code as follows:
python -m ptvsd --port 8788 --file main.py

However, ptvsd_launcher.py does a lot more than just launching the debugger.

  • It sets the cwd
  • It determines how the code is to be rune (file, module or plain text)
  • It parses the debug options

All of this is done and necessary stuff then passed onto PTVSD (debug function in debugger.py).
With VS Code not utilizing ptvsd_launcher.py, it feels like the responsibility falls on VS Code (our adapter) to to the above.

@ericsnowcurrently @int19h @karthiknadig
Please could someone confirm this.

@int19h
Copy link
Contributor

int19h commented Feb 5, 2018

The only reason why ptvsd_launcher.py is in VS is historical - it wasn't moved out to this repo because it wasn't a part of the ptvsd package, just a helper script (part of the reason why is because it needs to set sys.path to load the package from the right path for VS). Also, it parses command line in the way existing VS launcher code expects it.

If it's convenient for VSC to use the same script, we could move it to this repo, so that it's shared between the two. But I suspect there would be differences e.g. wrt locating the package, so it's probably easier to keep separate scripts for each - they're small enough. This would also mean that you can optimize the script's command line interface to be more convenient specifically for VSC launcher.

@DonJayamanne
Copy link
Contributor Author

they're small enough. This would also mean that you can optimize the script's command line interface to be more convenient specifically for VSC launcher.

Agreed. Just wanted to ensure that we're all on the same page.

I've tried using the launcher script in VS Code and it doesn't work. When launching ptvsd module (python -m ptvsd --port 8788 --file main.py), this seems to start the necessary socket server on port 8788, whilst using the ptvsd_launcher.py script it seems to expect a socket server listening on port 8788 (quite the opposite)..

Anyways, I'll proceed without this launcher script.

Once again, thanks.

@int19h
Copy link
Contributor

int19h commented Feb 5, 2018

With respect to direction of connection, you might want to consider making it work the same as in VS (i.e. the debuggee connects to the IDE). The main reason is that it allows the IDE to pick any available ephemeral port first and open a server there (thereby claiming it), and then telling the script where it should connect via command line arguments. When it's the other way around, you basically have to hardcode the port, since the script doesn't have any means to communicate a randomly picked port to the IDE without a connection; so it might fail if the port is already in use.

@DonJayamanne
Copy link
Contributor Author

DonJayamanne commented Feb 6, 2018

Got it.

@DonJayamanne
Copy link
Contributor Author

In making that architectural change, I can use ptvsd_launcher.py

If it's convenient for VSC to use the same script, we could move it to this repo

Please could you make this change. Will create a separate issue for that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants