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 F3C4D96D1EA; Tue, 16 Jan 2024 12:48:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org F3C4D96D1EA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1705398492; bh=6knHHi7gdfPj3n1AYLsJ3uyVlAlvA1/Pzg64AfQt7Mk=; 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=ns3hJ1hCZKU4FgK+iEz6yOJYaxJnjzzCE1DP3LrUcSQbSvCDbIMh3o7ZO+svwtCRb X8hDjBMLJicvJS51OQXwZ/4dop9VmQJbcwnh5t1GF29fyZVg/FGPWx7ciRegVUXy7B sNiMpJA6gbD0gkSK8KTppYiUAzPbYGmhUlFsgRhw= Received: from smtp41.i.mail.ru (smtp41.i.mail.ru [95.163.41.64]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 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 9624B96D1E5 for ; Tue, 16 Jan 2024 12:48:10 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9624B96D1E5 Received: by smtp41.i.mail.ru with esmtpa (envelope-from ) id 1rPg3F-0068W9-1r; Tue, 16 Jan 2024 12:48:10 +0300 Message-ID: <79141a96-6ec2-45e0-862e-fddb2fc29885@tarantool.org> Date: Tue, 16 Jan 2024 12:48:09 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Maxim Kokryashkin References: <4fb82034fcac21359f79b81cc6643054fc432be3.1701888856.git.m.kokryashkin@tarantool.org> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD912D89AD53D86C3F6C62244C793131C12AFF7AC58A8196FFB1313CFAB8367EF908E2BE116634AD74DD4F96BC8AF537F1B70464DA3F47EA4D9965C3C3A77F08F3547D41910D6C19DC5 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE754CF51794FD91028EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637B34A545A74F29B438638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D837F5D1C077DF827805900EFA748E7D1D117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC55D5BE2F85BDEC5FA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751FC26CFBAC0749D213D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE26055571C92BF10F1AB2475877E8919AD8FC6C240DEA76429C9F4D5AE37F343AA9539A8B242431040A6AB1C7CE11FEE3BC0ADEB1C81BB362040F9FF01DFDA4A8C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947C1D471462564A2E192E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89F9FFED5BD9FB4175535872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-C1DE0DAB: 0D63561A33F958A5B924EBAF3B8606D7D710D43003F12D6D704932623D02D7DDF87CCE6106E1FC07E67D4AC08A07B9B0A816C540FC8EEC30CB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF8CB3AA842EEC30A9CC83172779DD00656CB4212719F524FA91196741671400DDB9228B76B87D064D151C858F58AF3247E805C0749718F8EF491A128D87370C0EA74DFFEFA5DC0E7F02C26D483E81D6BE0DBAE6F56676BC7117BB6831D7356A2DEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioji89z+8RvaBNYFLoR3W3ghw== X-Mailru-Sender: 11C2EC085EDE56FAC07928AF2646A769CAEF76AC3C549545BAA14660C4F6EBA9FA95C477BC5130F8EBA65886582A37BD66FEC6BF5C9C28D98A98C1125256619760D574B6FC815AB872D6B4FCE48DF648AE208404248635DF X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit v2 6/6] profilers: print user-friendly errors 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 Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Cc: Maxim Kokryashkin , tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Max, thanks for corerections! LGTM On 1/9/24 16:54, Maxim Kokryashkin wrote: > Hi, Sergey! > Thanks for the review! > Fixed your minor, branch is force-pushed. Here is the diff: > === > diff --git a/tools/memprof/parse.lua b/tools/memprof/parse.lua > index cc66a23e..11a79a1d 100644 > --- a/tools/memprof/parse.lua > +++ b/tools/memprof/parse.lua > @@ -206,12 +206,13 @@ function M.parse(reader, symbols) > local _ = reader:read_octets(3) > > if magic ~= LJM_MAGIC then > - error("Bad LJM format prologue: "..magic) > + error("Bad memprof event format prologue: "..magic) > end > > if string.byte(version) ~= LJM_CURRENT_VERSION then > error(string_format( > - "LJM format version mismatch: the tool expects %d, but your data is %d", > + "Memprof event format version mismatch:".. > + " the tool expects %d, but your data is %d", > LJM_CURRENT_VERSION, > string.byte(version) > )) > diff --git a/tools/sysprof/parse.lua b/tools/sysprof/parse.lua > index 749f70db..0e416d37 100755 > --- a/tools/sysprof/parse.lua > +++ b/tools/sysprof/parse.lua > @@ -237,12 +237,13 @@ function M.parse(reader, symbols) > local _ = reader:read_octets(3) > > if magic ~= LJP_MAGIC then > - error("Bad LJP format prologue: " .. tostring(magic)) > + error("Bad sysprof event format prologue: " .. tostring(magic)) > end > > if string.byte(version) ~= LJP_CURRENT_VERSION then > error(string_format( > - "LJP format version mismatch: the tool expects %d, but your data is %d", > + "Sysprof event format version mismatch:".. > + " the tool expects %d, but your data is %d", > LJP_CURRENT_VERSION, > string.byte(version) > )) > diff --git a/tools/utils/symtab.lua b/tools/utils/symtab.lua > index c4aefef7..e80b9f33 100644 > --- a/tools/utils/symtab.lua > +++ b/tools/utils/symtab.lua > @@ -95,13 +95,13 @@ function M.parse(reader) > local _ = reader:read_octets(3) > > if magic ~= LJS_MAGIC then > - error("Bad LJS format prologue: " .. tostring(magic)) > + error("Bad LuaJIT symbol table format prologue: " .. tostring(magic)) > end > > if string.byte(version) ~= LJS_CURRENT_VERSION then > error(string_format( > - "LJS format version mismatch:".. > - "the tool expects %d, but your data is %d", > + "LuaJIT symbol table format version mismatch:".. > + " the tool expects %d, but your data is %d", > LJS_CURRENT_VERSION, > string.byte(version) > )) > === > > WBR, > Max > On Fri, Dec 29, 2023 at 03:27:46PM +0300, Sergey Bronnikov wrote: >> Hello, Max >> >> >> thanks for the patch. LGTM with minor comments >> >> >> On 12/6/23 21:55, Maxim Kokryashkin wrote: >> >> >> >> >>> diff --git a/tools/sysprof/parse.lua b/tools/sysprof/parse.lua >>> index 64c4a455..749f70db 100755 >>> --- a/tools/sysprof/parse.lua >>> +++ b/tools/sysprof/parse.lua >>> @@ -237,7 +237,7 @@ function M.parse(reader, symbols) >>> local _ = reader:read_octets(3) >>> if magic ~= LJP_MAGIC then >>> - error("Bad LJP format prologue: "..magic) >>> + error("Bad LJP format prologue: " .. tostring(magic)) >>> end >> LJP is not a well-known abbreviation. Probably, it is better to write the >> error >> >> message without it. I see that LJP/LJS is used extensively in error message, >> so feel free to >> >> ignore or fix in a separate patch. >> >>> if string.byte(version) ~= LJP_CURRENT_VERSION then >>> diff --git a/tools/utils/safe_event_reader.lua b/tools/utils/safe_event_reader.lua >>> new file mode 100644 >>> index 00000000..39246a9d >>> --- /dev/null >>> +++ b/tools/utils/safe_event_reader.lua >>> @@ -0,0 +1,34 @@ >>> +local bufread = require('utils.bufread') >>> +local symtab = require('utils.symtab') >>> + >>> +local function make_error_handler(fmt, inputfile) >>> + return function(err) >>> + io.stderr:write(string.format(fmt, inputfile)) >>> + io.stderr:write(string.format('\nOriginal error: %s', err)) >>> + os.exit(1, true) >>> + end >>> +end >>> + >>> +local function safe_event_reader(parser, inputfile) >>> + local _, reader = xpcall( >>> + bufread.new, >>> + make_error_handler('Failed to open %s.', inputfile), >>> + inputfile >>> + ) >>> + >>> + local _, symbols = xpcall( >>> + symtab.parse, >>> + make_error_handler('Failed to parse symtab from %s.', inputfile), >>> + reader >>> + ) >>> + >>> + local _, events = xpcall( >>> + parser, >>> + make_error_handler('Failed to parse profile data from %s.', inputfile), >>> + reader, >>> + symbols >>> + ) >>> + return events, symbols >>> +end >>> + >>> +return safe_event_reader >>> diff --git a/tools/utils/symtab.lua b/tools/utils/symtab.lua >>> index 0c878e7a..c4aefef7 100644 >>> --- a/tools/utils/symtab.lua >>> +++ b/tools/utils/symtab.lua >>> @@ -95,7 +95,7 @@ function M.parse(reader) >>> local _ = reader:read_octets(3) >>> if magic ~= LJS_MAGIC then >>> - error("Bad LJS format prologue: "..magic) >>> + error("Bad LJS format prologue: " .. tostring(magic)) >> LJS is not a well-known abbreviation. Probably, it is better to write the >> error >> >> message without it. >> >>> end >>> if string.byte(version) ~= LJS_CURRENT_VERSION then