robotpy-wpilib icon indicating copy to clipboard operation
robotpy-wpilib copied to clipboard

Remote debugging support

Open virtuald opened this issue 10 years ago • 10 comments
trafficstars

Possibly leverage eclipse/pydev support for this? Depends on #26

virtuald avatar Dec 29 '14 07:12 virtuald

I was able to launch a remote debugger using a patched version of pydevd (https://github.com/fabioz/PyDev.Debugger/pull/39). It works pretty nicely.

The way I envision this to work is the user will need to install pydevd on the roborio via the installer, and we'll include a special module that automatically sets up the PATHS_FROM_ECLIPSE_TO_PYTHON variables to map back to the users robot source directory for wpilib and the robot code itself.

virtuald avatar Jan 11 '16 05:01 virtuald

I think the easiest way to go about this has two pieces:

  • Create a new remote debug entry point to hal-base for robot programs, and execute that code there
    • See http://robotpy.readthedocs.io/en/stable/dev/design.html#adding-options-to-robot-py
    • Default entry point is at https://github.com/robotpy/robotpy-wpilib/blob/master/hal-base/hal/main.py#L10
  • Add a flag to pyfrc's deploy that cause that entry point to be used instead of the default
    • It could accept flags/environment variables that set the MY_PATHS_FROM_ECLIPSE_TO_PYTHON list

virtuald avatar Feb 14 '18 23:02 virtuald

I think this could be a good bug for a newcomer to work on if they wanted to delve into how RobotPy works under the hood.

auscompgeek avatar Feb 26 '18 09:02 auscompgeek

With upstream WPILib moving to VS Code for the 2019 season, it might be worth looking into how remote debug works there. There are some docs going about how to do this. https://code.visualstudio.com/docs/python/debugging#_remote-debugging

ThadHouse avatar May 11 '18 05:05 ThadHouse

That does look pretty straightforward, thanks for pointing it out :+1:

virtuald avatar May 11 '18 05:05 virtuald

Huh, that looks so much simpler than pydevd.

I imagine that there will be a number of teams who prefer to use PyCharm over Visual Studio/VSCode though, so we should definitely also consider supporting both ptvsd and pydevd in the long term.

Just to be painful though, PTVS requires different versions of ptvsd than vscode-python, so installing it by default will probably be a bad idea.

Dunno how many people actually use PTVS though. (I imagine that number would be fairly small, but shouldn't mean we should aim to be IDE-agnostic.)

auscompgeek avatar May 11 '18 07:05 auscompgeek

Note: We'll probably want to distribute ptvsd/pydevd with the Cython extensions.

auscompgeek avatar Nov 11 '18 02:11 auscompgeek

I think that makes sense. I'd be in favor of distributing a vscode-compatible install by default, but make other configurations possible. Not sure how that would work quite yet though.

virtuald avatar Nov 12 '18 02:11 virtuald

Looks like the VS Code plugin supports newer versions of ptvsd nowadays, so we should be ok to package up the latest stable release.

auscompgeek avatar Nov 12 '18 03:11 auscompgeek

I've started to pick up the VS Code extension again. Would be nice to have a deploy option that calls ptvsd.enable_attach() before the robot code starts.

auscompgeek avatar Feb 11 '19 06:02 auscompgeek