Debugger session returned by debugger.open().
@eryx/debugger Module
Debug Luau programs from Luau code.
The debugger library runs a target program under debugger control and exposes the primitives needed by debuggers and editor adapters: session lifecycle, event delivery, source lookup, breakpoints, coroutine threads, stack frames, scopes, variable inspection, expression evaluation, variable assignment, exception details, output events, stepping, pausing, termination, and VM bytecode disassembly.
Use debugger.open() to create a Session. Configure the session before
starting it, usually by setting breakpoints, then call Session:start() and
read events with Session:wait(). When a stopped event is received, use
the event's threadId with Session:frames(), then inspect frames with
Session:scopes(), Session:inspect(), Session:evaluate(), or
Session:setVariable(). Resume execution with Session:resume() or
Session:step().
Luau coroutines are reported as debugger threads. Thread identifiers are stable for known coroutines within a session. Frame, scope, evaluation, and mutation operations are guaranteed for the current stopped thread; other known threads may be listed even when they do not have inspectable frames.
Summary
Classes
Functions
API Reference
Classes
Session
Properties
Session:start
Starts the debuggee once breakpoints and listeners are configured.
Session:wait
⚠ YieldsWaits for and returns the next debugger event.
Returns
Next debugger event, or nil when the session has ended and no events remain.
Session:state
Returns the current coarse session state.
Returns
Current session state.
Session:threads
Returns known Luau coroutine threads in the debuggee.
Returns
Known threads for the session.
Session:resume
Resumes execution for a thread or the whole debuggee.
Parameters
Thread to resume. Omit to resume the current paused debuggee.
Session:pause
Requests that execution pause at the next source-backed interrupt point.
Parameters
Thread to pause. Omit to pause the next eligible running thread.
Session:step
Steps a paused thread using the requested mode.
Parameters
Session:terminate
Requests debugger termination and debuggee shutdown.
Session:close
Closes the session, optionally terminating the debuggee first.
Parameters
Whether to terminate a live debuggee before closing. Defaults to true.
Session:sources
Lists sources currently known to the debugger.
Returns
Known sources.
Session:readSource
Reads source text for a known source.
Parameters
Returns
Source text, or an empty string when the source cannot be read.
Session:setBreakpoints
Replaces source breakpoints for a source.
Parameters
Breakpoints to set for the source.
Returns
Resolved breakpoint records.
Session:clearBreakpoints
Clears source breakpoints for one source, or all user breakpoints when omitted.
Parameters
Session:frames
Returns stack frames for a thread.
Parameters
Thread whose frames should be returned. Omit to use the current stopped thread.
Zero-based frame offset.
Maximum number of frames to return.
Returns
Frame page and total frame count.
Session:scopes
Returns the visible scopes for a frame.
Parameters
Frame identifier captured during the current pause.
Returns
Scopes visible from the frame.
Session:inspect
Expands values referenced by a scope or prior inspection result.
Parameters
Value expansion request.
Returns
Expanded child values.
Session:evaluate
Evaluates code in the context of a paused frame.
Parameters
Luau expression or, when allowed, statement chunk to evaluate.
Evaluation options.
Returns
Evaluation result containing either a value or an error.
Session:setVariable
Assigns a variable or table child referenced by a scope or inspection result.
Parameters
Scope or value reference containing the variable.
Variable name or table key to assign.
Luau expression used to produce the assigned value.
Assignment options.
Returns
Assignment result containing either the new value or an error.
Session:disassemble
Returns a VM bytecode disassembly for a source or paused frame.
Parameters
Source, source descriptor, or disassembly options. Omit to disassemble the program source.
Returns
Human-readable bytecode listing.
Session:exception
Returns the currently captured exception, if any.
Parameters
Thread whose exception should be queried. Omit to query the current stopped thread.
Returns
Captured exception details, or nil when no exception is available.
Functions
debugger.open
Opens a debugger session for a Luau program.
The debuggee is not started until Session:start() is called. Configure
breakpoints and event consumers before starting the session.
Parameters
Session options. options.program is required.
Returns
New debugger session.
debugger.breakpoint
Breaks into the active debugger from inside the debuggee.
Call this from debuggee code to emit a stopped event with reason
"manual". If the current runtime is not running under debugger.open(),
the call has no effect.
Types
ThreadId
Identifies a Luau coroutine thread within a session.
FrameId
Identifies a stack frame captured during the current pause.
BreakpointId
Identifies a source breakpoint within a session.
SessionState
Session lifecycle state.
ThreadState
Debugger-visible state for a known coroutine thread.
StopReason
Stop reason reported by a stopped event.
EvaluateContext
Evaluation context supplied by debugger clients.
OutputStream
Output stream category.
ValueKind
Category of an expandable debugger value.
Source
Source file or chunk known to the session.
Stable debugger-facing source identifier.
Human-friendly label, usually the source basename.
Concrete filesystem path when the source is file-backed.
Optional source category such as "file" or "embedded".
Thread
Luau coroutine thread known to the session.
Stable thread identifier within the session.
Human-friendly thread name.
Current debugger-visible thread state.
Reason this thread is paused, when state is "paused".
BreakpointSpec
Breakpoint request passed to Session:setBreakpoints().
Requested one-based source line.
Optional one-based source column.
Expression that must evaluate truthy before the breakpoint stops.
Hit-count expression such as "3", ">= 5", or "% 2".
Logpoint message. Braced expressions are evaluated at the hit location.
Breakpoint
Breakpoint returned by Session:setBreakpoints().
Stable breakpoint identifier when the breakpoint was accepted.
Source where the breakpoint was requested or resolved.
One-based resolved or requested source line.
One-based resolved or requested source column.
Whether the debugger could bind this breakpoint to loaded code.
Human-readable explanation when the breakpoint is pending or rejected.
Frame
Stack frame returned by Session:frames().
Stable frame identifier for the current pause.
Thread that owns this frame.
Function or chunk name for display.
Source location for this frame, when available.
One-based source line.
One-based source column.
VM instruction program counter, when available.
Debugger instruction identifier for disassembly-oriented clients.
Scope
Variable scope returned by Session:scopes().
Scope display name, such as "Locals" or "Registers".
Kind of values exposed by this scope.
Value reference used to expand the scope with inspect.
Whether expanding the scope may be relatively expensive.
Number of named children when known.
Number of array-like children when known.
Source associated with this scope, when available.
One-based source line associated with this scope, when available.
One-based source column associated with this scope, when available.
Value
Value returned by Session:inspect(), Session:evaluate(), or
Session:setVariable().
Display name for the value.
Human-readable value summary.
Luau type name or debugger-specific type label.
Value reference for expansion, or 0 when the value has no children.
Kind of value reference.
Number of named children when known.
Number of array-like children when known.
Expression that can be evaluated to retrieve this value again.
InspectQuery
Expansion request for Session:inspect().
Scope or value reference to expand.
Zero-based child offset.
Maximum number of children to return.
Child category to return.
Whether numeric summaries should prefer hexadecimal formatting.
EvaluateOptions
Options for Session:evaluate().
Frame used as the lexical evaluation context.
UI or protocol context for the evaluation request.
Whether numeric summaries should prefer hexadecimal formatting.
Whether statement chunks may run when expression evaluation fails.
SetVariableOptions
Options for Session:setVariable().
Frame used as the lexical evaluation context for the assigned expression.
Whether numeric summaries should prefer hexadecimal formatting.
DisassembleOptions
Options for Session:disassemble().
Frame whose source should be disassembled when source is omitted.
Whether local-variable debug information should be included.
Whether compiler remarks should be included.
Whether type debug information should be included.
EvaluateResult
Result returned by Session:evaluate() and Session:setVariable().
Exception
Exception details captured for an exception stop.
Exception identifier or category.
Primary exception message.
Luau exception type name when available.
Human-readable exception description.
Formatted stack trace.
Source associated with the selected exception location.
One-based source line associated with the exception.
One-based source column associated with the exception.
SessionEventState
Event emitted when the session state changes.
Event discriminator.
New session state.
Thread related to the state change, when available.
SessionEventStopped
Event emitted when the debuggee stops.
Event discriminator.
Thread that stopped.
Reason execution stopped.
Human-readable stop description.
Additional stop text, such as an exception message.
Breakpoints hit by this stop.
Source location for the stop.
One-based source line for the stop.
One-based source column for the stop.
SessionEventOutput
Event emitted for debuggee or debugger output.
Event discriminator.
Output stream category.
Output text.
Source associated with the output, when available.
One-based source line associated with the output.
One-based source column associated with the output.
SessionEventSource
Event emitted when a source is added, changed, or removed.
Event discriminator.
Source that changed.
SessionEventTerminated
Event emitted when the debuggee terminates.
Event discriminator.
Process-style exit code when available.
SessionEvent
Event returned by Session:wait().
SessionOptions
Options for debugger.open().
Entry file for the debuggee.
Command-line arguments visible to the debuggee.
Whether to pause before the first line executes.
Whether native codegen should be enabled for the debuggee.
Luau optimization level used to compile the debuggee.