Support remote Python debugging
See original GitHub issueAfter thinking about this some more, this approach locks cocotb into debuggers that use the Debug Adapter Protocol such as VSCode or Theia (used by GitPod). There are a variety of ways to do remote debugging:
- VSCode/GitPod uses debugpy.
- Pycharm Professional uses pydevd-pycharm.
- PyDev in Eclipse uses plain pydevd.
- Our docs recommend remote-pdb.
This may be a good candidate for cocotb extensions that provide a setuptools entry point that can be selected by COCOTB_PY_ATTACH
.
So for example, a new extension cocotbext-debugpy could provide an entry point:
setup(
name = 'cocotbext-debugpy',
entry_points = {"cocotb.remote_debugger": "debugpy = cocotbext.debugpy:debug_attach"}
...
)
And the user would select it with COCOTB_PY_ATTACH=debugpy,localhost:5678
_Originally posted by @garmin-mjames in https://github.com/cocotb/cocotb/pull/2103#issuecomment-705050127_
This issue is to discuss the best approach to support remote debugging.
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (16 by maintainers)
Top Results From Across the Web
Debugging configurations for Python apps in Visual Studio Code
This article mainly addresses Python-specific debugging configurations, including the necessary steps for specific app types and remote debugging.
Read more >Remotely debug Python code on Linux - Microsoft Learn
Visual Studio can launch and debug Python applications locally and remotely on a Windows computer (see Remote debugging). It can also debug ......
Read more >Remote Debugging Guide for Python | Codementor
Learn how to go beyond print and logging to debug tough problems efficiently using remote debugging in python.
Read more >PythonDebuggingTools - Python Wiki
PyCharm's integrated debugger works for Python and Jython, supports debugging of multiple threads, remote debugging, allows debugging Django, ...
Read more >Remote Python Debugging - Komodo 12 Documentation
Using the Python Remote Debugger. When debugging a Python program remotely, the program is executed on the remote machine, and the debug output...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes IMO.
Of course!
The number of point solutions and environment variables we are using for those point solutions is already a lot IMO, and adding more is only going to decrease maintainability. I think it’s time to step back and abstract the problem. To me the best solution to abstract all the behaviors we want at startup, as well as support user customization points, as “custom entry points” (#1225). To me, these are more of a startup routine. Attaching a Python debugger can be one of those startup routines, and so could other existing aspects of
_initialize_testbench
(like enabling coverage).For example, in your PR you have encapsulated the behavior into a function. Now we can do
COCOTB_STARTUP_ROUTINES += ',cocotb:_check_debug_attach'
. The remote debugger initialization could live in this repo, or not. Whether it can exist or not is then divorced from everyone else’s approval. I think this is the path forward for new features that must run during initialization. There are also a host of other issues that can be solved using this generalized approach.P.S. Maybe there is a way to support passing simple literal values safely to these routines? So that you don’t even need the additional environment variable for the port #.
@garmin-mjames: Note in principle that cocotb could support only
entry_points
, and we could provide acocotb-plugin-hacks
package that provides an entry point that readsCOCOTB_STARTUP_ROUTINES
(or vice versa)