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 35A876ECE2; Fri, 20 Nov 2026 16:48:06 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 35A876ECE2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1795182486; bh=G1EWduPHYLi74hPGqElmb1m4jQT3wWzbnrT9OH5HRgc=; 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=gbQdZRpI9Bop7ksWetFuDJ37LDiE9KhVmPn1vi4J11KDtX9v+l/iYgaSc5EthyD28 x+Fo562qvteYU0ejefcyYjMIqsKO28aY0YH2i/86vdosKaszvYcR/zAaZ2sbpTMyD3 QcDGCKwS+dwey2262u3axfFGrluunqAv4br5qXNE= Received: from send149.i.mail.ru (send149.i.mail.ru [89.221.237.244]) (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 8B5FC6ECE2 for ; Fri, 20 Nov 2026 16:48:04 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8B5FC6ECE2 Received: by exim-smtp-56bb8ff957-fbmhh with esmtpa (envelope-from ) id 1xUOyB-000000000ya-1Jrb; Fri, 20 Nov 2026 16:48:03 +0300 Date: Fri, 20 Nov 2026 16:50:19 +0300 To: Mikhail Elhimov Message-ID: References: <0a9a648552eb3a3bbaa9639e0d567ae008cb0e14.1794522533.git.m.elhimov@vk.team> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0a9a648552eb3a3bbaa9639e0d567ae008cb0e14.1794522533.git.m.elhimov@vk.team> X-Mailru-Src: smtp X-4EC0790: 10 X-618D5548: 905396CAB9A1148C3DE06ABAFEAF6705E3289764B2F982662F7394908224CDEAB2E63BB8312375AE X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9749DDC91F62168F92C5CC3D78C1F4129358BF2273B6E1791182A05F538085040A9CD81EB908742E43DE06ABAFEAF67054FB3546B81502987FE41681707FA065359C33E53B579784F X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7B264C8851FD8E810EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566B47933B1EBDEC5AF84C66CBA2D8BE15BDFFC0AB3657AAE8C28F67CFC1F47C514389733CBF5DBD5E9D5E8D9A59859A8B60417BEADF48D1460CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8090A508E0FED6299176DF2183F8FC7C09935A1E27F592749B3661434B16C20ACC84D3B47A649675FE827F84554CEF5019E625A9149C048EE33AC447995A7AD182BEBFE083D3B9BA73A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E7351D6A3D1828C12CDEC4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A5F1A299B0915C5A4B5002B1117B3ED69608D28F1C9577E632361FAC1196A180DE823CB91A9FED034534781492E4B8EEAD21D4E6D365FE45D1BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADB58128AB1E6D661A8E10F71CB4DF9F96AB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D65964051CF1E19EF3A961047CF352852DC30DAB061D290A23F28413FD916FB6BA5216F2098527BE4864B8341EE9D5BE9A0A3E5538B18B0E2193283CEBB3EFED155531CC906BCE051AB5C7CEAA0681F5848F4C41F94D744909CECFA6C6B0C050A61A8CAF69B82BA93681CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXOcIETfglQORZ0zpDET4Zrk3igikrdHlWPtMPRdShvpX3KofJT2Itw4= X-Mailru-Sender: 520A125C2F17F0B17094CDC02B85F11BA986CBB5842951303DE06ABAFEAF67054FB3546B81502987B7CBEF92542CD7C88B0A2698F12F5C9EC77752E0C033A69E86920BD37369036789A8C6A0E60D2BB63A5DB60FBEB33A8A0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 1/4] dbg: clean up and unification 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, Mikhail! Thanks for the update! LGTM, with minor nits below. On 13.11.26, Mikhail Elhimov wrote: > * unified `dbg.eval` approach to simplify error handling (exception in > case of any failure) > * removed trailing newline in all the dumpers to unify composing of the Typo: s/trailing newline/trailing newlines/ > complex output > * newly introduced `dbg.print` is used whenever trailing newline is > needed to make code more compact and clean > * moved handling of a missing command arg to command level (all the > dump-like functions now expect concrete value) > * unified handling of command-level error (introduced special exception > for LLDB that works similar to `gdb.GdbError`, i.e. doesn't cause > traceback to be printed) > * in `gdb.eval()` dropped check of the value returned by > `gdb.parse_and_eval()` as it would also fail for an expression like > `'0'` (looks like a kind of experimental code that was left by mistake) > * `lldb.eval()` is adjusted to return object of the same type as > `lldb.cast()` method returns (this improves consistency) > * renamed `dbg.eval` argument to reflect its meaning (it is > an expression rather than a command) > --- > src/luajit_dbg.py | 178 +++++++++-------- > .../debug-extension-tests.py | 182 +++++++++++++----- > 2 files changed, 234 insertions(+), 126 deletions(-) > > diff --git a/src/luajit_dbg.py b/src/luajit_dbg.py > index 80057a4e..77abf8c6 100644 > --- a/src/luajit_dbg.py > +++ b/src/luajit_dbg.py > @@ -694,8 +703,13 @@ class _LLDBDebugger(Debugger): > def write(self, msg): > sys.stdout.write(msg) > > + class DbgError(Exception): > + '''Raised to indicate an error during command execution. > + Doesn't cause a traceback to be printed (like gdb.GdbError for GDB).''' Side note: I'm a little bit concerned about that, but if it is needed for the consistency with LLDB, I'm OK with that. > + pass > + > def error(self, errmsg): > - return Exception(errmsg) > + return self.DbgError(errmsg) > > def check_libluajit(self): > # TODO: Implement postpone loading for LLDB too. > @@ -738,12 +752,27 @@ class _LLDBDebugger(Debugger): > def __call__(ljbase, debugger, args, exe_ctx, result): > try: > ljbase.execute(args) > - except Exception as e: > + except _LLDBDebugger.DbgError as e: > msg = 'Failed to execute command `{}`: {}'.format( > ljbase.name, > e > ) > result.SetError(msg) > + # `result` is an output argument of LLDB command > + # handler. If error message is set, LLDB displays Typo: s/error/an error/ > + # it in session. But such a message is missing in Typo: s/session/the session/ > + # output when the same problem occurs in batch Typo: s/output/the output/ > + # mode, so in order to be able to catch this kind > + # of error in batch mode it is needed to put it > + # into stderr explicitly. > + # Also to avoid duplication of the same error > + # message in interactive mode, it should be done > + # in batch mode only. There is no official way to > + # check if LLDB is in the batch mode so one of the > + # recommended workarounds is used below that > + # checks if tty is not used for standard input. > + if not sys.stdin.isatty(): > + result.PutError(lldb.SBFile.Create(sys.stderr, True)) > > @abc.abstractmethod > def execute(ljbase, args): > @@ -2399,7 +2428,7 @@ def dump_proto(proto): > diff --git a/test/tarantool-debugger-tests/debug-extension-tests.py b/test/tarantool-debugger-tests/debug-extension-tests.py > index ab44121c..fe8c5028 100644 > --- a/test/tarantool-debugger-tests/debug-extension-tests.py > +++ b/test/tarantool-debugger-tests/debug-extension-tests.py > @@ -19,30 +19,6 @@ LLDB = 'lldb' in DEBUGGER > EXTENSION = EXTENSION_PATH + '/luajit_dbg.py' > TIMEOUT = 10 > > -if LLDB: > - INFERIOR_ARGS = '--' > - LOAD_EXTENSION = 'command script import ' + EXTENSION > - PROCESS_RUN = ( > - # Prevent errors in case when running tests in Docker. > - 'settings set target.disable-aslr false\n' > - 'process launch' > - ) > - # Don't run any initialization scripts. > - RUN_CMD_FILE = [ > - '--batch', > - '--no-lldbinit', > - '--no-use-colors', > - '--source-quietly', > - '--source' > - ] > -else: > - # GDB. > - INFERIOR_ARGS = '--args' > - LOAD_EXTENSION = 'source ' + EXTENSION > - PROCESS_RUN = 'run' > - # Don't run any initialization scripts. > - RUN_CMD_FILE = ['--batch', '--nx', '--quiet', '--command'] > - > TEST_VERBOSE = os.getenv('DEBUGGER_TEST_VERBOSE', default=False) > > RX_ADDR = r'0x[a-f0-9]+' > @@ -60,7 +36,7 @@ def persist(data): > +if LLDB: > + INFERIOR_ARGS = '--' > + LOAD_EXTENSION = 'command script import ' + EXTENSION > + PROCESS_RUN = ( > + # Prevent errors in case when running tests in Docker. > + 'settings set target.disable-aslr false\n' > + 'process launch' > + ) > + # Don't run any initialization scripts. > + RUN_CMD_FILE = [ > + '--batch', > + '--no-lldbinit', > + '--no-use-colors', > + '--source-quietly', > + '--source' > + ] > + SET_EXEC = 'target create ' + LUAJIT_BINARY > + SET_RUN_ARGS = 'settings set target.run-args' > + > + def execute_process(cmd, timeout=TIMEOUT): > + # While executing extension commands LLDB might produce Typo: s/commands/commands,/ > + # errors that cannot be caught in extension. The internal Typo: s/extension/the extension/ > + # parser does some processing in background and might > + # emit an error message into stderr asynchronously. Also Typo: s/Also/Also,/ > + # the internal parser has a kind of fallback mechanism > + # that might resolve the problem, but is not able to > + # "cancel" the error message which might fail tests in Typo: s/message which/message, which/ > + # this case. > + # > + # List of regex that specifies lines to be wiped out from > + # the LLDB output. In case additional cleaning is needed, > + # just append this list with the correponding regex (use Typo: s/correponding/corresponding/ > + # as strict regex as possible in order to avoid accidental Typo: s/strict regex as/strictest regex/ > @@ -129,42 +160,38 @@ else: > > class TestCaseBase(unittest.TestCase): > @classmethod > - def construct_cmds(cls): > - return '\n'.join([ > + def construct_cmds(cls, deferred, *run_args): > + cmds = [ > + SET_EXEC, > + SET_RUN_ARGS + ' ' + ' '.join(run_args), > 'b {loc}'.format(loc=cls.location), > PROCESS_RUN, > 'n', > - LOAD_EXTENSION, > cls.extension_cmds.strip(), > - 'q', > - ]) > + ] > + cmds.insert(0 if deferred else 1, LOAD_EXTENSION) Minor: It may be nice to add the comment that we load the extension either before or after LuaJIT symbols are loaded. > + return '\n'.join(cmds) > > - @classmethod > - def setUpClass(cls): > - cmd_file = persist(cls.construct_cmds()) > - script_file = persist(cls.lua_script) > + def check(self, deferred=False): > + script_file = persist(self.lua_script) > + cmd_file = persist(self.construct_cmds(deferred, script_file.name)) > process_cmd = [ > DEBUGGER, > *RUN_CMD_FILE, > cmd_file.name, > - INFERIOR_ARGS, Why is this part missing? AMIUC, that this flag si not needed anymore after `SET_RUN_ARGS` is introduced? After removing, its variable is unused. Shouldn't it be removed then? > - LUAJIT_BINARY, > - script_file.name, > ] > > > # Test that the emitted debug information supports macro > @@ -1051,8 +1078,65 @@ class TestLJCTypeBase(TestCaseBase): > pattern = r'\[\d+\] ' > > > -for test_cls in TestCaseBase.__subclasses__(): > +class TestMissingArgBase(TestCaseBase): > + location = 'lj_cf_print' > + lua_script = 'print(1)' > + pattern = r'Argument is required\n' > + > + @classmethod > + def setUpClass(cls): > + cls.extension_cmds = '{}\n'.format(cls.cmd_name) > + super(TestMissingArgBase, cls).setUpClass() > + > + > +class TestMissingArgLJFunc(TestMissingArgBase): > + cmd_name = 'lj-func' > + > + > +class TestMissingArgLJTValue(TestMissingArgBase): > + cmd_name = 'lj-tv' > + > + > +class TestMissingArgLJBC(TestMissingArgBase): > + cmd_name = 'lj-bc' > + > + > +class TestMissingArgLJStr(TestMissingArgBase): > + cmd_name = 'lj-str' > + > + > +class TestMissingArgLJTable(TestMissingArgBase): > + cmd_name = 'lj-tab' > + > + > +class TestMissingArgLJProto(TestMissingArgBase): > + cmd_name = 'lj-proto' > + > + > +class TestMissingArgLJGCO(TestMissingArgBase): > + cmd_name = 'lj-gco' > + > + > +class TestMissingArgLJCType(TestMissingArgBase): > + cmd_name = 'lj-ctype' Minor: It looks like this classes can be generated in cycle. Feel free to ignore. > + > + > +def get_leaf_subclasses(cls): > + subclasses = cls.__subclasses__() > + if not subclasses: > + yield cls > + else: > + for sub in subclasses: > + for leaf in get_leaf_subclasses(sub): > + yield leaf > + > + > +for test_cls in get_leaf_subclasses(TestCaseBase): > test_cls.test = lambda self: self.check() Please add the comment that we double-check each function functionality in deferred loading mode to be sure that we initialize all internal variables correctly (as we discussed offline). > + test_cls.test_with_deferred_loading = \ > + unittest.skipIf(LLDB, "not supported for LLDB")( > + lambda self: self.check(True) > + ) > > if __name__ == '__main__': > unittest.main(verbosity=2) > -- > 2.55.0 > -- Best regards, Sergey Kaplun