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 0E5B09DA75A; Wed, 13 Mar 2024 17:43:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0E5B09DA75A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1710341005; bh=cfbXzUjxs0M9/bXV4+ftiGJ8jd7pOWI5bD4kCQzy3Uo=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=eugpBEq6uCEi1rWolf1nFRB6Qn29VpdanVY/LX4mgRkufqcEE00wD6WNEgPxq/wpF 4+OvP6DKUETqCgImiQerkyZYJo0KYz4rvTgwN50oDJrtHCrfo0JVD/53QoK4LjoCg9 VPyg3kWMJscAF93urMywNs5zvczvFIsLOP7UxRZk= Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (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 B743BDC5B98 for ; Wed, 13 Mar 2024 17:40:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B743BDC5B98 Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2d4698f4936so17005871fa.1 for ; Wed, 13 Mar 2024 07:40:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710340831; x=1710945631; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RjfVgRjn5Bi8lNpavLiFc5vxsnoEjop3TEejZKRGyp4=; b=A8tM2vzEW3IvRHoXJlwiUuKHm/5p343RxGHLbgXblh2ekzc5WCPBf7VhXLAlDjmFM0 HMSEB5N7QBcQrPjMQBTK74RMb+3vFiNymbzderYIYmlWb5rSdybTsTLAk/ICMQzi2WkL 15oxPWpU5ySVvOdcg9xKCsDZ3bWiEsGm32PuOgtWDhjN5eSbOtV9BpX9j1B4c7KJlVvb DQ1dN6h2gZqz0wN3YnYbqW+UUrxrwjt62G/nwdmXqhhAk5+fZHiaozqLfxhKO/4ZfTVk rtqkOqFbi137zPSr9OtKtkT6Cv61u8Sp/GwUbJKuIWFOIbjm6YjSKkiUjr05hpqobNC+ MAIQ== X-Gm-Message-State: AOJu0YyWmFsrIJ7WbmaE/mg36gItGegf4GdsRF2Oqi9Dj0eXTiNPC17n UXWELwaZ24NBEwMwQ63gq7GFILbtIU3R73ElBvWtSR7vNmDiDEW34TisFNn0ga8= X-Google-Smtp-Source: AGHT+IEQ1rPmHgVvPqv4PCBTSK2SfyMqT+FfUhdKd/smKtgh4YK4FnIApl1IUB5NrJX6RaDjrxK0Yw== X-Received: by 2002:a05:651c:1a29:b0:2d4:61b6:7a2a with SMTP id by41-20020a05651c1a2900b002d461b67a2amr3148818ljb.1.1710340830624; Wed, 13 Mar 2024 07:40:30 -0700 (PDT) Received: from localhost.localdomain (95-24-11-149.broadband.corbina.ru. [95.24.11.149]) by smtp.gmail.com with ESMTPSA id a14-20020a2e88ce000000b002d4692a51c8sm505450ljk.99.2024.03.13.07.40.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 07:40:30 -0700 (PDT) X-Google-Original-From: Maxim Kokryashkin To: tarantool-patches@dev.tarantool.org, skaplun@tarantool.org, sergeyb@tarantool.org Date: Wed, 13 Mar 2024 17:40:18 +0300 Message-ID: <0203bed32763ed20c596326d5ca9670491269c67.1710340671.git.m.kokryashkin@tarantool.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit v3 6/6] profilers: introduce event reader module 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" There is no error-checking in profilers which results in raw Lua errors being reported in cases of non-existing paths or corrupt file structures. This patch adds a profiler-agnostic module for event parsing, which is going to be used to introduce user-friendly errors. It is impossible to enable it right now because it should be included in Tarantool's build procedure first. Part of tarantool/tarantool#9217 Part of tarantool/tarantool#5994 --- Makefile.original | 2 +- tools/CMakeLists.txt | 4 ++++ tools/utils/evread.lua | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 tools/utils/evread.lua diff --git a/Makefile.original b/Makefile.original index d0834fe6..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 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/tools/CMakeLists.txt b/tools/CMakeLists.txt index a4adc15b..695c079a 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -18,6 +18,7 @@ else() memprof.lua utils/avl.lua utils/bufread.lua + utils/evread.lua utils/symtab.lua ) list(APPEND LUAJIT_TOOLS_DEPS tools-parse-memprof) @@ -36,6 +37,7 @@ else() install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/utils/avl.lua ${CMAKE_CURRENT_SOURCE_DIR}/utils/bufread.lua + ${CMAKE_CURRENT_SOURCE_DIR}/utils/evread.lua ${CMAKE_CURRENT_SOURCE_DIR}/utils/symtab.lua DESTINATION ${LUAJIT_DATAROOTDIR}/utils PERMISSIONS @@ -65,6 +67,7 @@ else() sysprof.lua utils/avl.lua utils/bufread.lua + utils/evread.lua utils/symtab.lua ) list(APPEND LUAJIT_TOOLS_DEPS tools-parse-sysprof) @@ -81,6 +84,7 @@ else() install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/utils/avl.lua ${CMAKE_CURRENT_SOURCE_DIR}/utils/bufread.lua + ${CMAKE_CURRENT_SOURCE_DIR}/utils/evread.lua ${CMAKE_CURRENT_SOURCE_DIR}/utils/symtab.lua DESTINATION ${LUAJIT_DATAROOTDIR}/utils PERMISSIONS diff --git a/tools/utils/evread.lua b/tools/utils/evread.lua new file mode 100644 index 00000000..394a4a03 --- /dev/null +++ b/tools/utils/evread.lua @@ -0,0 +1,32 @@ +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('\n\t%s\n', err)) + os.exit(1, true) + end +end + +return function(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 -- 2.44.0