|
Daurnimator,
Thanks for your replay. Did you test in lua5.1.4? Is it same as
lua5.1.5? I will test in lua5.1.5.
2016-06-06
cx0cx2001
发件人: Daurnimator
发送时间: 2016-06-06 00:12:33
收件人: Lua mailing list
抄送:
主题: Re: cannot receive
LUA_HOOKTAILRET event of tail callafterdebug.sethook
On 6 June 2016 at 00:08, cx0cx2001 <cx0cx2001@aliyun.com> wrote:
> The lua version used is lua5.1.4
>
>
> 2016-06-05
> ________________________________
> cx0cx2001
> ________________________________
> 发件人: cx0cx2001
> 发送时间: 2016-06-05 22:04:41
> 收件人: lua-l
> 抄送:
> 主题: cannot receive LUA_HOOKTAILRET event of tail call afterdebug.sethook
> <code>
> function hook(event)
> print(event);
> end
>
> function test1()
> end
>
> function test()
> return test1();
> end
>
> debug.sethook(hook, "cr");
> test();
> </code>
>
> The output of the above code is following:
> call
> call
> return
>
> The count of return hook is not same as the count of call hook.
> I found that the return or tailretun event is missing when there is tail
> call.
> Because of this bug, it's impossible to collect the function's execute
> time(between call hook and return hook) of lua code.
>
> 2016-06-05
> ________________________________
> cx0cx2001
Please do not send HTML formatted email; and please bottom post.
In Lua 5.1.5 I get:
return
call
call
return
tail return
return
In Lua 5.3.2 I get:
return
call
tail call
return
return
The first `return` in both outputs is debug.sethook itself returning,
the final `return` in both outputs is the test itself finishing. These
can be ignored for the sake of your example.
In 5.1 if you count +1 for each "call", and -1 for each "return" or
"tail return" it is balanced:
0
call --> 1
call --> 2
return --> 1
tail return --> 0
|