Created
July 31, 2012 13:23
-
-
Save mrwonko/3217014 to your computer and use it in GitHub Desktop.
a lua hook that's called every 1000 instructions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function hook(event) | |
assert(event == "count") | |
local info = debug.getinfo(2, "Sl") -- get source file related info (S) and current line (l) | |
error("Code took to long (over 1000 instructions), aborted at file \"" .. info.short_src .. "\" line " .. info.currentline) | |
end | |
debug.sethook(hook, "", 1000) -- "" = when to call this hook, if any of "every line", "every function call" or "every function return", 1000 = call every 1000 instructions | |
local i = 0 | |
while true do | |
print(i) | |
i = i + 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment