Version: alpha
FUNCTIONS | |
---|---|
debug.debug() | enters interactive debugging |
debug.getfenv() | returns the environment of an object |
debug.gethook() | returns the current hook settings |
debug.getinfo() | returns a table with information about a function |
debug.getlocal() | returns name and value of a local variable |
debug.getmetatable() | returns the metatable of the given object |
debug.getregistry() | returns the registry table |
debug.getupvalue() | returns the name and value of an upvalue |
debug.setfenv() | sets the environment of an object |
debug.sethook() | sets a debug hook function |
debug.setlocal() | sets the value of the local variable |
debug.setmetatable() | sets the metatable for an object |
debug.setupvalue() | sets an upvalue for a function |
debug.traceback() | returns a string with a traceback of the stack call |
debug.debug()
Enters an interactive mode with the user, running each string that the user enters. Using simple commands and other debug facilities, the user can inspect global and local variables, change their values, evaluate expressions, and so on. A line containing only the word cont finishes this function, so that the caller continues its execution. Note that commands for debug.debug are not lexically nested within any function, and so have no direct access to local variables.
PARAMETERS
None
debug.getfenv(o)
Returns the environment of object o.
PARAMETERS
o |
|
debug.gethook([thread])
Returns the current hook settings of the thread, as three values: the current hook function, the current hook mask, and the current hook count (as set by the debug.sethook function).
PARAMETERS
[thread] |
|
debug.getinfo([thread],function,[what])
Returns a table with information about a function.
You can give the function directly,
or you can give a number as the value of function,
which means the function running at level function of the call stack
of the given thread:
level 0 is the current function (getinfo itself);
level 1 is the function that called getinfo;
and so on.
If function is a number larger than the number of active functions,
then getinfo returns nil.
The returned table can contain all the fields returned by lua_getinfo,
with the string what describing which fields to fill in.
The default for what is to get all information available,
except the table of valid lines.
If present,
the option 'f'
adds a field named func with the function itself.
If present,
the option 'L'
adds a field named activelines with the table of
valid lines.
For instance, the expression debug.getinfo(1,"n").name
returns
a table with a name for the current function,
if a reasonable name can be found,
and the expression debug.getinfo(print)
returns a table with all available information
about the print function.
PARAMETERS
[thread] |
|
|
function |
|
|
[what] |
|
debug.getlocal([thread],level,local)
This function returns the name and the value of the local variable with index local of the function at level level of the stack. (The first parameter or local variable has index 1, and so on, until the last active local variable.) The function returns nil if there is no local variable with the given index, and raises an error when called with a level out of range. (You can call debug.getinfo to check whether the level is valid.) Variable names starting with '(' (open parentheses) represent internal variables (loop control variables, temporaries, and C function locals).
PARAMETERS
[thread] |
|
|
level |
|
|
local |
|
debug.getmetatable(object)
Returns the metatable of the given object or nil if it does not have a metatable.
PARAMETERS
object |
|
debug.getregistry()
Returns the registry table .
PARAMETERS
None
debug.getupvalue(func,up)
This function returns the name and the value of the upvalue with index up of the function func. The function returns nil if there is no upvalue with the given index.
PARAMETERS
func |
|
|
up |
|
debug.setfenv(object,table)
Sets the environment of the given object to the given table. Returns object.
PARAMETERS
object |
|
|
table |
|
debug.sethook([thread],hook,mask,[count])
Sets the given function as a hook. The string mask and the number count describe when the hook will be called. The string mask may have the following characters, with the given meaning:
"c"
"r"
"l"
"call"
, "return"
(or "tail return"
,
when simulating a return from a tail call),
"line"
, and "count"
.
For line events,
the hook also gets the new line number as its second parameter.
Inside a hook,
you can call getinfo with level 2 to get more information about
the running function
(level 0 is the getinfo function,
and level 1 is the hook function),
unless the event is "tail return"
.
In this case, Lua is only simulating the return,
and a call to getinfo will return invalid data.
PARAMETERS
[thread] |
|
|
hook |
|
|
mask |
|
|
[count] |
|
debug.setlocal([thread],level,local,value)
This function assigns the value value to the local variable with index local of the function at level level of the stack. The function returns nil if there is no local variable with the given index, and raises an error when called with a level out of range. (You can call getinfo to check whether the level is valid.) Otherwise, it returns the name of the local variable.
PARAMETERS
[thread] |
|
|
level |
|
|
local |
|
|
value |
|
debug.setmetatable(object,table)
Sets the metatable for the given object to the given table (which can be nil).
PARAMETERS
object |
|
|
table |
|
debug.setupvalue(func,up,value)
This function assigns the value value to the upvalue with index up of the function func. The function returns nil if there is no upvalue with the given index. Otherwise, it returns the name of the upvalue.
PARAMETERS
func |
|
|
up |
|
|
value |
|
debug.traceback([thread],[message],[level])
Returns a string with a traceback of the call stack. An optional message string is appended at the beginning of the traceback. An optional level number tells at which level to start the traceback (default is 1, the function calling traceback).
PARAMETERS
[thread] |
|
|
[message] |
|
|
[level] |
|