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 5B0F96EC40; Fri, 16 Oct 2026 01:53:30 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5B0F96EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1792104810; bh=gAb21L/fpVNJinoqmo9ZRv2WzRCXelD07LW9l9Rfn14=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=aiDUOmJXNpHbkxWKiQZ4sU/IVKTzAbKJj2p2b8tHWrrkh3BTljOKL58PFu31KcgJC SuEmPREYfjvW7ZVm3r2iZWqP6/13Wxg5j92K1k2QLCpcePQ6F+s772Vdf3rETgkgL5 IkBQyCYovWHDzWIRXxgURZLHdYKe+bXMRFYMAgg0= Received: from send59.i.mail.ru (send59.i.mail.ru [89.221.237.154]) (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 0D7E76EC40 for ; Fri, 16 Oct 2026 01:53:29 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0D7E76EC40 Received: by exim-smtp-canary-30-cb6b8b7df-q4fcw with esmtpa (envelope-from ) id 1xHUKF-00000000KFb-3NdX; Fri, 16 Oct 2026 01:53:28 +0300 Message-ID: <94f5ce6c-a379-4505-b968-3fa75e67a3c2@vk.team> Date: Fri, 16 Oct 2026 01:53:25 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Sergey Kaplun , Sergey Bronnikov , Evgeniy Temirgaleev Cc: tarantool-patches@dev.tarantool.org References: <20261014150248.296106-1-m.elhimov@vk.team> Content-Language: en-US In-Reply-To: <20261014150248.296106-1-m.elhimov@vk.team> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Mailru-Src: smtp X-618D5548: A632CDF4580D8DA015C513EAE8123D4D95EB458D620770EAD144E75BF44E3633FED361105D3F6232 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9D5ABD805758C3F0B6A7048CC65C8CB6A9213BBDA6D6CB42F182A05F538085040F9C2524C12A959C23DE06ABAFEAF67056CC17FA3C6CD6A3C606E32B7470A7E8E74892205136C5E50 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE75AD53DF1D86BACA3EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB553375667E1D4B08D42AEC87478D8CAA93C9A172C536C627B307875E1B8E71D8F89F701B8EEF46B7454FC60B9742502CCDD46D0D6089696B24BB1D19BA3038C0950A5D36D5E8D9A59859A8B62505A774C657DC2776E601842F6C81A1F004C906525384303E02D724532EE2C3F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7C561E97631CE4783743847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A50A6FF065F198E7945002B1117B3ED69650ABF2E76363B099886DC9BC01168B20823CB91A9FED034534781492E4B8EEADA91A6E18C88C5E2F X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE1918E10F71CB4DF9F9677DD89D51EBB774225B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D65909B8B3E93B1FA5A4B3DBF3B7FA4ADA491DE7CE6BE3C533354ED1530EEB9E55E11B6BC4F5F4560A24B8341EE9D5BE9A0A2B294A04DE0B4D5CE3FBF4E6F11B30008BC46D52C2FE7625C7CEAA0681F5848F4C41F94D744909CE9D6718F459EE2962AE54DA86D399E591103B389C0A9E82E8 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXOcIETfglQORZ0zpDET4Zrk3igikrdHlWKqr4setyrOiAP+qXqN/L60= X-Mailru-Sender: 49D287FBCBBF3A5C92A60AAC437E3E175857679D4BB3A48D3DE06ABAFEAF67056CC17FA3C6CD6A3CA165F1893FAC5C751036CFC832F975CE5A92E71CC7C3152D493CB54E9A9D11381B6B970E2AF9E88A510CA7867B031959FEAC74B6516BD3BDB4A721A3011E896F X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] dbg: avoid hardcoded vmstate 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 Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This patch is closed (it has been integrated into https://lists.tarantool.org/pipermail/tarantool-patches/2026-October/030858.html) On 14.10.2026 18:02, Mikhail Elhimov wrote: > Follows-up f0897ba86494b250512be18e25bafccffadb27b1 ("dbg: avoid > hardcoded enums (get them from target)"). > > Also tests were adjusted to use stricter regex for vm state. > --- > Branch: https://github.com/tarantool/luajit/tree/elhimov/gh-13094-dbg-avoid-hardcoded-vmstate > Related issues: https://github.com/tarantool/tarantool/issues/13094 > > src/luajit_dbg.py | 88 +++++++++---------- > .../debug-extension-tests.py | 16 +++- > 2 files changed, 58 insertions(+), 46 deletions(-) > > diff --git a/src/luajit_dbg.py b/src/luajit_dbg.py > index 7c2d085f..e0b8f958 100644 > --- a/src/luajit_dbg.py > +++ b/src/luajit_dbg.py > @@ -198,7 +198,7 @@ class Debugger(object): > # different in GDB and LLDB, so this method is needed to hide > # the implementation details. > @abc.abstractmethod > - def create_enum_value(self, enum_name, enum_member_name): > + def create_enum_value(self, enum_member_name, enum_name=None): > '''Return debugger-specific value object that represents > the given enum member. > ''' > @@ -357,7 +357,7 @@ class _GDBDebugger(Debugger): > def register_command(self, command, name): > command(name) > > - def create_enum_value(self, enum_name, enum_member_name): > + def create_enum_value(self, enum_member_name, enum_name): > val = self.eval(enum_member_name) > assert val.type.code == gdb.TYPE_CODE_ENUM > return val > @@ -752,27 +752,31 @@ class _LLDBDebugger(Debugger): > ) > ) > > - def create_enum_value(self, enum_name, enum_member_name): > - # In LLDB an enum member has to be specified in the form: > - # :: > - val = self.eval(enum_name + "::" + enum_member_name) > - # Be aware that SBValue.IsValid() is necessary, but not > - # sufficient as it only indicates that the object does > - # contain the relevant data (including potential error), > - # so it is necessary to check additionally that no error > - # has occurred while evaluating the expression. > - if val.sbvalue.IsValid() and val.sbvalue.error.Success(): > - assert self._lldb_tp_isenum(val.sbvalue.GetType()) > - return val > - > - # LLDB uses the enum name in the expression above but > - # debugging information about the enum name might be > - # optimized out if no variable of the given enum type is > - # declared and its members are only used as the predefined > - # constants (like in case of the enum IRFieldID). > - > - # In this case the above method doesn't work so trying to > - # discover the enum type by the given enum member. > + def create_enum_value(self, enum_member_name, enum_name): > + if enum_name is not None: > + # In LLDB an enum member has to be specified in the > + # form: :: > + val = self.eval(enum_name + "::" + enum_member_name) > + # Be aware that SBValue.IsValid() is necessary, but > + # not sufficient as it only indicates that the object > + # does contain the relevant data (including potential > + # error), so it is necessary to check additionally > + # that no error has occurred while evaluating the > + # expression. > + if val.sbvalue.IsValid() and val.sbvalue.error.Success(): > + assert self._lldb_tp_isenum(val.sbvalue.GetType()) > + return val > + > + # LLDB needs the enum name in the expression above but > + # 1. Enum might be anonymous (like LJ_VMST__MAX) > + # 2. Debugging information about the enum name might be > + # optimized out if no variable of the given enum type > + # is declared and its members are only used as the > + # predefined constants (like in case of the enum > + # IRFieldID) > + > + # In these cases the above method doesn't work so trying > + # to discover the enum type by the given enum member. > > def find_enum_type_member(enum_type, enum_member_name): > # SBTypeEnumMemberList supports members iteration and > @@ -870,10 +874,10 @@ def strx64(val): > > > class EnumBasedList(object): > - def __init__(self, enum_name, max_enum_member, map_func=None, > + def __init__(self, max_enum_member, enum_name, map_func=None, > *map_func_extra_args): > - self.__enum_name = enum_name > self.__max_enum_member = max_enum_member > + self.__enum_name = enum_name > self.__map_func = map_func > self.__map_func_extra_args = map_func_extra_args > # Lazy initialization (see __get_items) as the required > @@ -892,7 +896,7 @@ class EnumBasedList(object): > def __get_items(self): > if self.__items is None: > max_enum_value = dbg.create_enum_value( > - self.__enum_name, self.__max_enum_member > + self.__max_enum_member, self.__enum_name > ) > items = [] > for i in range(max_enum_value): > @@ -985,7 +989,7 @@ def bc_d(ins): > return int(ins) >> 16 > > > -BCMODE = EnumBasedList('BCMode', 'BCM_max', cut_prefix, 'BCM') > +BCMODE = EnumBasedList('BCM_max', 'BCMode', cut_prefix, 'BCM') > > > lj_bc_mode_ = None > @@ -1011,7 +1015,7 @@ def bcmode_cd(op): > return int((lj_bc_mode()[op] >> 7) & 15) > > > -BYTECODES = EnumBasedList('BCOp', 'BC__MAX', cut_prefix, 'BC_') > +BYTECODES = EnumBasedList('BC__MAX', 'BCOp', cut_prefix, 'BC_') > > > def proto_bc(proto): > @@ -1166,7 +1170,7 @@ def J(g): > > > # Matched `MMDEF(_)`. > -MM_NAMES = EnumBasedList('MMS', 'MM__MAX', cut_prefix, 'MM_') > +MM_NAMES = EnumBasedList('MM__MAX', 'MMS', cut_prefix, 'MM_') > > > # Get the name of the index in the predefined arrays. > @@ -1219,18 +1223,12 @@ def ggfname_by_offset(offset): > return ggfname > > > +VM_STATES = EnumBasedList('LJ_VMST__MAX', None, cut_prefix, 'LJ_VMST_') > + > + > def vm_state(g): > - return { > - i2notu32(0): 'INTERP', > - i2notu32(1): 'LFUNC', > - i2notu32(2): 'FFUNC', > - i2notu32(3): 'CFUNC', > - i2notu32(4): 'GC', > - i2notu32(5): 'EXIT', > - i2notu32(6): 'RECORD', > - i2notu32(7): 'OPT', > - i2notu32(8): 'ASM', > - }.get(int(tou32(g['vmstate'])), 'TRACE') > + index = i2notu32(g['vmstate']) > + return VM_STATES[index] if index < len(VM_STATES) else 'TRACE' > > > def gc_state(g): > @@ -1427,7 +1425,7 @@ def cdataptr(cd): > # JIT engine. > > > -IRS = EnumBasedList('IROp', 'IR__MAX', cut_prefix, 'IR_') > +IRS = EnumBasedList('IR__MAX', 'IROp', cut_prefix, 'IR_') > > > # Mode bits: Commutative, {Normal/Ref, Alloc, Load, Store}, > @@ -1479,7 +1477,7 @@ def ir_mode(op): > return mode > > > -IRTYPES = EnumBasedList('IRType', 'IRT__MAX', lambda x: { > +IRTYPES = EnumBasedList('IRT__MAX', 'IRType', lambda x: { > 'IRT_CDATA': 'cdt', > 'IRT_FLOAT': 'flt', > 'IRT_LIGHTUD': 'lud', > @@ -1488,11 +1486,11 @@ IRTYPES = EnumBasedList('IRType', 'IRT__MAX', lambda x: { > }.get(x, cut_prefix(x, 'IRT_')[:3].ljust(3).lower())) > > > -IRFIELDS = EnumBasedList('IRFieldID', 'IRFL__MAX', lambda x: > +IRFIELDS = EnumBasedList('IRFL__MAX', 'IRFieldID', lambda x: > cut_prefix(x, 'IRFL_').lower().replace('_', '.', 1)) > > > -IRFPMS = EnumBasedList('IRFPMathOp', 'IRFPM__MAX', > +IRFPMS = EnumBasedList('IRFPM__MAX', 'IRFPMathOp', > lambda x: cut_prefix(x, 'IRFPM_').lower()) > > > @@ -1522,7 +1520,7 @@ REGISTERS = { > } > > > -IR_CALLS = EnumBasedList('IRCallID', 'IRCALL__MAX', cut_prefix, 'IRCALL_') > +IR_CALLS = EnumBasedList('IRCALL__MAX', 'IRCallID', cut_prefix, 'IRCALL_') > > > def regname(reg_number): > diff --git a/test/tarantool-debugger-tests/debug-extension-tests.py b/test/tarantool-debugger-tests/debug-extension-tests.py > index 5e369f00..359163e9 100644 > --- a/test/tarantool-debugger-tests/debug-extension-tests.py > +++ b/test/tarantool-debugger-tests/debug-extension-tests.py > @@ -262,12 +262,26 @@ class TestLJArch(TestCaseBase): > ) > > > +RX_VM_STATE = '({})'.format('|'.join([ > + 'INTERP', > + 'LFUNC', > + 'FFUNC', > + 'CFUNC', > + 'GC', > + 'EXIT', > + 'RECORD', > + 'OPT', > + 'ASM', > + 'TRACE', > +])) > + > + > class TestLJState(TestCaseBase): > extension_cmds = 'lj-state' > location = 'lj_cf_print' > lua_script = 'print(1)' > pattern = ( > - r'VM state: [A-Z]+\n' > + r'VM state: ' + RX_VM_STATE + '\n' > r'GC state: [A-Z]+\n' > r'JIT state: [A-Z]+\n' > ) -- Best regards, Mikhail Elhimov