I just pushed an elaborate patch that allows us to get the WASM version for use in the browser to a next level. This patch reorganises how the VM interacts with the debugger. Before, there was a built-in debugger and the possibility to define the prolog_trace_interception/4
hook to implement your own debugger based on callbacks. That hook is used by the GUI debugger.
This patch adds a new option: the VM can yield on a trace event, i.e., PL_next_solution() returns when a trace event happens. The environment may now retrieve the event, inspect the Prolog state and call Prolog predicates. When done, it sets how execution must continue (creep, skip, leap, nodebug, abort, …) and calls PL_next_solution() to resume the VM.
The interface is largely the same as the prolog_trace_interception/4
interface and it is (thus) capable of building a traditional debugger, something similar to the GUI debugger or something very different. But, the yield based approach allow us to do so for the WASM version running in your browser.
The first obvious usage should be adding a basic debugger to the browser Prolog shell. The next should be something more fancy, that can also be used to debug Prolog applications running in the browser.
Anyone interested in working on such a beast? The development requires a mixture of JavaScript, HTML and Prolog code.
P.s. I do have a C based implementation that reproduces a traditional debugger. Not sure whether I’ll add that as a demo the the source or put it elsewhere. Ask for it if you want to see it.