Andrew Leech
|
c98b355ef4
|
python-ecosys/debugpy: Add VS Code debugging support for MicroPython.
This implementation provides a Debug Adapter Protocol (DAP) server that enables
VS Code to debug MicroPython code with full breakpoint, stepping, and variable
inspection capabilities.
Features:
- Manual breakpoints via debugpy.breakpoint()
- Line breakpoints set from VS Code
- Stack trace inspection
- Variable scopes (locals/globals)
- Source code viewing
- Stepping (into/over/out)
- Non-blocking architecture for MicroPython's single-threaded environment
- Conditional debug logging based on VS Code's logToFile setting
Implementation highlights:
- Uses MicroPython's sys.settrace() for execution monitoring
- Handles path mapping between VS Code and MicroPython
- Efficient O(n) fibonacci demo (was O(2^n) recursive)
- Compatible with MicroPython's limited frame object attributes
- Comprehensive DAP protocol support
Files:
- debugpy/: Core debugging implementation
- test_vscode.py: VS Code integration test
- VSCODE_TESTING_GUIDE.md: Setup and usage instructions
- dap_monitor.py: Protocol debugging utility
Usage:
```python
import debugpy
debugpy.listen() # Start debug server
debugpy.debug_this_thread() # Enable tracing
debugpy.breakpoint() # Manual breakpoint
```
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-06-11 15:09:40 +10:00 |