Garry's Mod Wiki

debug.getinfo

table debug.getinfo( function funcOrStackLevel, string fields = "flnSu" )

Description

Returns debug information about a function.

Arguments

1 function funcOrStackLevel
Takes either a function or a number representing the stack level as an argument. Stack level 0 always corresponds to the debug.getinfo call, 1 would be the function calling debug.getinfo, and so on.

Returns useful information about that function in a table.

2 string fields = "flnSu"
A string whose characters specify the information to be retrieved.

  • f - Populates the func field.
  • l - Populates the currentline field.
  • L - Populates the activelines field.
  • n - Populates the name and namewhat fields - only works if stack level is passed rather than function pointer.
  • S - Populates the location fields (lastlinedefined, linedefined, short_src, source and what).
  • u - Populates the argument and upvalue fields (isvararg, nparams, nups)

Returns

1 table
A table as a Structures/DebugInfo containing information about the function you passed. Can return nil if the stack level didn't point to a valid stack frame.

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.

PrintTable( debug.getinfo( net.Receive ) )
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

Page Links


Special Pages


Wikis

?

Render Time: 39ms

DB GetPage 2
Generate Html 13
SaveChanges (1) 9
Render Body 0
Render Sidebar 11