Hey,
Version 0.4.0 of package debug_adapter
is out and available via:
?- pack_install(debug_adapter)
This release features a new mode of operation which provides an integrated Prolog top-level.
First a screenshot for demonstration:
The way it works is that the DAP server starts a new thread running prolog/0
with hooks in place for controlling debugging facilities, and standard I/O streams redirected to a TCP socket. The server then sends a DAP request to the IDE instructing it to launch a terminal and connect it to the newly created Prolog top-level via TCP.
I find this mode of operation provides quite a nice development experience as you get both the interactive top-level and visual debugging features together in the IDE.
To start the integrated top-level using GNU/Emacs and dap-mode
:
- Add the following lines to your
init.el
(won’t be needed once this PR todap-mode
is merged):
(dap-register-debug-template "SWI-Prolog Start Terminal"
(list :type "swi-prolog"
:goal "$run_in_terminal"
:request "launch"
:name "SWI-Prolog::Terminal"))
- Type
M-x dap-debug
- Choose “SWI-Prolog Start Terminal” when prompted for a debug configuration:
A new buffer should open up showing the familiar ?-
prompt.
Each time the tracer is hit, the DAP server notifies the IDE that the running thread stopped, and allows the IDE to request debug information like the current stack trace, the exact position in the source code (including generated sources for dynamic predicates), and variable bindings.