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 264E0C51BD1; Wed, 7 Aug 2024 14:31:35 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 264E0C51BD1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1723030295; bh=a8InF6hpc9vBM40JSEaIeho28887AOVW/zZ8/DRgHKs=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=uMpUoIdT1EAFoJgPqesiFOwpLFEWl6ZlzIFCKj/SUjbx7Acv07fhrkkDWIKZSr2Ci KfiX0D1bjJmUXASPAWJ70W7UQb4tCPYjA3znlg5e6nwV/kzTfVXrmpD0jVRPtP+K2L eijrHFqN5hwwM/7eKD61SaCydPse9Dyi5szf9BrY= Received: from smtp49.i.mail.ru (smtp49.i.mail.ru [95.163.41.91]) (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 AF351516A47 for ; Wed, 7 Aug 2024 14:31:33 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org AF351516A47 Received: by exim-smtp-548c4c4b6c-p9hbd with esmtpa (envelope-from ) id 1sbetA-000000009cG-2EWN; Wed, 07 Aug 2024 14:31:33 +0300 To: skaplun@tarantool.org, m.kokryashkin@tarantool.org Date: Wed, 7 Aug 2024 14:31:28 +0300 Message-ID: <20240807113128.3094487-1-m.elhimov@vk.team> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9972A9DADB51A1AA1D5DF8E98E2688B30354311490C3F1DB0CD62213F67905E7A61C1FD2101B168246F7D2A135779D5C6DD1031F012FCFD7CA26F9A9D2AFA0A0D08D917D6130B1AFB X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE70312E9A300D47E3BEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637A0569EA9A35E44F48638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D89E0646602688D3D8E40DDB39DACB059530F23489DC6E0CEB20879F7C8C5043D14489FFFB0AA5F4BF176DF2183F8FC7C0A68A47777D5C6D9CD8FC6C240DEA76428AA50765F7900637DB774727DDCF9ACCD81D268191BDAD3DBD4B6F7A4D31EC0BE2F48590F00D11D6D81D268191BDAD3D78DA827A17800CE73B915859EE5BCF98EC76A7562686271ED91E3A1F190DE8FD2E808ACE2090B5E14AD6D5ED66289B5259CC434672EE63711DD303D21008E298D5E8D9A59859A8B6B372FE9A2E580EFC725E5C173C3A84C356BFB3752F709D0935872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-C1DE0DAB: 0D63561A33F958A55F37CC5A90398AE05002B1117B3ED6962D0521EA540832B169995D676B7B4CBE823CB91A9FED034534781492E4B8EEADF4F3DF47829F65C7C79554A2A72441328621D336A7BC284946AD531847A6065A535571D14F44ED41 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF77DD89D51EBB7742D3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF4C4E133E6337B3137D565905268C9B36F068522A8F8954B0A57658A11F7CF97E85EFCC6ECD4542027E625F09773DF59AEAE7BA5138572E4A7FC7EED84F3248320115769805D20228C226CC413062362A913E6812662D5F2A2759B354903CB0EB99D599D7C8FAC70FEF495F0351076533 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojbL9S8ysBdXj9f+Neof46S3FPSz/DnwXr X-Mailru-Sender: 0A26D9779F8DDEABC01EB084392F96C8217039042345B6EC72C88FB39F7EDAED3391701616A311A5166AFCB76AC79D914CA08BFBBB45AAA72C22B24405C8F0CCB7331131FBF1F034D3A388E327D6469BB4C443D66B1C03FA314DF935DB795A1AEAB4BC95F72C04283CDA0F3B3F5B9367 X-Mras: Ok Subject: [Tarantool-patches] [PATCH] gdb: display fast function name along with ffid 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 Elhimov via Tarantool-patches Reply-To: Mikhail Elhimov Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Part of tarantool/tarantool#4808 --- Branch: https://github.com/tarantool/luajit/tree/elhimov/gh-4808-display-fast-function-name Issue: https://github.com/tarantool/tarantool/issues/4808 src/luajit-gdb.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/luajit-gdb.py b/src/luajit-gdb.py index d2070e9b..967124a8 100644 --- a/src/luajit-gdb.py +++ b/src/luajit-gdb.py @@ -4,6 +4,7 @@ import re import gdb import sys +import itertools # make script compatible with the ancient Python {{{ @@ -14,6 +15,7 @@ if LEGACY: CONNECTED = False int = long range = xrange + filter = itertools.ifilter # }}} @@ -74,6 +76,14 @@ def strx64(val): hex(int(cast('uint64_t', val) & 0xFFFFFFFFFFFFFFFF))) +def enumval_name(type, val, default): + assert type.code == gdb.TYPE_CODE_ENUM, \ + "enumval_name expects enum type but type of code {} was given".format(type.code) + enumval_attr = 'enumval' if hasattr(type.fields()[0], 'enumval') else 'bitpos' + field = next(filter(lambda x: getattr(x, enumval_attr) == val, type.fields()), None) + return field.name if field is not None else default + + # Types {{{ @@ -426,7 +436,7 @@ def dump_lj_tproto(tv): def dump_lj_tfunc(tv): func = cast('struct GCfuncC *', gcval(tv['gcr'])) - ffid = func['ffid'] + ffid = int(func['ffid']) if ffid == 0: pt = funcproto(func) @@ -439,7 +449,9 @@ def dump_lj_tfunc(tv): elif ffid == 1: return 'C function @ {}'.format(strx64(func['f'])) else: - return 'fast function #{}'.format(int(ffid)) + ffid_enum = gdb.parse_and_eval('FF__MAX').type + ffid_name = enumval_name(ffid_enum, ffid, 'UNKNOWN') + return 'fast function #{}({})'.format(ffid, ffid_name) def dump_lj_ttrace(tv): -- 2.43.0