A Control-Flow Graph Approach to Language-Agnostic Debugging for Microcontrollers
The emergence of lightweight virtual machines enabled the use of managed languages, such as JavaScript or Python, on microcontrollers (MCUs). WebAssembly (Wasm) has also expanded the possibilities for managed execution on resource-constrained devices. However, debugging on MCUs remains hard. Most MCU debugging support targets languages that compile to native code, making them unsuitable for managed runtimes. As a result, debugging is often performed using logging, manual resets, and GPIO toggling for call tracing.
In this work, we investigate a language-agnostic approach to debugging microcontrollers (MCUs). Our approach builds control-flow graphs (CFGs) specialised for debugging from compiler-generated Wasm bytecode and debugging information. During debugging, developers can use traditional debugging operations for which the debugger utilises the specialised CFGs to advance computation. We implement a CFG debugger prototype for the WARDuino Wasm VM, building on a basic debug API. We show that our debugger successfully debugs four languages that compile to Wasm without requiring modifications to the debugger. Our benchmarks reveal that the prototype’s execution speed outperforms WARDuino’s existing debugger by factors from 7 to 215.