Debugger

Duktape has built-in debugger support as an option you can enable during compilation. Debugger support adds about 15-20kB of code footprint (depending on what debugger features are enabled) and has very minimal memory footprint. Debugger features include:

The debugger is based on the following main concepts:

The most appropriate debug transport varies a lot between debug targets; it can be Wi-Fi, Bluetooth, a serial line, a stream embedded into a custom management protocol, etc. Although there is no "standard" transport, a TCP connection is a useful default. The Duktape distributable includes all the pieces you need to get started with debugging using a TCP transport:

The Node.js based debugger web UI (duk_debug.js) can connect to the Duktape command line, but can also talk directly with any other target implementing a TCP transport. You can also customize it to use a different transport or use a proxy which converts between TCP and your custom transport. It's also possible to write your own debug client from scratch and e.g. integrate it to a custom IDE. You can integrate directly with a debug target using the binary debug protocol, or use the JSON proxy provided by duk_debug.js (Node.js) or duk_debug_proxy.js (DukLuv).

Debug targets and debug clients are intended to be mixed and matched: apart from the transport (which is usually either TCP or easy to adapt) the debug protocol is the same. Core functionality will be the same regardless of the debug client or the debug target, but some optional features may be missing. Debug clients and debug targets may also implement application specific commands (AppRequest) and notifications (AppNotify) for richer integration which can be used when both the client and the target support them (they're easy and safe to ignore if not supported). Custom commands and notifications allow e.g. downloading of source files directly from the target, deep inspection of the state of a custom memory allocator, rebooting the target on command, etc.

For more details on the implementation and how to get started, see: