I have successfully implemented custom menu options in PlatformIO to execute Makefile operations through Python scripts. These work as expected.
I am now looking to extend this functionality to include debugger controls. Specifically, I would like to programmatically invoke the VSCode/PlatformIO debug commands that are available under “Quick Access → Debug”:
“Start Debugging” (equivalent to F5)
“Toggle Debug Console”
Is there a mechanism available within PlatformIO’s Python scripting environment to call these VSCode commands from a custom menu handler?
I know you can start a debug session (and launch into GDB) with
pio debug --interface=gdb -- -x .pioinit
per docs, but not sure how you would trigger the “Start Debugging” action.. Essentially it’s a launch of the debug configuration in the launch.json. I’m not sure this is something that a Python script called by the PlatformIO core can trigger at all, since this has to do with VSCode.
This was true when using PlatformIO’s build manager; but the client wanted to use their existing makefile (which was also used on CI/CD system etc). So when pressing F5, a pre:script.py is called, check made on args to see if any are “debug”, and if so, run the makefile.
It’s a little more complicated than that, but you get the idea