The debugger
Adam's own debugger, at a prompt or in an editor.
One engine
Adam has its own debugger: one engine drives the console debugger (adam build -d) and the debug adapter (adam dap) an editor uses. It reads the debug information Adam writes, on Windows a PDB from Adam's own PDB writer, so a stop is shown at its .adam file, line and routine. adam has a debugger for its host's programs where it has one: x86_64-windows-gnu today; on Linux -d and adam dap say CL0033.
At the prompt
adam build <file> -d builds the program for debugging and runs it at a (dbg) prompt in the same console (Running and debugging); a build with no debug information is refused (CL0025). At the prompt:
| Command | What it does |
|---|---|
b <file>:<line> | set a breakpoint |
bl / bd <n> / bc | list the breakpoints, delete one, clear them |
c / n / s / finish | continue, step over, into, out |
bt / f <n> | show the stack, pick a frame |
locals / p <x> | show the frame's values, one value |
src / threads | the source around the stop, the threads |
r / h / q | run again with the breakpoints kept, the help, quit |
A stop shows its reason, routine, file and line, then two lines of source above and below with >> on the stop's line; Ctrl+C pauses a running program. p <x> reads a name, a field after ., an element [N] and what a pointer points to (^).
Breakpoints in the code
@breakpoint; marks its line in the program itself: the debugger takes it as a breakpoint from the start, and a run outside the debugger goes past it (Messages and breakpoints).
module exe debugger_marks;
var
GTotal: int64;
begin
GTotal := 2;
// The debugger stops here, before the next line runs
@breakpoint;
GTotal := GTotal * 10;
println("total {}", GTotal);
end.
total 20
In an editor
adam dap serves the Debug Adapter Protocol on stdin / stdout; a launch takes an .adam source, which it builds for debugging first, or a built exe, its arguments and stopOnEntry. With noDebug it only runs the program, as an editor's Run. The adapter stops on an exception where nothing catches it, and on every exception at its first chance when the client turns on the "all" filter. Every start and end of a thread of the program is reported to the client. The Adam editor is its client (Build, run, debug).
Debugging a dll
A dll is debugged in the exe that loads it (--host <exe> with -d, the launch's host): its breakpoints come in when the host loads it and go when it unloads.