From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id D53C36ECC0; Thu, 16 Dec 2021 18:26:37 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D53C36ECC0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1639668398; bh=67uHuC1iKVedZsObrt9WUV892FSipOlmfgfaj8UHBNY=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=jmvekfZhPEsE8RougUoyQJkc1zsFxpgYV3LPx/ZvkQD66YtyIvHg4PQvRsVrV2wE/ rnnStvodFKFh2oqzlVZleY12VFsepLW0wkr0WqWVUNZdTrCM6dd6tZKwmNqRLIQd5w ox8YJ059oOPGMbDTW1enzfszgotvzW6ceksFVQnU= Received: from smtp63.i.mail.ru (smtp63.i.mail.ru [217.69.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 325276ECC0 for ; Thu, 16 Dec 2021 18:26:37 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 325276ECC0 Received: by smtp63.i.mail.ru with esmtpa (envelope-from ) id 1mxseR-0000H4-TT; Thu, 16 Dec 2021 18:26:36 +0300 Date: Thu, 16 Dec 2021 18:24:46 +0300 To: Maxim Kokryashkin Message-ID: References: <20211110192042.1687467-1-m.kokryashkin@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211110192042.1687467-1-m.kokryashkin@tarantool.org> X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9FFF274446F725B74DDE9CB69FF4D5D3930584F29715B0AC6182A05F53808504034EE8EA0397A2B331144FECF81DBD9AF53F649FDE152232002404EAAFE44B5E3 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7F65C230EDDCD559EEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006371E92E38DA2D50EB18638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8F292B30DF3313A90EE1DF8AD76000EE9117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF1175FABE1C0F9B6A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735209ECD01F8117BC8BEA471835C12D1D977C4224003CC8364762BB6847A3DEAEFB0F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7CB1724D34C644744043847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A59F567FD52231CDCED9CF6D577729FE625FFAFC5A85FC561ED59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA759D2A03B9C34326B3410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D340A59E724FC7897F72AA0CF1AC09DB027BCD699CE884483408D8C7B2A7D64A3D30FB69FFBE0C24AF61D7E09C32AA3244C22DCB3ABCDCE8B55FC9E0DBD9AB4DBB9F165894D92D62706927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojwI6cKrhU01LES95aLvAXrA== X-Mailru-Sender: 3B9A0136629DC91206CBC582EFEF4CB420B544EF2D432C1C7C1E71DF7933A6301AA88FDC92D805A5F2400F607609286E924004A7DEC283833C7120B22964430C52B393F8C72A41A84198E0F3ECE9B5443453F38A29522196 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit v2] test: adapt tests checking debug line hook trace X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Maxim! Thanks for the fixes! LGTM, except a few nits below. Am I right that this CI branch [1] is the latest one? Also, please align comments with linewidth 66 symbols. On 10.11.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 tarantool/tarantool#5693. Nit: this see also is excess (as far as this patch resolves the ticket). > > Those tests are adapted to LuaJIT behavior by changing assertions > considering line events that LuaJIT generates. > > Part of tarantool/tarantool#5870 It's OK to mention that this patch "Resolves tarantool/tarantool#5693". > --- > Changes in v2: > - Fixed comments as per review by Sergey > - Added some comments > > test/PUC-Rio-Lua-5.1-tests/db.lua | 57 +++++++++++++++++-------------- > 1 file changed, 31 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..120fc04c 100644 > --- a/test/PUC-Rio-Lua-5.1-tests/db.lua > +++ b/test/PUC-Rio-Lua-5.1-tests/db.lua > @@ -8,6 +8,23 @@ 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. > +-- 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,6 +33,11 @@ function test (s, l, p) > if p then print(l, line) end > assert(l == line, "wrong trace!!") > end > + -- Despite `loadstring` and `debug.sethook` are on the same line, LuaJIT > + -- generates separate line events for them. The test is adapted to LuaJIT > + -- behavior by adding corresponding line numbers into the test table. > + table.insert(l, 1, 41) > + table.insert(l, 41) > debug.sethook(f,"l"); loadstring(s)(); debug.sethook() > assert(table.getn(l) == 0) > end > @@ -25,8 +47,8 @@ do > local a = debug.getinfo(print) > assert(a.what == "C" and a.short_src == "[C]") > local b = debug.getinfo(test, "SfL") > - assert(b.name == nil and b.what == "Lua" and b.linedefined == 11 and > - b.lastlinedefined == b.linedefined + 10 and > + assert(b.name == nil and b.what == "Lua" and b.linedefined == 28 and > + b.lastlinedefined == b.linedefined + 15 and > b.func == test and not string.find(b.short_src, "%[")) > assert(b.activelines[b.linedefined + 1] and > b.activelines[b.lastlinedefined]) > @@ -95,26 +117,6 @@ repeat > assert(g(f) == 'a') > until 1 > > --- FIXME: 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. > ---[=[ > test([[if > math.sin(1) > then > @@ -132,23 +134,25 @@ else > end > ]], {2,5,6}) > > +-- Test is adapted to the behaviour of LuaJIT. > test([[a=1 > repeat > a=a+1 > until a==3 > -]], {1,3,4,3,4}) > +]], {1,2,3,4,2,3,4}) > > test([[ do > return > end > ]], {2}) > > +-- Test is adapted to the behaviour of LuaJIT. > test([[local a > a=1 > while a<=3 do > a=a+1 > end > -]], {2,3,4,3,4,3,4,3,5}) > +]], {1,2,3,4,3,4,3,4,3,5}) > > test([[while math.sin(1) do > if math.sin(1) > @@ -168,8 +172,9 @@ 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, as it generates only four line > +-- events, unlike Lua, which generates five of them. > +test([[for i=1,4 do a=1 end]], {1,1,1,1}) > > > print'+' > -- > 2.33.0 > [1]: https://github.com/tarantool/tarantool/tree/fckxorg/gh-5693-PUC-Rio-debug-line-hook -- Best regards, Sergey Kaplun