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
niland does not run the prototype. Use theactiveoption when you need a live closure.
Functions
| Function | Purpose |
|---|---|
| debug.getconstants | Lists a Lua function's constants by their original indices. |
| debug.getupvalues | Lists a Lua function's captured values by index. |
| debug.getprotos | Lists handles for a Lua function's immediate nested prototypes. |
| debug.getconstant | Reads one Lua constant by its index. |
| debug.getupvalue | Reads one captured value by its index. |
| debug.setconstant | Replaces a Lua constant without changing its value type. |
| debug.setupvalue | Writes a Lua function's captured value. |
| debug.getproto | Reads a nested prototype handle or finds its live closures. |
| debug.getstack | Reads values from a live Lua stack frame. |
| debug.setstack | Writes a slot in the current thread's live Lua stack. |
| debug.getinfo | Returns metadata for a function or reachable stack level. |
| debug.info | Returns selected function information as multiple values. |
| debug.traceback | Formats a traceback for the current or another thread. |
| debug.getcallstack | Lists metadata rows for visible caller stack frames. |
| debug.isvalidlevel | Checks whether a positive stack level is reachable. |
| debug.setname | Updates the debug name of a Lua prototype. |
| debug.setinfo | Updates a Lua prototype's source or name field. |
| debug.getsafeenv | Reads a table's Luau safe-environment flag. |
| debug.setsafeenv | Changes a table's Luau safe-environment flag. |
