Remote Debugging (Python) - SimonCapewell/enigma2 GitHub Wiki
The debugpy package enables remote debugging of the Python parts of Enigma2.
On your Enigma2 box
Install gdb, python-pip and the debugpy Python package
opkg install gdb
opkg install python3-compile python3-xmlrpc python3-plistlib python3-ensurepip
python -m ensurepip
pip3 install debugpy
To launch Enigma2 with the debugger, put this in mytest.py
import debugpy
import sys
sys.argv = []
debugpy.listen(("192.168.1.85", 9998))
If you the process to wait until the debugger client has attached, add
debugpy.wait_for_client()
Note that the IP address has to be specified, not a hostname. sys.argv
is a workaround to prevent a crash.
Attaching to an existing Enigma2 process isn't supported yet. Once it's supported, the command should be
python -m debugpy --connect 192.168.1.85:9998 --pid `pidof enigma2`
Run enigma2
On a dev machine
- In Visual Studio Code, create a launch.json. It has to have multiple
pathMappings
due to the daft location of the source for items in /usr/lib/enigma2/python. If you need to debug plugins, create additional mappings at the top of thepathMappings
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Enigma2",
"type": "python",
"request": "attach",
"pathMappings": [
{
"localRoot": "C:\\Source\\sc-enigma2-plugins\\autotimer\\src",
"remoteRoot": "/usr/lib/enigma2/python/Plugins/Extensions/AutoTimer"
},
{
"localRoot": "C:\\Source\\sc-enigma2-plugins\\epgsearch\\src",
"remoteRoot": "/usr/lib/enigma2/python/Plugins/Extensions/EPGSearch"
},
{
"localRoot": "${workspaceRoot}",
"remoteRoot": "/usr/lib/enigma2/python"
}
],
"rules":[
{
"path": "/usr/lib/python3.8",
"include":false
}
],
"port": 9998,
"host": "192.168.1.85",
"justMyCode": false, // Need this because our code is under /usr/lib
}
]
}
- Press F5 to attach
- Note that running with the debugger attached doesn't seem terribly stable. The e2 process can crash with sigfault occasionally