From: Sergey Kaplun via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Maxim Kokryashkin <max.kokryashkin@gmail.com> Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH luajit] test: adapt tests checking debug line hook trace Date: Mon, 11 Oct 2021 18:19:42 +0300 [thread overview] Message-ID: <YWRWDm8VpDSpEhxw@root> (raw) In-Reply-To: <20210924162716.101342-1-m.kokryashkin@tarantool.org> Hi, Maxim! Thanks for the patch! Please consider my comments below. On 24.09.21, Maxim Kokryashkin wrote: > The LuaJIT's virtual machine interprets the bytecode > following the return from function (i.e. the one succeeding > the call made) and located on the line other than that return > bytecode, as a new line trigger for line hooks, unlike Lua > does. > Here is an example (it is joined in one line intend): > > debug.sethook(function(_, l) print("LINE: "..l) end, "l") loadstring("\n\ns=nil")() debug.sethook() > > This chunk prints for LuaJIT: > > LINE: 3 > LINE: 1 > > But for Lua 5.1 it is only "LINE: 3" in the output. > See also https://github.com/tarantool/tarantool/issues/5693. > Considering implementation-defined behaviour difference > (see also https://luajit.org/status.html) test is disabled for > LuaJIT. But the commit adapts the test. Please describe how. > > Closes tarantool/tarantool#5693 > Part of tarantool/tarantool#5845 > Part of tarantool/tarantool#4473 Looks like it should be 5870 instead 4473. Also, 5845 is already closed. > --- > Issue: https://github.com/tarantool/tarantool/issues/5693 > GitHub branch: https://github.com/tarantool/luajit/tree/fckxorg/gh-5693-PUC-Rio-debug-line-hook > > test/PUC-Rio-Lua-5.1-tests/db.lua | 54 ++++++++++++++++--------------- > 1 file changed, 28 insertions(+), 26 deletions(-) > > diff --git a/test/PUC-Rio-Lua-5.1-tests/db.lua b/test/PUC-Rio-Lua-5.1-tests/db.lua > index 56f59ea8..99efe8ef 100644 > --- a/test/PUC-Rio-Lua-5.1-tests/db.lua > +++ b/test/PUC-Rio-Lua-5.1-tests/db.lua > @@ -8,6 +8,26 @@ do > local a=1 > end > > +-- The LuaJIT's virtual machine interprets the bytecode > +-- following the return from function (i.e. the one succeeding > +-- the call made) and located on the line other than that return > +-- bytecode, as a new line trigger for line hooks, unlike Lua > +-- does. > +-- Here is an example (it is joined in one line intend): > +--[[ > +debug.sethook(function(_, l) print("LINE: "..l) end, "l") loadstring("\n\ns=nil")() debug.sethook() > +--]] > +-- This chunk prints for LuaJIT: > +--[[ > +LINE: 3 > +LINE: 1 > +--]] > +-- But for Lua 5.1 it is only "LINE: 3" in the output. > +-- See also https://github.com/tarantool/tarantool/issues/5693. > +-- Considering implementation-defined behaviour difference > +-- (see also https://luajit.org/status.html) test is disabled for > +-- LuaJIT. But it is not disabled after this commit. > +-- This function is modified to correspond with LuaJIT's line triggers. > function test (s, l, p) > collectgarbage() -- avoid gc during trace > local function f (event, line) > @@ -16,7 +36,7 @@ function test (s, l, p) > if p then print(l, line) end > assert(l == line, "wrong trace!!") > end > - debug.sethook(f,"l"); loadstring(s)(); debug.sethook() > + local cur_line = debug.getinfo(1).currentline; table.insert(l, 1, cur_line); table.insert(l, cur_line); debug.sethook(f,"l"); loadstring(s)(); debug.sethook() For what do we need additional insert? And why is it on the same line? > assert(table.getn(l) == 0) > end > > @@ -25,7 +45,7 @@ do <snipped> > @@ -168,8 +170,8 @@ test([[for i,v in pairs{'a','b'} do > end > ]], {1,2,1,2,1,3}) > > -test([[for i=1,4 do a=1 end]], {1,1,1,1,1}) > ---]=] > +-- Test is adapted to the behaviour of LuaJIT. > +test([[for i=1,4 do a=1 end]], {1,1,1,1}) Why are there 4 entries instead 5? > > > print'+' > -- > 2.33.0 > -- Best regards, Sergey Kaplun
prev parent reply other threads:[~2021-10-11 15:21 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-09-24 16:27 Maxim Kokryashkin via Tarantool-patches 2021-10-11 15:19 ` Sergey Kaplun via Tarantool-patches [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=YWRWDm8VpDSpEhxw@root \ --to=tarantool-patches@dev.tarantool.org \ --cc=max.kokryashkin@gmail.com \ --cc=skaplun@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH luajit] test: adapt tests checking debug line hook trace' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox