Did you know ... Search Documentation:
Pack debug_adapter -- README.md

Debug Adapter Protocol for SWI-Prolog

Welcome to the SWI-Prolog Debug Adapter Protocol server, an implementation of DAP for SWI-Prolog, written in Prolog.


debug_adapter is available as a SWI-Prolog pack, to use it simply run the following goal in the SWI-Prolog toplevel:

?- pack_install(debug_adapter).

If you're using GNU Emacs with dap-mode, add the following lines to your init.el:

(require 'dap-swi-prolog)

Now run `M-x dap-debug` in a Prolog buffer and have fun.


Most of the DAP specification is implemented and operational. For the status of specific features, see below.

For information about recent changes and additions, see NEWS.md.

Currently only tested with GNU Emacs and dap-mode until we have a VS Code extension.

DAP Events implementation coverage

event messages are notifications sent from the server to the client according to different runtime hooks that are implemented by the server.

Breakpointthe status of a breakpoint has changed✅
Capabilitiesone or more capabilities have changed
Continuedthe execution of the debuggee has continued✅
Exitedthe debuggee has exited and returns its exit code✅
Initializedthe debug adapter is ready to accept configuration requests✅
Invalidatedsome state in the debug adapter has changed
LoadedSourcesource has been added, changed, or removed✅
Memorymemory range has been updated
Moduleinformation about a module has changed
Outputthe target has produced some output✅
Processthe debugger has begun debugging a new process
ProgressEndsignals the end of the progress reporting
ProgressStarta long running operation is about to start
ProgressUpdateprogress reporting needs to updated
Stoppedthe execution of the debuggee has stopped✅
Terminateddebugging of the debuggee has terminated
Threada thread has started or exited✅

DAP Requests implementation coverage

request messages are sent from the client to the server to retrieve information about the current runtime.

Attachattach to a debuggee that is already running✅
BreakpointLocationsobtain possible locations for source breakpoints in a given range
Completionsobtain possible completions for a given caret position and text✅
ConfigurationDonefinish initialization of the debug adapter✅
Continueresume execution of all threads✅
DataBreakpointInfoobtain information on a possible data breakpoint that could be set
Disassembledisassemble code at the provided location
Disconnectstop debugging✅
Evaluateevaluate the given expression in the context of the debuggee✅
ExceptionInfoobtain details about thrown exceptions✅
Gotoset the location where the debuggee will continue to run
GotoTargetsobtain possible goto targets for the specified source location
Initializeconfigure the debug adapter and obtain its capabilities✅
Launchstart the debuggee✅
LoadedSourcesobtain all sources currently loaded by the debuggee
Modulesobtain modules currently loaded by the debuggee
Nextexecute the specified thread for one step✅
Pausesuspend the debuggee✅
ReadMemoryread bytes from memory at the specified location
Restartrestart the debug session
RestartFramerestart execution of the specified stackframe✅
ReverseContinueresume backward execution of all threads
Scopesobtain the variable scopes for a given stackframe✅
SetBreakpointsset breakpoints in specified source locations✅
SetDataBreakpointsset data breakpoints
SetExceptionBreakpointsset the debug adapter's behaviour upon debuggee exceptions✅
SetExpressionassign runtime values to a given expression
SetFunctionBreakpointsset functions breakpoints✅
SetInstructionBreakpointsset intructions breakpoints
SetVariableassign runtime values to a given variable
Sourceobtain source code for a given source reference✅
StackTraceobtain stacktrace from the current execution state of a given thread✅
StepBackexecute the specified thread one backward step
StepInresume the specified thread to step into a function✅
StepInTargetsobtain possible stepIn targets for the specified stackframe✅
StepOutresume the specified thread to step out from a function✅
Terminateterminate the specified thread
TerminateThreadsterminate the specified threads
Threadsobtain the list of current threads✅
Variablesobtain all child variables for the specified variable reference✅
WriteMemorywrite bytes to memory at the specified location

DAP Reverse requests implementation coverage

Reverse requests are request messages sent from the server to the client to trigger client side operations.

Reverse RequestDescriptionStatus
RunInTerminalrun a command in a client controlled terminal✅


The two big milestones for this project are:

  • Reaching feature parity with SWI-Prolog's built-in graphical debugger with a DAP enabled IDE (GNU Emacs + dap-mode in particular), and
  • Supporting the entire DAP specification Some of the needed steps towards these goals are:
  • [x] Stepping through the source code of a debuggee with precise source positions
  • [x] Restarting debuged frames
  • [x] Supporting more debug requests - stepOut, stepBack, next
  • [x] Providing source code for dynamic predicates through decompilation
  • [x] Installing breakpoints at source positions
  • [x] Providing information about variable bindings in each frame
  • [x] Editing and reloading source code during break
  • [ ] ...