A better workflow for 'Attach to Process' debugging?

Feb 5 at 9:35 PM
Edited Feb 5 at 9:35 PM
Hello!

I used PTVS with Maya and the current workflow that I have is to start Maya and then Attach to Process in Visual studio. I iterate quite a bit so I would like to improve this.

What is ideal would be to launch Maya from visual studio, in the same way that I can launch Maya as a start-up application when debugging dlls. Can I do this?

Thank you.
Coordinator
Feb 6 at 1:25 AM
PTVS can work with custom Python interpreters, but only so long as they take the same meaning for command line arguments as regular python.exe - this is because, when launching the program via Start Debugging, the debugger code is the actual startup script that transfers control to your program after registering the necessary hooks, while Attach to Process uses a separate and much more complicated scheme to inject the debugger into a running interpreter.

I don't know much about Maya, but I doubt that it falls into this category, as its main purpose isn't running Python scripts, so you're stuck with Attach to Process. It might still be possible to simplify that workflow, however. There is a third-party VS extension called ReAttach that provides a toolbar dropdown that maintains a most-recently-used list of debug attach commands, and allow you to repeat them. I believe it should work with PTVS, as well.

At the same time, it would also make for an interesting feature for PTVS itself. We already have the concept of different "launchers" - if you go into project settings page for your Python project and look at the Debug tab, you'll see a "Launch mode" combo box on top. So it would be possible to add a new launcher type that would just start the process and then attach to it, instead of launching it normally.

(In fact, launchers are a public extensibility point, and it is possible to add a new launcher type with a separate VS extension, without having to modify & rebuild PTVS itself - it locates and loads the launcher providers via MEF.)