debug.getcallstack
Gets visible call frames from the current thread or another thread.
Syntax
debug.getcallstack(thread?: thread) -> {{func: function, currentline: number?}}Parameters
| Parameter | Type | Description |
|---|---|---|
thread | thread? | Thread to inspect; defaults to the current thread |
Returns
| Type | Description |
|---|---|
table | Array of call stack entries |
Description
debug.getcallstack returns non-hidden frames. Each entry contains the function and, for Luau frames, the current source line. OTH hook frames are followed into their linked original thread.
Example
local function innerFunc()
local stack = debug.getcallstack()
for i, entry in ipairs(stack) do
local info = debug.getinfo(entry.func)
print(i, info.name or "anonymous", entry.currentline)
end
end
local function outerFunc()
innerFunc()
end
outerFunc()Entry Fields
| Field | Description |
|---|---|
func | Function running in this frame |
currentline | Current source line for a Luau frame; absent for C frames |
Related Functions
debug.getinfo- Get info for specific leveldebug.validlevel- Check if level is valid