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 0B1D56FC87; Wed, 29 Sep 2021 23:09:03 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0B1D56FC87 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1632946143; bh=sTXgP2v2/mW5kiTw6ErPZ95jDiYDfRLVXac4ZrIToqE=; 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=oPwcB0SnUvczdh25KJbr7pvNAxdX5W6V7lBw4ytWq+QTCEp4fBf80ZT2gREogLKom oVc+0yGQ3SpFoyKKMSz8xYxHu6/0qRADkAq7UKTUAT8rfVbH+QThtKwRYNLWO99Pxw nK4uFK4m0SQ7F/YBUu/tN2zjxl5rcb4Qa8Eri/m0= Received: from smtp59.i.mail.ru (smtp59.i.mail.ru [217.69.128.39]) (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 7335A6DB05 for ; Wed, 29 Sep 2021 23:08:04 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7335A6DB05 Received: by smtp59.i.mail.ru with esmtpa (envelope-from ) id 1mVfs3-0000Jo-Gh; Wed, 29 Sep 2021 23:08:03 +0300 To: tarantool-patches@dev.tarantool.org, imun@tarantool.org, skaplun@tarantool.org Date: Wed, 29 Sep 2021 23:07:56 +0300 Message-Id: <20210929200758.149446-3-m.shishatskiy@tarantool.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210929200758.149446-1-m.shishatskiy@tarantool.org> References: <20210929200758.149446-1-m.shishatskiy@tarantool.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD96A58C36AA2E99649BF631F26B0465AFD66E223DEB3A228DC182A05F5380850409989C7EA7F865C43B2FC0765BFDE8C682229EC98D7F65402481D5B74BBEA6065 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE70D278D70F8433719EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006370BEBC60587DC626C8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8A7D7666BECC08586053A2005397E5444117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC974A882099E279BDA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18C26CFBAC0749D213D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EEB28585415E75ADA92AE38A8E97BAFFB1D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE35FF72824B19451C6302FCEF25BFAB345C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F79006373BC478629CBEC79DEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458F0AFF96BAACF4158235E5A14AD4A4A4625E192CAD1D9E79DB194B0D77246B867F28E482518298EFC X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C5D501480F54144102440178C292B5745E021E766A4F44E049C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF9EAAB76869E07C3E699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34EB7BD66E9101C100A29E979BBA4F1BD040F3A435BC0938A10B37C6328EF61494E741396F56A004A01D7E09C32AA3244C80457F4676B10A9F3BBE65A5F25C0F20C86C126E7119A0FE927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojsAIehEB+JdkXlogozHqCTg== X-Mailru-Sender: EFA0F3A8419EF21635BFE795C6CB22C93AAF7B0F420A8617B2FC0765BFDE8C6814D23FB96A9F340B2376072A51849BFFE66B5C1DBFD5D09D5E022D45988A037B448E0EA96F20AB367402F9BA4338D657ED14614B50AE0675 X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit v4 2/4] memprof: refactor location parsing 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: Mikhail Shishatskiy via Tarantool-patches Reply-To: Mikhail Shishatskiy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" As it is hard to keep function `id_location` easily usable in the function `parse_location` with a growing number of fields in the table, the code is refactored to make it more understandable. The API of module changed with adding a function `id(loc)` returning the same id-string, as `id_location` did. This function is useful to "stringify" the location and use it as a key in the key/value storage. Part of tarantool/tarantool#5814 --- Issue: https://github.com/tarantool/tarantool/issues/5814 Branch: https://github.com/tarantool/luajit/tree/shishqa/gh-5814-group-allocations-on-trace-by-trace-number CI: https://github.com/tarantool/tarantool/tree/shishqa/gh-5814-group-allocations-on-trace-by-trace-number tools/memprof/parse.lua | 26 +++++++++++++------------- tools/utils/symtab.lua | 4 ++++ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/tools/memprof/parse.lua b/tools/memprof/parse.lua index 12e2758f..34ff8aef 100644 --- a/tools/memprof/parse.lua +++ b/tools/memprof/parse.lua @@ -8,6 +8,8 @@ local bit = require "bit" local band = bit.band local lshift = bit.lshift +local symtab = require "utils.symtab" + local string_format = string.format local LJM_MAGIC = "ljm" @@ -59,22 +61,20 @@ local function link_to_previous(heap_chunk, e, nsize) end end -local function id_location(addr, line) - return string_format("f%#xl%d", addr, line), { - addr = addr, - line = line, - } -end - local function parse_location(reader, asource) - if asource == ASOURCE_INT then - return id_location(0, 0) - elseif asource == ASOURCE_CFUNC then - return id_location(reader:read_uleb128(), 0) + local loc = { + addr = 0, + line = 0, + } + if asource == ASOURCE_CFUNC then + loc.addr = reader:read_uleb128() elseif asource == ASOURCE_LFUNC then - return id_location(reader:read_uleb128(), reader:read_uleb128()) + loc.addr = reader:read_uleb128() + loc.line = reader:read_uleb128() + elseif asource ~= ASOURCE_INT then + error("Unknown asource "..asource) end - error("Unknown asource "..asource) + return symtab.id(loc), loc end local function parse_alloc(reader, asource, events, heap) diff --git a/tools/utils/symtab.lua b/tools/utils/symtab.lua index 3ed1dd13..e01daa62 100644 --- a/tools/utils/symtab.lua +++ b/tools/utils/symtab.lua @@ -73,6 +73,10 @@ function M.parse(reader) return symtab end +function M.id(loc) + return string_format("f%#xl%d", loc.addr, loc.line) +end + function M.demangle(symtab, loc) local addr = loc.addr -- 2.33.0