[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua debug hooks
- From: Michal Kolodziejczyk <miko@...>
- Date: Tue, 28 Feb 2012 12:10:10 +0100
On 28.02.2012 02:22, Josh Klint wrote:
> I am not sure what this means, but the hook doesn't seem to get called
> in the manner I expect. If I had a script like below, I would expect
> the hook to be called after executing each line:
> local a = 1 --hook executed!
> local b = a + 1 --hook executed!
> b = b + 2 --hook executed!
>
> Is the functionality I want supported in Lua? Thanks.
Works for me:
$ cat test.lua
function cb(event, nr)
print('HOOK:'..event, nr)
end
debug.sethook(cb, 'l')
local a = 1 --hook executed!
local b = a + 1 --hook executed!
b = b + 2 --hook executed!
$ lua test.lua
HOOK:line 5
HOOK:line 6
HOOK:line 7
Check for yourself at http://www.lua.org/cgi-bin/demo (you may wish to
call debug.sethook() as the last line)
Regards,
miko