Remote Debugging (enigma2 c code) - SimonCapewell/enigma2 GitHub Wiki

On your Enigma2 box

  • Install gdbserver opkg install gdbserver
  • Install python symbols opkg install python-dbg
  • Launch gdbserver
    • To attach to Enigma2 if already running gdbserver localhost:9999 --attach $(pidof -s enigma2$)
    • To launch a new Enigma2 instance gdbserver localhost:9999 /usr/bin/enigma2

On a Windows dev machine

  • Install MSYS2
  • Follow installation steps, in particular step III updating packages
  • Install gdb-multiarch with Python support pacman -S mingw-w64-x86_64-gdb-multiarch
  • In Visual Studio Code, create a launch.json
{
	"version": "0.2.0",
	"configurations": [
		{
			"name": "GDB debug",
			"type": "cppdbg",
			"request": "launch",
			"program": "c:\\XTrend\\enigma2", <==== local copy of enigma2 binary
			"args": [],
			"stopAtEntry": false,
			"cwd": "${workspaceFolder}",
			"environment": [],
			"externalConsole": false,
			"MIMode": "gdb",
			"setupCommands": [
				{
					"description": "Enable pretty-printing for gdb",
					"text": "-enable-pretty-printing",
					"ignoreFailures": true
				}
			],
			"sourceFileMap": {
				"\\home\\simon\\openvix\\build-environment-4.4\\builds\\openvix\\developer\\et8500\\tmp\\work\\et8500-oe-linux\\enigma2\\enigma2-5.4-r0\\sc-enigma2\\main": "c:\\Source\\XTrend\\OpenVix\\sc-enigma2\\lib",
				"\\home\\simon\\openvix\\build-environment-4.4\\builds\\openvix\\developer\\et8500\\tmp\\work\\et8500-oe-linux\\enigma2\\enigma2-5.4-r0\\sc-enigma2": "c:\\Source\\XTrend\\OpenVix\\sc-enigma2"
			},
			"miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb-multiarch.exe",
			"miDebuggerServerAddress": "192.168.1.85:9999"
		}
	]
}
  • Press F5 to run
  • After a wait while debug symbols are pulled across from the box, you'll be able to set breakpoints, press pause, etc.

Some gotchas

  • It can sometimes take a minute or two for debug symbols to be pulled down from the box before you see any signs of progess.
  • sourceFileMap isn't completely correct yet, so some files are not located correctly when debugging.