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 7B619468661; Mon, 22 May 2023 10:09:00 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7B619468661 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1684739340; bh=hIucIIIXVZXRYSRe5HVRViEz0HjxLjwLfLehEJs2RB4=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=mdBsgVd6vs5V3WTQrRwX5EB16EJdG9MU4uJRTaiC7j6caByI9eAq+ZwCUQDFkoWZR Ns7boxLvVDVSeEQAypcQ5A/x67tz5OyI4lUedzyAULrrQDxKHm3Z3I4S7m762esUQ+ IFahW9jiD+LC69hxYZ71eccmYNPi3YMoU1Mq5lWQ= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [94.100.181.251]) (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 17A503A611B for ; Mon, 22 May 2023 10:08:59 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 17A503A611B Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1q0zf8-0000t8-Ac; Mon, 22 May 2023 10:08:58 +0300 Date: Mon, 22 May 2023 10:04:53 +0300 To: Maxim Kokryashkin , tarantool-patches@dev.tarantool.org Message-ID: References: <44354d682d3cabf5a3ab1a268f900d7e6f981020.1683720396.git.skaplun@tarantool.org> <1684149117.34095260@f521.i.mail.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD921E8753A900160F1DA5C0D86C5704C541286B838E464C551182A05F5380850407C43B18E33BA897626BD4A0349BD27649F2450B6C0B36951C205B193C510DF59 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE727FD6E7FC3A8F857EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006377EB37407B8EEC8CE8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D83F10E41A19F7D62CE8B3E8627AA6A425117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC6BB7BF01F84D6A81A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352091ADC097FE2C3A08F04B652EEC242312D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6A45692FFBBD75A6A089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A53E05007BFC4B6B4435FC3150985A3DCC5A4B65452BAD0A0CF87CCE6106E1FC07E67D4AC08A07B9B0DB8A315C1FF4794DBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF2F0942B407261CAC6DA456EE44D5A696B6A3ADB9B1373978BCAC81C71148365B1D17C9D1E192534444C44B1DB2C1FC29828DA22BD058152C0EC34CB5E0A245A9C897C70B1EFF344F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojsZq9uZIzxfYXVCPKeXM1tQ== X-DA7885C5: 8384F7A128939B2C461DD730565AB4E3248C4C5FE078F133C6B9AB867E474968262E2D401490A4A0DB037EFA58388B346E8BC1A9835FDE71 X-Mailru-Sender: 689FA8AB762F73930F533AC2B33E986B437FE32C2FFFFA7DA2C7A13B28FF64DC0FBE9A32752B8C9C2AA642CC12EC09F1FB559BB5D741EB962F61BD320559CF1EFD657A8799238ED55FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 1/2] test: add utility for parsing `jit.dump` 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 Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, again! Just some followup fixes, for the previous changes. On 21.05.23, Sergey Kaplun via Tarantool-patches wrote: > > > >>+local function parse_trace_hdr(ctx, line, trace_num, status) > > >>+ local traces = ctx.traces > > >>+ if status == 'start' then > > >>+ local trace = trace_new(trace_num) > > >>+ trace.parent, trace.parent_exitno = line:match('start (%d+)/(%d+)') > > >>+ -- XXX: Assume, that source line can't contain spaces. > > >>+ -- For example, it's not "(command line)". > > >>+ trace.start_loc = line:match(' ([^%s]+)$') > > >>+ traces[trace_num] = trace > > >>+ ctx.parsing_trace = trace_num > > >>+ ctx.parsing = 'bc' > > >>+ elseif status == 'stop' then > > >>+ assert(ctx.parsing_trace == trace_num) > > >>+ ctx.parsing_trace = nil > > >>+ ctx.parsing = nil > > >>+ elseif status == 'abort' then > > >>+ assert(ctx.parsing_trace == trace_num) > > >>+ ctx.parsing_trace = nil > > >>+ ctx.parsing = nil > > >>+ traces[trace_num] = nil > > >Two branches below are almost identical. Is it possible to avoid > > >duplication? > > I suppose, no, especially since we may want to do some more work for > aborted traces (I just don't sure for now). > > > >Side note: Also, I like it much more when switch-like constructions > > >in Lua are implemented with tables, because it seems to be cleaner. > > >Feel free to ignore. > > Rewritten in this way, see the iterative patch below. Branch is > force-pushed. > > =================================================================== > diff --git a/test/tarantool-tests/utils/jit_parse.lua b/test/tarantool-tests/utils/jit_parse.lua > index fe8e0e08..7e8f879e 100644 > --- a/test/tarantool-tests/utils/jit_parse.lua > +++ b/test/tarantool-tests/utils/jit_parse.lua > @@ -64,9 +64,9 @@ local function parse_mcode(trace, line) > trace.mcode[#trace.mcode + 1] = {addr = addr, instruction = instruction,} > end > > -local function parse_trace_hdr(ctx, line, trace_num, status) > - local traces = ctx.traces > - if status == 'start' then > +local header_handlers = { > + start = function(ctx, line, trace_num) > + local traces = ctx.traces > local trace = trace_new(trace_num) > trace.parent, trace.parent_exitno = line:match('start (%d+)/(%d+)') > -- XXX: Assume, that source line can't contain spaces. > @@ -75,23 +75,27 @@ local function parse_trace_hdr(ctx, line, trace_num, status) > traces[trace_num] = trace > ctx.parsing_trace = trace_num > ctx.parsing = 'bc' > - elseif status == 'stop' then > + end, > + stop = function(ctx, line, trace_num) > + local traces = ctx.traces > assert(ctx.parsing_trace == trace_num) > ctx.parsing_trace = nil > ctx.parsing = nil > - elseif status == 'abort' then > + end, > + abort = function(ctx, line, trace_num) > + local traces = ctx.traces > assert(ctx.parsing_trace == trace_num) > ctx.parsing_trace = nil > ctx.parsing = nil > traces[trace_num] = nil > - elseif status == 'IR' then > + end, > + IR = function(ctx, line, trace_num) > ctx.parsing = 'IR' > - elseif status == 'mcode' then > + end, > + mcode = function(ctx, line, trace_num) > ctx.parsing = 'mcode' > - else > - error('Unknown trace status: ' .. status) > - end > -end > + end, > +} > > local function parse_line(ctx, line) > if line == '' then > @@ -105,7 +109,11 @@ local function parse_line(ctx, line) > > local trace_num, status = line:match('TRACE (%d+) (%w+)') > if trace_num then > - parse_trace_hdr(ctx, line, tonumber(trace_num), status) > + if (header_handlers[status]) then > + header_handlers[status](ctx, line, tonumber(trace_num)) > + else > + error('Unknown trace status: ' .. status) > + end > return > end > =================================================================== > Fix luacheck warnings with the following changes: =================================================================== diff --git a/test/tarantool-tests/utils/jit_parse.lua b/test/tarantool-tests/utils/jit_parse.lua index 56267713..bd663196 100644 --- a/test/tarantool-tests/utils/jit_parse.lua +++ b/test/tarantool-tests/utils/jit_parse.lua @@ -65,7 +65,7 @@ local function parse_mcode(trace, line) end local header_handlers = { - start = function(ctx, line, trace_num) + start = function(ctx, trace_num, line) local traces = ctx.traces local trace = trace_new(trace_num) trace.parent, trace.parent_exitno = line:match('start (%d+)/(%d+)') @@ -76,23 +76,22 @@ local header_handlers = { ctx.parsing_trace = trace_num ctx.parsing = 'bc' end, - stop = function(ctx, line, trace_num) - local traces = ctx.traces + stop = function(ctx, trace_num) assert(ctx.parsing_trace == trace_num) ctx.parsing_trace = nil ctx.parsing = nil end, - abort = function(ctx, line, trace_num) + abort = function(ctx, trace_num) local traces = ctx.traces assert(ctx.parsing_trace == trace_num) ctx.parsing_trace = nil ctx.parsing = nil traces[trace_num] = nil end, - IR = function(ctx, line, trace_num) + IR = function(ctx) ctx.parsing = 'IR' end, - mcode = function(ctx, line, trace_num) + mcode = function(ctx) ctx.parsing = 'mcode' end, } @@ -110,7 +109,7 @@ local function parse_line(ctx, line) local trace_num, status = line:match('TRACE (%d+) (%w+)') if trace_num then if (header_handlers[status]) then - header_handlers[status](ctx, line, tonumber(trace_num)) + header_handlers[status](ctx, tonumber(trace_num), line) else error('Unknown trace status: ' .. status) end =================================================================== Branch is force-pushed. > > >-- > > >Best regards, > > >Maxim Kokryashkin > > >  > > -- > Best regards, > Sergey Kaplun -- Best regards, Sergey Kaplun