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 2BA5F6F81F; Fri, 20 Nov 2026 17:10:58 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 2BA5F6F81F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1795183858; bh=bUbuXjPANRwfL9vyPZ+erS2mY37mnxtR/9lUt+jwE/Y=; 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=WyDDHc118+cWDPobPWEwz6qnTL7LN/IiaJvmNCkOHoqRpPgDLgIZpmyNaANJPoemP vpI31biiZYpTBnCPVfEtRwVgnZbWBTV/d69L73f3M+jz4igui1hZJpjdlOTacuvmCd 4RRBWF9VaJc3qQvwrAucTWAue/IFaEsm9ts1PZY8= Received: from send151.i.mail.ru (send151.i.mail.ru [89.221.237.246]) (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 B6C906F81F for ; Fri, 20 Nov 2026 17:10:56 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B6C906F81F Received: by exim-smtp-56bb8ff957-m57pn with esmtpa (envelope-from ) id 1xUPKJ-00000000Q7S-0kBx; Fri, 20 Nov 2026 17:10:55 +0300 Date: Fri, 20 Nov 2026 17:13:11 +0300 To: Mikhail Elhimov Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-618D5548: 57C03A12D1CA74594BD03525DDD6C8963ABE87F4886578642A15D4BAEB1D7105649BF128C5D6472B X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9F0F7827A03D16B765BE031D3EFF6392A47335DCA4567F0EB1867C24CE74E72BB5FE18E9CBFBE7C0762D00345CBA639608E4030E5EC4E3C0C4CAD58654CB7595A7B10834EA722D0E4FEDCCBD3DDE7F493 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7A8325FA649D0A450EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566B47933B1EBDEC5AF0874FC398460CD33837D2D8755258557E280DCFA64210E74389733CBF5DBD5E9D5E8D9A59859A8B6A70DDFFB3186CBC5CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8090A508E0FED62991661749BA6B977351B03672033AC981DCD04E86FAF290E2DB606B96278B59C421DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6045A9A90E9EED90B089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A5A7670973F8695F6A5002B1117B3ED696B7E38EB9A5E2026D4A0A47EBA01A636A3610D81D389A125CDE35189EBF2DEA28FEA14CD2CD220BB99C5DF10A05D560A9880EC71AF561E0AAD9143641EC25BB39C9DC896FBFA37178 X-C8649E89: 1C3962B70DF3F0ADB58128AB1E6D661A8E10F71CB4DF9F96AB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D6591C8BB2893F11B84334A03C85C768E4B2A24FB8103AB8452B6FF357887DB247B95C594B8C4C59FEABB8341EE9D5BE9A0A12EA903917A2777C265D8139DA9665B1A2D799C981EA4A00C7CEAA0681F5848F4C41F94D744909CECFA6C6B0C050A61A8CAF69B82BA93681CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXOcIETfglQORZ0zpDET4Zrk3igikrdHlWE/Sgg3DyugJm5/lFOSIJYM= X-Mailru-Sender: 520A125C2F17F0B17094CDC02B85F11B83EBA81D1E0A76353DE06ABAFEAF67052BAB593F0F62F546B7CBEF92542CD7C88B0A2698F12F5C9EC77752E0C033A69E86920BD37369036789A8C6A0E60D2BB63A5DB60FBEB33A8A0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 2/4] dbg: avoid hardcoded enums 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: > Besides reducing lines of code this way the extension becomes compatible > with various versions of LuaJIT because different versions might use > different sets of enum members (a newer version might introduce > additional BC/IR/etc.) > > Prior to this patch, the string was used as a debugger-agnostic way to > specify type, but this way might not work in the case of an enum because > debugging information might be optimized out if no variable of such an > enum type is declared and its members are used only as predefined > constants. The type of enum is needed to be able to get human-readable > value (member name instead of number). The alternative way to get enum > type is to get it from the value, i.e. somehow obtain the value that is > of enum type and then use this type to convert the numbers to the member > names. > > Creating the value of the given enum member is quite different in GDB > and LLDB, so separate method `create_enum_value` was introduced in > Debugger API. Also new method `cast_typeof` was introduced to perform > value-based cast, i.e. it casts to the same type as a reference value. > > Also this patch fixes the mapping of FPMATHOP to a human-readable form, > because prior to this patch, IRFPMS contained the incorrect entry > 'exp2'. IRFPMS is a human-readable form of enum IRFPMathOp, but there is > no 'exp2' enum member actually (see IRFPMDEF). It looks like it was > added by mistake initially (corresponding tests to check mapping of > FPMATHOP were added). > > Resolves tarantool/tarantool#13094 > Resolves tarantool/tarantool#13159 > --- > src/luajit_dbg.py | 675 +++++------------- > .../debug-extension-tests.py | 62 +- > 2 files changed, 249 insertions(+), 488 deletions(-) > > diff --git a/src/luajit_dbg.py b/src/luajit_dbg.py > index 77abf8c6..ceba4c58 100644 > --- a/src/luajit_dbg.py > +++ b/src/luajit_dbg.py > @@ -106,6 +106,8 @@ class Debugger(object): > def initialize_extension(self, commands): > if self.configure(): > for name, command in commands.items(): > + if hasattr(command, 'pre_register'): > + command.pre_register() Please add the comment that this is needed for generated documentation for function's help. > self.register_command(command, name) > self.write('{} command initialized\n'.format(name)) > self.write('LuaJIT debug extension is successfully loaded\n') > @@ -119,6 +121,13 @@ class Debugger(object): > @@ -829,6 +916,55 @@ def strx64(val): > return re.sub('L?$', '', hex(int(tou64(val)))) > > > +class EnumBasedList(object): > + def __init__(self, max_enum_member, enum_name, map_func=None, > + *map_func_args): > + self.__max_enum_member = max_enum_member > + self.__enum_name = enum_name > + self.__map_func = map_func > + self.__map_func_args = map_func_args > + # Lazy initialization (see __get_items) as the required > + # information might be unavailable at this moment. > + self.__items = None Nit: Please sort these items alphabetically. Nit: Please sort functions below alphabetically. > + > + def __iter__(self): > + return iter(self.__get_items()) > + > + def __getitem__(self, key): > + return self.__get_items()[key] > + > + def __len__(self): > + return len(self.__get_items()) > + > + def __get_items(self): > + if self.__items is None: > + try: > + max_enum_value = dbg.create_enum_value( > + self.__max_enum_member, self.__enum_name > + ) > + except Exception as e: > + msg = 'failed to resolve {} enum members using {}'.format( > + self.__enum_name or 'anonymous', > + self.__max_enum_member, > + ) > + raise dbg.error('{}: {}'.format(msg, e)) > + items = [] > + for i in range(max_enum_value): > + item = str(dbg.cast_typeof(max_enum_value, i)) > + if self.__map_func: > + item = self.__map_func(item, *self.__map_func_args) > + items.append(item) > + self.__items = items > + return self.__items > + > + def index(self, item): > + return self.__get_items().index(item) Why do not use __index__ method for this? Since `IRTYPES['num']` is more readable than `IRTYPES.index('num')`, IMO. Since we assume that idx == value for these lists. Also, it is worth mentinoning that these generated lists skips some enums that are defined equal to others like there is no: IRT_PGC, IRT_PTR, and also skips all enums that are greater than border __MAX value (IRT_MARK, etc) (I suppose there is no need in this functionality right now, just worth mentioning). > -- > 2.55.0 > -- Best regards, Sergey Kaplun