VOLTTRON / volttron

VOLTTRON Distributed Control System Platform
https://volttron.readthedocs.io/
Other
456 stars 216 forks source link

Question about debugging VOLTTRON (background for VOLTTRON™ Office Hours - 4/28/2023) #3148

Open kefeimo opened 9 months ago

kefeimo commented 9 months ago

Background, in the VOLTTRON™ Office Hours - 4/28/2023 (https://www.youtube.com/watch?v=5caMIDeoieo&t=964s) (around: 15:00-20:00) it talks about debugging volttron using vscode. One scenario is when setting debug point at line 435 volttron/platform/main.py, it didn't go to the brakepoint. And the thread issue was mentioned. Could somebody elaborate on that?

kefeimo commented 9 months ago

Is the launch.py file for this tutorial available somewhere? Especially what is the setup for listener-agent section (around 24:00)? (edited) found the following screenshot at 26:07 image

craig8 commented 9 months ago

I am going to assume you mean launch.json file as it is what vs code uses for launching code.. Debugging volttron.platform.main would require you to start the server in the debugger.

The following will let you do the server.

...
          {
            "name": "volttron -vv",
            "type": "python",
            "request": "launch",
            "program": "env/bin/volttron",
            "console": "integratedTerminal",
            "justMyCode": true,
            "args": [
                "-vv"
            ],
            "env": {
                "GEVENT_SUPPORT": "True"
            },
            "cwd": "${workspaceFolder}"
        },
...

The thread issue is weird. Basically it has to do with the GEVENT_SUPPORT=True. That flag allows greenlets to be debugged and have them hit the break points, however it also has the side effect of "Normal threads" not be able to hit break points. At least that is the observed behavior. if you remove the GEVENT_SUPPORT then your normal threads will be able to be hit but your greenlets won't be able to be debugged. I don't think there is any other in-depth discovery of exactly why or how you could do both.