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 9E9D76EC40; Fri, 24 Sep 2021 19:27:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9E9D76EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1632500843; bh=/oDadQkF4qi4hjGuq2NSo/wIfv/Xp9Q+hRoQH5cJUuA=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=g6NT5O8wxqkOv+WeWI4Le8XeyYrcMJXf3bby/qq7YIV3+RtOYed9zv9nf+g4L7eDj qgr6KqkVRoGUJAO0pqB2eI1OUnvFpg31AoE5mXIBaKQ50n1nqgcDKT1t4iXKkV2+YP 9ZBbDOsQ0snmVoOQSDfmgfxClj3eIeFvLSiK5z7E= Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id D8BD86EC40 for ; Fri, 24 Sep 2021 19:27:20 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D8BD86EC40 Received: by mail-lf1-f54.google.com with SMTP id z24so43273185lfu.13 for ; Fri, 24 Sep 2021 09:27:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lmjJ6YkXw8bEXxC+kei/O8OY64xBmIF5OpnJPeSbfnU=; b=05UPBbnsKN3FVyIjUPPJYrn3HifNqaO8xGFwZtC6qUpFy6KQ3+PDi4kXfRdOz2GiDw rT2gpnXe+4Dlo0DvTsBB5MKwxRFv7r/ceZcfsry8/V/dvrBO/BXgnShE0tSPjYnRMj8x wQ3Jpp8Z2oGNfTBE4OSbfXiGLP1IXkxhU0poH9rCQNr9RSapi13TMYBjE0JJPSnxbDzb pWmVVrw4GqmqAeFO7KSkR03dD7zFMpcTBUqoieThc1ZtCJcJ8E7AjkT2jJuCYaSLUYdQ IoqSXM3rJKMudqyiRKahGyJWokyQ7wZhTURyA8K8amgJYEAq8AbTXZVFYMETSNSHoKD8 e97w== X-Gm-Message-State: AOAM530cXCAqkH2H+aauPnbCwxKhfq4RkKughhgZBpB9HPTXwh5dk8PE e3jS1KZpHiLwD2qgEkKtzZbjsdYGdLCbdQi3 X-Google-Smtp-Source: ABdhPJxoh2LpxWQMtjuotBuNdvB+TzUh5tyRTUrLv9FTQ6CeupG+XZDD3Ms0muFn3X6A9yxDayK5xA== X-Received: by 2002:ac2:5c46:: with SMTP id s6mr9799796lfp.634.1632500839518; Fri, 24 Sep 2021 09:27:19 -0700 (PDT) Received: from localhost.localdomain ([93.175.11.199]) by smtp.gmail.com with ESMTPSA id r16sm793602lfi.182.2021.09.24.09.27.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:27:18 -0700 (PDT) X-Google-Original-From: Maxim Kokryashkin To: tarantool-patches@dev.tarantool.org, imun@tarantool.org, skaplun@tarantool.org Date: Fri, 24 Sep 2021 19:27:16 +0300 Message-Id: <20210924162716.101342-1-m.kokryashkin@tarantool.org> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit] 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: Maxim Kokryashkin via Tarantool-patches Reply-To: Maxim Kokryashkin Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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. Closes tarantool/tarantool#5693 Part of tarantool/tarantool#5845 Part of tarantool/tarantool#4473 --- 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. +-- 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() assert(table.getn(l) == 0) end @@ -25,7 +45,7 @@ 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 + assert(b.name == nil and b.what == "Lua" and b.linedefined == 31 and b.lastlinedefined == b.linedefined + 10 and b.func == test and not string.find(b.short_src, "%[")) assert(b.activelines[b.linedefined + 1] and @@ -95,26 +115,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 +132,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 +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}) print'+' -- 2.33.0