debug.sethook ([thread,] hook, mask [, count])
Sets the given function as a hook.The string mask
and the number count
describewhen the hook will be called.The string mask may have the following characters,with the given meaning:
"c"
: The hook is called every time Lua calls a function; 当函数被调用的时候触发,且在函数获得参数之前调用;
"r"
: The hook is called every time Lua returns from a function; 当函数返回之前触发hook,且不能在此时获得函数的返回值;
"l"
: The hook is called every time Lua enters a new line of code. 当执行到某一行代码之前触发hook
With a count
different from zero,the hook is called after every count
instructions.
When called without arguments,debug.sethook turns off the hook.
When the hook is called, its first parameter is a stringdescribing the event that has trigger