AcediaDocumentation

Debug

Inspect and modify function metadata, constants, captures and live stack frames.

Debug calls inspect functions and live stack frames:

  • Constants, upvalues, and child prototypes use one-based indices. Lists can have holes where a value is nil.
  • An inactive prototype handle can be inspected. Calling one is safe but produces no result: it returns nil and does not run the prototype. Use the active option when you need a live closure.

Functions

FunctionPurpose
debug.getconstantsLists a Lua function's constants by their original indices.
debug.getupvaluesLists a Lua function's captured values by index.
debug.getprotosLists handles for a Lua function's immediate nested prototypes.
debug.getconstantReads one Lua constant by its index.
debug.getupvalueReads one captured value by its index.
debug.setconstantReplaces a Lua constant without changing its value type.
debug.setupvalueWrites a Lua function's captured value.
debug.getprotoReads a nested prototype handle or finds its live closures.
debug.getstackReads values from a live Lua stack frame.
debug.setstackWrites a slot in the current thread's live Lua stack.
debug.getinfoReturns metadata for a function or reachable stack level.
debug.infoReturns selected function information as multiple values.
debug.tracebackFormats a traceback for the current or another thread.
debug.getcallstackLists metadata rows for visible caller stack frames.
debug.isvalidlevelChecks whether a positive stack level is reachable.
debug.setnameUpdates the debug name of a Lua prototype.
debug.setinfoUpdates a Lua prototype's source or name field.
debug.getsafeenvReads a table's Luau safe-environment flag.
debug.setsafeenvChanges a table's Luau safe-environment flag.

On this page