Alloy apps run on Moddable's XS JavaScript engine, which ships with a graphical
source-level debugger called xsbug. With xsbug you can set breakpoints, step
through JavaScript, inspect variables, and watch console.log / trace output
while your app runs on a watch or in the emulator.
Platform Support: Alloy and xsbug debugging are available on Emery (Pebble Time 2) and Gabbro (Pebble Time 2 round). This requires
pebble-tool5.0.38 or later.
xsbug can only attach to an app that was built in debug mode. Build your
project with the --debug flag:
$ pebble build --debug
A debug build:
-O0) for easier stepping;PBL_DEBUG, which the Alloy entry point (src/c/mdbl.c) uses to set
kModdableCreationFlagDebug and enable the xsbug connection; and<app>_debug.pbw bundle, so your debug and release
builds can coexist.Note: A debug build is larger and runs more slowly than a release build, and may not fit on memory-constrained apps. Build without
--debugfor normal testing and release.
When you install a --debug build, the Pebble tool automatically launches
xsbug, opens your src/embeddedjs folder so breakpoints map to your source,
and bridges the JavaScript debugger over the connection before the app boots
- so the debugger is attached as soon as your code starts running:
$ pebble install --emulator emery
Launching xsbug JavaScript debugger...
The same happens for pebble logs, which also prefers the _debug bundle when
one is present.
xsbug ships in the active SDK's moddable-tools directory and is started for
you. If the tool can't find it, it prints a warning - launch xsbug manually and
re-run the install so the debugger can connect.
Once connected, xsbug shows your running app. From its interface you can:
console.log and trace output in the messages pane.For a full tour of the debugger, see the Moddable xsbug documentation.