Expand description
Debug Adapter Protocol over stdio (node --dap).
A single-threaded source-line debugger. The program is compiled with
per-statement line markers (Op::CallBuiltin(DBG_LINE, 1), emitted only in
this mode — normal runs carry zero extra ops) and run on the pure interpreter
(the tracing JIT would compile hot loops and skip the markers, so --dap
compiles with set_debug_mode(true), which installs the marker hook instead
of enable_tracing_jit). The DBG_LINE builtin fires synchronously at each
marker; when it lands on a breakpoint or a step target it pauses IN PLACE and
services DAP requests (stackTrace/scopes/variables/continue/next/
stepIn/stepOut) from stdin until a resume command, then returns control to
the VM.
Because it is single-threaded, an async pause of a free-running program is
not supported (the adapter only reads requests while stopped at a marker);
breakpoints and stepping — the load-bearing features — work inside function,
loop, and try/catch bodies. Program stdout is redirected to a pipe during the
run and forwarded as output events, so console.log/process.stdout.write
never corrupt the JSON protocol channel on the saved stdout fd.
Functions§
- on_
debug_ line - Called by the VM at each statement marker (via the
DBG_LINEbuiltin, which passes the marker’s sourceline). If it is a breakpoint or the active step target, pauses and services DAP requests until a resume command. - on_ext
- Extension-handler shim kept for the
Op::Extendeddispatch seam registered inhost::run_chunk_on. node-js emitsDBG_LINEasOp::CallBuiltin, notOp::Extended, so in the current wiring the live hook ison_debug_line(invoked from theDBG_LINEbuiltin — seebuiltins::b_dbg_line). This shim routes anExtended(DBG_LINE)marker to the same logic should the emission seam ever be switched, and is a no-op for every other extension id. - run
- Entry point for
node --dap.