debug.getinfo
Example
Let's find out information about net.Receive, such as which file it's defined in, the line it starts and the line it ends, and if it's defined in Lua, or C plus additional information.
Output:
[linedefined] = 7
[currentline] = -1
[func] = function: 0x1a8fae90
[isvararg] = false
[namewhat] =
[lastlinedefined] = 11
[source] = @lua/includes/modules/net.lua
[nups] = 0
[what] = Lua
[nparams] = 2
[short_src] = lua/includes/modules/net.lua