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 4216D72FFD8; Tue, 12 Dec 2023 15:54:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4216D72FFD8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1702385689; bh=AcLDNEwyDKMQ47e1FrfdMKSUyWZpzV4Xdn8q73BlNCI=; 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=s/NaF3VjIG3sH7CmF6GRvbyqM7L94YeCum+ADmMqxsXx1C+vMhi/9cLrFlUY3O7kP xqurXivNnP/q/ooJeZt7cqAzHBKUldrpD+JKF37kq9xAIS0D95jTwuWDa8qfxX8vMu Bk7/OWL7I/o0ujRXIap3lgMgtKhNXLI18LqCk6/M= Received: from smtp3.i.mail.ru (smtp3.i.mail.ru [95.163.41.67]) (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 2BBB972FFD8 for ; Tue, 12 Dec 2023 15:54:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 2BBB972FFD8 Received: by smtp3.i.mail.ru with esmtpa (envelope-from ) id 1rD2Hf-001c9o-0Q; Tue, 12 Dec 2023 15:54:47 +0300 Date: Tue, 12 Dec 2023 15:54:46 +0300 To: Sergey Kaplun Message-ID: References: <4fb82034fcac21359f79b81cc6643054fc432be3.1701888856.git.m.kokryashkin@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Mailru-Src: smtp X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9B1592A052B88CCADC723B38012FD4A199F6CA7F36E5B91021313CFAB8367EF908E2BE116634AD74D1A9CE0EC9340353F0F3CC0CC2D9C20597E66947654886BD3409B4009A0DB8B7F X-C1DE0DAB: 0D63561A33F958A5A70AD96BE0AD49B637D25F4C321E1215800696E7FB627DA2F87CCE6106E1FC07E67D4AC08A07B9B0735DFC8FA7AC1207CB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0AD5177F0B940C8B66ECE892A7B2722663E91682638B966EB3F662256BEEFA9527F07DA8A022327660AC049744B2C5C2BB3588EBF3751C7DE05C119CA6FC8F54B293556600B6737C2D437FD76D11AF80A0DD2CF19262644A152D793A68207D978F3EA455F16B58544A21C197AAF4D2E4732965026E5D17F6739C77C69D99B9914278E50E1F0597A6FD5CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojm/AwjadTR3RkavaDzUkcHg== X-Mailru-Sender: 11C2EC085EDE56FA38FD4C59F7EFE407B769E237922C7F56C962CB7764835185F2618984F9E88A09D51284F0FE6F529ABC7555A253F5B200DF104D74F62EE79D27EC13EC74F6107F4198E0F3ECE9B5443453F38A29522196 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: Maxim Kokryashkin via Tarantool-patches Reply-To: Maxim Kokryashkin Cc: Maxim Kokryashkin , tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Sergey! Thanks for the review! Fixed, branch is force-pushed, tarantool PR is updated. Iterative diff: === diff --git a/Makefile.original b/Makefile.original index 73995130..4a1e1d9d 100644 --- a/Makefile.original +++ b/Makefile.original @@ -97,7 +97,7 @@ FILES_JITLIB= bc.lua bcsave.lua dump.lua p.lua v.lua zone.lua \ dis_x86.lua dis_x64.lua dis_arm.lua dis_arm64.lua \ dis_arm64be.lua dis_ppc.lua dis_mips.lua dis_mipsel.lua \ dis_mips64.lua dis_mips64el.lua vmdef.lua -FILES_UTILSLIB= avl.lua bufread.lua safe_event_reader.lua symtab.lua +FILES_UTILSLIB= avl.lua bufread.lua evread.lua symtab.lua FILES_MEMPROFLIB= humanize.lua parse.lua process.lua FILES_SYSPROFLIB= parse.lua FILES_TOOLSLIB= memprof.lua sysprof.lua diff --git a/test/tarantool-tests/gh-5688-tool-cli-flag.test.lua b/test/tarantool-tests/gh-5688-tool-cli-flag.test.lua index ec958031..8ead83b5 100644 --- a/test/tarantool-tests/gh-5688-tool-cli-flag.test.lua +++ b/test/tarantool-tests/gh-5688-tool-cli-flag.test.lua @@ -42,7 +42,7 @@ local SMOKE_CMD_SET = { local MEMPROF_CMD_SET = { { cmd = MEMPROF_PARSER .. BAD_PATH, - like = 'Failed to open', + like = 'Failed to open.*fopen, errno: 2', }, { cmd = MEMPROF_PARSER .. TMP_BINFILE_MEMPROF, @@ -61,7 +61,7 @@ local MEMPROF_CMD_SET = { local SYSPROF_CMD_SET = { { cmd = SYSPROF_PARSER .. BAD_PATH, - like = 'Failed to open', + like = 'Failed to open.*fopen, errno: 2', }, { cmd = SYSPROF_PARSER .. TMP_BINFILE_SYSPROF, diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 7f728787..695c079a 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -18,7 +18,7 @@ else() memprof.lua utils/avl.lua utils/bufread.lua - utils/safe_event_reader.lua + utils/evread.lua utils/symtab.lua ) list(APPEND LUAJIT_TOOLS_DEPS tools-parse-memprof) @@ -37,7 +37,7 @@ else() install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/utils/avl.lua ${CMAKE_CURRENT_SOURCE_DIR}/utils/bufread.lua - ${CMAKE_CURRENT_SOURCE_DIR}/utils/safe_event_reader.lua + ${CMAKE_CURRENT_SOURCE_DIR}/utils/evread.lua ${CMAKE_CURRENT_SOURCE_DIR}/utils/symtab.lua DESTINATION ${LUAJIT_DATAROOTDIR}/utils PERMISSIONS @@ -67,7 +67,7 @@ else() sysprof.lua utils/avl.lua utils/bufread.lua - utils/safe_event_reader.lua + utils/evread.lua utils/symtab.lua ) list(APPEND LUAJIT_TOOLS_DEPS tools-parse-sysprof) @@ -84,7 +84,7 @@ else() install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/utils/avl.lua ${CMAKE_CURRENT_SOURCE_DIR}/utils/bufread.lua - ${CMAKE_CURRENT_SOURCE_DIR}/utils/safe_event_reader.lua + ${CMAKE_CURRENT_SOURCE_DIR}/utils/evread.lua ${CMAKE_CURRENT_SOURCE_DIR}/utils/symtab.lua DESTINATION ${LUAJIT_DATAROOTDIR}/utils PERMISSIONS diff --git a/tools/memprof.lua b/tools/memprof.lua index d491b3dc..7d7e8e05 100644 --- a/tools/memprof.lua +++ b/tools/memprof.lua @@ -12,7 +12,7 @@ local memprof = require "memprof.parse" local process = require "memprof.process" -local safe_event_reader = require "utils.safe_event_reader" +local evread = require "utils.evread" local view = require "memprof.humanize" local stdout, stderr = io.stdout, io.stderr @@ -110,7 +110,7 @@ local function dump(inputfile) -- XXX: This function exits with a non-zero exit code and -- prints an error message if it encounters any failure during -- the process of parsing. - local events, symbols = safe_event_reader(memprof.parse, inputfile) + local events, symbols = evread(memprof.parse, inputfile) if not config.leak_only then view.profile_info(events, config) diff --git a/tools/sysprof.lua b/tools/sysprof.lua index 9c0c23c9..420ca41c 100644 --- a/tools/sysprof.lua +++ b/tools/sysprof.lua @@ -1,4 +1,4 @@ -local safe_event_reader = require "utils.safe_event_reader" +local evread = require "utils.evread" local sysprof = require "sysprof.parse" local stdout, stderr = io.stdout, io.stderr @@ -80,7 +80,7 @@ local function dump(inputfile) -- XXX: This function exits with a non-zero exit code and -- prints an error message if it encounters any failure during -- the process of parsing. - local events = safe_event_reader(sysprof.parse, inputfile) + local events = evread(sysprof.parse, inputfile) for stack, count in pairs(events) do print(stack, count) diff --git a/tools/utils/safe_event_reader.lua b/tools/utils/evread.lua similarity index 82% rename from tools/utils/safe_event_reader.lua rename to tools/utils/evread.lua index 39246a9d..394a4a03 100644 --- a/tools/utils/safe_event_reader.lua +++ b/tools/utils/evread.lua @@ -4,12 +4,12 @@ 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)) + io.stderr:write(string.format('\n\t%s\n', err)) os.exit(1, true) end end -local function safe_event_reader(parser, inputfile) +return function(parser, inputfile) local _, reader = xpcall( bufread.new, make_error_handler('Failed to open %s.', inputfile), @@ -30,5 +30,3 @@ local function safe_event_reader(parser, inputfile) ) return events, symbols end - -return safe_event_reader === Regards, Maxim Kokryashkin