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 6A9E26ECD0; Tue, 30 Jun 2026 19:02:32 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6A9E26ECD0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1782835352; bh=wh9LeEZLX64w4ANuZsUgMs7O+kV7Mqinknbb+EZUwII=; 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=S2vwqYE0FEs7/tmZ99Q00qt7UMn4JHAoPuGcYco3epGMOlDHhrLkS47T0A/gjlh1r ig2KM81QuKACOl2TVHt1g1KSD4vSiEBwGUEj6h8zh7z359Fd0MvAFvlRO1w5OwxJvQ M6gMW8ZktMyP5aFNOJab03a3oFUrMAPvfuhEjPxA= Received: from send83.i.mail.ru (send83.i.mail.ru [89.221.237.178]) (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 910986ECD0 for ; Tue, 30 Jun 2026 19:02:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 910986ECD0 Received: by exim-smtp-78b8b8c574-6hg4j with esmtpa (envelope-from ) id 1weaus-00000000N3T-1rzC; Tue, 30 Jun 2026 19:02:31 +0300 Date: Tue, 30 Jun 2026 19:01:51 +0300 To: Sergey Bronnikov Message-ID: References: <20260625202903.3157425-1-skaplun@tarantool.org> <20260625202903.3157425-2-skaplun@tarantool.org> <74882449-a4cc-4602-a8b3-75bd5e9724eb@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <74882449-a4cc-4602-a8b3-75bd5e9724eb@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9C332F781D648AA6A4F29E395B7A4CA33AC9D70133690E203182A05F53808504017FD31D9E4E43DD43DE06ABAFEAF6705C1C3A43DEA876970A1957ADDA95B5BD487CACECC26227EC5 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE75263010198C72082EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB553375667C07923B88CEC0ED84373CCBFB39E46B7C163A70C69F87FDBD89B2F37045C204389733CBF5DBD5E913377AFFFEAFD269A417C69337E82CC2CC7F00164DA146DAFE8445B8C89999729449624AB7ADAF37F6B57BC7E64490611E7FA7ABCAF51C92176DF2183F8FC7C0A3E989B1926288338941B15DA834481F9449624AB7ADAF372E808ACE2090B5E14AD6D5ED66289B5278DA827A17800CE76631511D42670FFE2EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE74ABCC139FF3F849B731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A56E41D355255058C35002B1117B3ED696005D81A70B2F01F830C8F815570A3530823CB91A9FED034534781492E4B8EEADEEA082C9A12FE455BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D6595CA2B42642ABB02D40955E19C3B51B754BB21CF883E650A702AF15F695D1ABCE78460424221B1BDAB8341EE9D5BE9A0AAE04CCDB255205177497E6BF069D97FCCA8E0803C08BAC336536EB022892E5344C41F94D744909CECFA6C6B0C050A61A8CAF69B82BA93681CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVRSZSJkMhZtMCZQI8D/39Rk= X-DA7885C5: E5ECC0E7F2380843F255D290C0D534F985C5B34B5461EFDAB4B650D204A256F8DF10FB5F2B3F018C5B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393520AF17B8A65FDE235432D06A5DF40269D57C121B9B9AA89674440802E6AAF2FE49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 1/3] dbg: introduce lj-ir, lj-jslots, lj-trace dumpers 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: Sergey Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Sergey! Thanks for the review! Fixed your comments and force-pushed the branch. On 30.06.26, Sergey Bronnikov wrote: > Hi, Sergey, > > thanks for the patch! LGTM with minor comments. > > Sergey > > On 6/25/26 23:29, Sergey Kaplun wrote: > > This patch adds dumpers for a single IR instruction (`lj-ir`), as well > > as for all bytecodes inside one trace (`lj-trace`). Its dump is quite > > similar to the -jdump flag but also reports types of register operands > > (`ref`, `lit`, `cst`) and operation mode (`N`, `A`, `W`, etc.). > > The `lj-trace` command accepts optional /rs flags to dump registers > > associated with IR and snapshots for the trace correspondingly. > > The `lj-ir` command can be used for dumping IR constants as well. > > The `lj-jslots` command dumps the content of `J->slot`. It is useful to > > simplify debugging of `rec_check_slots()` assertion failures. > > > > For LLDB value, the `__getitem__` metamethod now accepts bool keys. > > Also, `__index__` is set to allow lldb.value to be used as an index > > without explicit conversion to int. Old GDB versions (below 7.12) are > > not supported because of the gdb.Value lacks the `__index__` metamethod > > and can't be monkey-patched. The support for these versions may be added > > by demand. > > > > Part of tarantool/tarantool#4808 > > --- > > src/luajit_dbg.py | 1216 ++++++++++++++++- > > .../debug-extension-tests.py | 365 +++++ > > 2 files changed, 1570 insertions(+), 11 deletions(-) > > > > diff --git a/src/luajit_dbg.py b/src/luajit_dbg.py > > index 2edb199a..fd6ca8a5 100644 > > --- a/src/luajit_dbg.py > > +++ b/src/luajit_dbg.py > > @@ -58,6 +58,26 @@ class Debugger(object): > > self.LLDB = True > > return super(Debugger, self).__new__(_LLDBDebugger) > > > > + def parse_flags(self, raw_flags, permitted_flags): > > + flags = {} > > + for flag in raw_flags: > > + if flag not in permitted_flags: > > + raise self.error('Unrecongnized option: "{}"'.format(flag)) > typo: s/Unrecongnized/Unrecognized/ Fixed, thanks! =================================================================== diff --git a/src/luajit_dbg.py b/src/luajit_dbg.py index 19cefaed..6412575c 100644 --- a/src/luajit_dbg.py +++ b/src/luajit_dbg.py @@ -62,7 +62,7 @@ class Debugger(object): flags = {} for flag in raw_flags: if flag not in permitted_flags: - raise self.error('Unrecongnized option: "{}"'.format(flag)) + raise self.error('Unrecognized option: "{}"'.format(flag)) flags[flag] = True return flags =================================================================== > > + flags[flag] = True > > + return flags > > + > > + def member_by_offset(self, tp, offset, prev_name=None): > > + if isinstance(tp, str): > > + tp = self._dbgtype(tp) > > + assert offset < tp.sizeof, 'offset is bigger than object size' > > + if tp.code == gdb.TYPE_CODE_TYPEDEF: > > + tp = tp.strip_typedefs() > > + if tp.code == gdb.TYPE_CODE_STRUCT: > > + fields = tp.fields() > > + for n_field in range(len(fields)): > > + islast = n_field == (len(fields) - 1) > > + field = fields[n_field] > > + start_field = field.bitpos / 8 > may be //? I'm not sure that this is crucial. In case when the bitpos isn't a multiple of 8 we will get an error, so we may find the bug earlier instead of an incorrect result. I'd prefer to ignore it if you don't insist. > > + end_field = fields[n_field + 1].bitpos / 8 if not islast \ > > + else tp.sizeof > > + if start_field <= offset and offset < end_field: > > + next_name = self.member_by_offset( > > + field.type, > > + offset - start_field, > > + prev_name=field.name > > + ) > > + return '.{field}{suffix}'.format( > > + field=field.name, > > + suffix=next_name if next_name else '' > > + ) > > @@ -322,8 +428,26 @@ class _LLDBDebugger(Debugger): > > def lldb__getitem__(lldbval, key): > > if type(key) is lldb.value: > > key = int(key) > > + if type(key) is bool: > > + key = int(key) > > if type(key) is int: > > # Allow array access. > > + ltp = lldbval.sbvalue.GetType() > > + # XXX: LLDB in versions 17 - 19 can't use an array > > + # object as the initializer for `lldb.value` since > > + # `GetValue()` for it returns `None` leading to > > + # the invalid result. See > > + #https://github.com/llvm/llvm-project/pull/90144. > > + if (self.version < 17 or self.version > 19) or \ > > + ltp.GetTypeClass() != lldb.eTypeClassArray: > > + pass > probably it is better to invert condition and remove section with "pass" The same condition is used for loading the global symbol, so it is more bulletproof, I suppose. Also, this attracts an attention about the mentioned issue. I'd prefer to leave it as is if you don't insist. > > + > > + > > +def ir_kptr(ir): > > + irname = IRS[ir['o']] > > + assert irname == 'KPTR' or irname == 'KKPTR', 'wrong IR for ir_iptr()' > typo: s/ir_iptr()/ir_kptr() or ir_kkptr()/ Fixed, thanks: =================================================================== diff --git a/src/luajit_dbg.py b/src/luajit_dbg.py index 6412575c..d5967716 100644 --- a/src/luajit_dbg.py +++ b/src/luajit_dbg.py @@ -2001,7 +2001,7 @@ def irt_toitype(irt): def ir_kptr(ir): irname = IRS[ir['o']] - assert irname == 'KPTR' or irname == 'KKPTR', 'wrong IR for ir_iptr()' + assert irname == 'KPTR' or irname == 'KKPTR', 'wrong IR for ir_kptr()' return mref('void *', dbg.cast('IRIns *', dbg.address(ir))[LJ_GC64]['ptr']) =================================================================== > > + return mref('void *', dbg.cast('IRIns *', dbg.address(ir))[LJ_GC64]['ptr']) > > +def ir_kint64(ir): > > + irname = IRS[ir['o']] > > + assert irname == 'KINT64', 'wrong IR for ir_knum()' > typo: s/ir_knum/ir_kint64/ Fixed, thanks: =================================================================== diff --git a/src/luajit_dbg.py b/src/luajit_dbg.py index d5967716..68f7970b 100644 --- a/src/luajit_dbg.py +++ b/src/luajit_dbg.py @@ -2019,7 +2019,7 @@ def ir_knum(ir): def ir_kint64(ir): irname = IRS[ir['o']] - assert irname == 'KINT64', 'wrong IR for ir_knum()' + assert irname == 'KINT64', 'wrong IR for ir_kint64()' return dbg.address(dbg.cast('IRIns *', dbg.address(ir))[1]['tv']) =================================================================== > > + for slot in range(0, snap['nslots']): > > + dump += ' ' > > + snap_entry = int(snap_map[snap_entry_num]) > > + if snap_entry_num < snap['nent'] and snap_entry >> TREF_SHIFT == slot: > > + snap_entry_num += 1 > > + ref = int((snap_entry & TREF_REFMASK) - REF_BIAS) > > + if ref < 0: > > + if int(snap_entry) == 0x1057fff: > magic number Indeed, fixed: =================================================================== diff --git a/src/luajit_dbg.py b/src/luajit_dbg.py index 68f7970b..9534dfad 100644 --- a/src/luajit_dbg.py +++ b/src/luajit_dbg.py @@ -1956,6 +1956,7 @@ RID_SUNK = (RID_INIT - 2) SPS_NONE = 0 REF_BIAS = 0x8000 +REF_NIL = REF_BIAS - 1 TREF_SHIFT = 24 @@ -1964,8 +1965,11 @@ TREF_FRAME = 0x00010000 TREF_CONT = 0x00020000 # Snapshot flags and masks. SNAP_FRAME = 0x010000 +SNAP_NORESTORE = 0x040000 SNAP_SOFTFPNUM = 0x080000 +SNAP_FR2_SLOT = (1 << TREF_SHIFT) | SNAP_FRAME | SNAP_NORESTORE + REF_NIL + def irt_type(t): return dbg.cast('IRType', t['irt'] & IRT_TYPE) @@ -2810,7 +2813,7 @@ def dump_snap(trace, snapno, snap): snap_entry_num += 1 ref = int((snap_entry & TREF_REFMASK) - REF_BIAS) if ref < 0: - if int(snap_entry) == 0x1057fff: + if int(snap_entry) == SNAP_FR2_SLOT: dump += '----' continue elif (snap_entry & TREF_CONT): =================================================================== > > > +# Assume not cross-platform debugging. > > +machine = os.uname().machine > > +if machine == 'x86_64': > > + RX_GPR = r'r\w\w' > > + RX_FPR = r'xmm\d+' > > +elif machine == 'arm64' or machine == 'aarch64': > > + RX_GPR = r'x\d+' > > + RX_FPR = r'd\d+' > > +else: > > + raise Exception('Unknown archeticture in testing') > typo: s/archeticture/architecture/ Fixed, thanks! =================================================================== diff --git a/test/tarantool-debugger-tests/debug-extension-tests.py b/test/tarantool-debugger-tests/debug-extension-tests.py index 71b763d2..895171a4 100644 --- a/test/tarantool-debugger-tests/debug-extension-tests.py +++ b/test/tarantool-debugger-tests/debug-extension-tests.py @@ -124,7 +124,7 @@ elif machine == 'arm64' or machine == 'aarch64': RX_GPR = r'x\d+' RX_FPR = r'd\d+' else: - raise Exception('Unknown archeticture in testing') + raise Exception('Unknown architecture in testing') class TestCaseBase(unittest.TestCase): =================================================================== > > > + > > +class TestLJIRConst(TestCaseBase): > > + location = 'trace_stop' > > + > > + # No narrowing of 42. > > + if IS_DUALNUM: > > + # KNUM occupies 2 slots. > > + _knum_irnum = '6' > > + _kgc_irnum = '8' if IS_GC64 else '7' > > + _kptr_irnum = '10' if IS_GC64 else '8' > > + else: > > + # KNUM occupies 2 slots. > > + _knum_irnum = '8' > > + _kgc_irnum = '10' if IS_GC64 else '9' > > + _kptr_irnum = '12' if IS_GC64 else '10' > both branches contains the same comment, is it a typo or not? It is intentional. KNUM occupies 2 slots anyway. > > > > -- Best regards, Sergey Kaplun