Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Interactive Debugger

Lumen has a built-in step debugger (src/debugvm.cpp), reached via --debugger (which requires --run):

lumen program.lmn --compile --dbgsym --run --debugger

Compiling with --dbgsym first is optional but strongly recommended — without it, the debugger shows raw slot indices instead of your variable and routine names.

Starting up

Debugger active. 'help' for list of commands
>>

Commands

CommandDescription
runBegin bytecode execution
stopStop execution
breakpoint set <address>Set a breakpoint at a bytecode offset
breakpoint remove <address>Remove a breakpoint
breakpoint listList all breakpoints
breakpoint clearRemove all breakpoints
pcPrint the current program counter
pc <address>Set the program counter
step / sExecute a single instruction
continueResume execution until the next breakpoint or halt
stackPrint the operand stack, top to bottom
variablesPrint all variable slots and their current values
disassembleShow the disassembled bytecode, with the current PC marked
helpShow the command list

A typical session

>> run
Executing...
Breakpoint hit!
>> stack
Stack (top to bottom):
  [2] {int64: 5}  <- top
  [1] {int64: 3}
  [0] {string: "hello"}
>> variables
Variables:
  [i] {int64: 5}
  [result] {int64: 8}
>> step
>> continue
Execution finished

Addresses for breakpoint and pc are bytecode offsets, not source line numbers — pair --debugger with --disassemble (or the debugger’s own disassemble command) to find the offset you want to break at. If you compiled with --dbgsym, routine names shown by disassemble will help you find the offset where a particular routine begins.