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 E2D0A750D64; Fri, 29 Dec 2023 15:27:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E2D0A750D64 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1703852870; bh=6tVdX93CGoM+9Pz+LasUSW7dK1XjLAz9rOLjaf2QEi0=; 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=mVzd9MxpwscydhCyrCyLLNjxUWVmPSkuiSjPVaFDpSYUPmLQ9e/qGbSLQqb+B82gw g5neGFHnbuKWqwD7O6uONtswpT7nHKywaMsPxrEdQgU3goxTPZj0Ame4x7b7p7w30x BbHGl7peAqqpEC/4dJWtuJPOj/MlqnPqNcW1d2NY= Received: from smtp57.i.mail.ru (smtp57.i.mail.ru [95.163.41.95]) (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 0E26A4944FE for ; Fri, 29 Dec 2023 15:27:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0E26A4944FE Received: by smtp57.i.mail.ru with esmtpa (envelope-from ) id 1rJBxq-004eeY-0m; Fri, 29 Dec 2023 15:27:46 +0300 Message-ID: Date: Fri, 29 Dec 2023 15:27:46 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Maxim Kokryashkin , tarantool-patches@dev.tarantool.org, skaplun@tarantool.org References: <4fb82034fcac21359f79b81cc6643054fc432be3.1701888856.git.m.kokryashkin@tarantool.org> Content-Language: en-US In-Reply-To: <4fb82034fcac21359f79b81cc6643054fc432be3.1701888856.git.m.kokryashkin@tarantool.org> 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: 4F1203BC0FB41BD9344F665CF1C84C29E9A5DAA3DFF75FA7012FC4F8AC494F3A182A05F5380850404C228DA9ACA6FE27CD563502AAC7EDF5E635F902B63825CE6104997BA577FBF1AFE3C60697F065F7 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE77545ECFDF1E157EBEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006377EB37407B8EEC8CE8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D884F74C944B711BF068D218A34329E122117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC55D5BE2F85BDEC5FA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18E5D25F19253116ADD2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE26055571C92BF10FC0837EA9F3D197644AD6D5ED66289B523666184CF4C3C14F6136E347CC761E07725E5C173C3A84C3A7AC412AE061D85076E601842F6C81A1F004C906525384303E02D724532EE2C3F43C7A68FF6260569E8FC8737B5C22494854413538E1713FE827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B64468F871CB5E8762089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A5997AFB3FBC834BF3C80C38790F6F3F8155B2F8746AAC91C1F87CCE6106E1FC07E67D4AC08A07B9B0CE135D2742255B35CB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF1BBE2E69CB018C6392EE8AF782F99AA89D553C259CB32981D7C4863A5DFAFDE7963129249CAA680A016CD57D7736DB49F28D08490ED26BB486289F5B74F9C5CCA74DFFEFA5DC0E7F02C26D483E81D6BE0DBAE6F56676BC7117BB6831D7356A2DEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojkMbJCS2ejbirrD89O+lPWg== X-Mailru-Sender: 11C2EC085EDE56FAC07928AF2646A769FBDDE5FDB2328EABE635F902B63825CE87D154BA7A9C8918EBA65886582A37BD66FEC6BF5C9C28D98A98C1125256619760D574B6FC815AB872D6B4FCE48DF648AE208404248635DF 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 Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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