Syntax
getinfo(target: function | number): tabledebug.getinfoArguments
| Name | Type | Description |
|---|---|---|
target | function | number | Function or stack level number to inspect. |
Returns
| Name | Type | Description |
|---|---|---|
info | table | Metadata table containing func, nups, source, short_src, currentline, what, linedefined, is_vararg, numparams, name, and sizep only for direct Lua function targets. |
Description
Returns a metadata table for a function or stack level. target must be a function or number. Invalid target types raise "function or number expected", invalid stack levels raise "Level out of range", and unavailable levels raise "invalid level". The returned table includes func, nups, source, short_src, currentline, what, linedefined, is_vararg, numparams, and name. sizep is included only for direct Lua function targets. debug.getinfo is an alias.
Call it with 1 parameter(s): target. The argument table explains which values are required and which ones only refine the behavior.
It returns info (table). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Read the metadata table for a function or stack level.
local function target()
return "ready"
end
local info = getinfo(target)
print(info.source)
print(info.currentline)
print(info.numparams)
print(info.sizep)
print(debug.getinfo(target).what)