Garry's Mod Wiki

DebugInfo

Description

Table returned by debug.getinfo.

If a filter is applied to debug.getinfo, some members may not exist!

For functions defined in C/C++, the following members will always have the given values:

  • what = "C"
  • source = "[C]"
  • nparams = 0
  • isvararg = true
  • namewhat = ""
  • short_src = "[C]"
  • linedefined = -1
  • currentline = -1
  • lastlinedefined = -1

Parameters

function func
Reference to the function that was passed in. If a stack level was specified, this will be the function at that stack level. 0 = debug.getinfo, 1 = function that called debug.getinfo, etc.

Option: f

number linedefined
The line where the function definiton starts (where "function" is located).

Option: S

number lastlinedefined
The line the function definition ended (where "end" is located).

Option: S

string source
The path to the file where the passed function is defined prepended by an @ (ex. "@lua/autorun/mytestfile.lua"). This will be the CompileString or RunString identifier if the function wasn't defined in a file, also prepended by an @.

Option: S

string short_src
The shortened name of the source (without the @). May be truncated if the source path is long.

Option: S

string what
The language used. Either "Lua" or "C".

Option: S

number currentline
The current line. This will be -1 if the code is not executed from a file.

Option: l (lowercase L)

string name
The function name. This will be nil if the name cannot be found. Only works if stack level is passed rather than function pointer.

Option: n

string namewhat
The function "type". This will be "global", "local", "method", "field". Can also be an empty string if the function name could not be found. Only works if stack level is passed rather than function pointer.

Option: n

boolean isvararg
Whether the function is variadic (has a ... argument).

Option: u

number nparams
The number of arguments the function uses excluding varargs.

Option: u

number nups
Upvalue count. Max index that can be used with debug.getupvalue. C functions can have upvalues but they cannot be accessed from Lua.

Option: u

table activelines
A table of all the active lines in the function - that is, lines with code that actually does something (not blank lines or lines with comments only).

The table keys will be line numbers, and their values will all be true. Lines that are inactive are simply not included in the table - they have the value nil.

It doesn't check for activeline in subfunctions.

Option: L