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 E28BC6EC40; Mon, 16 Aug 2021 12:12:44 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E28BC6EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1629105165; bh=sMjmdgsPxvcO1T4Nq+JyTxwIby1fyR0i1eS1xvRobGc=; 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=BVX4CHd5QhFME7V1t0sN886efXwVc/67mMRYcvbomf+ss9Jw6nqGpD4pGZuCsNY05 BY0If8zspnRV9ZW+aXRbon9lm7hdjHOhSrx79m2AJCoX64vuyTPEVkzduTh0zSxF9h 1kC7R7EwhGdNGVntFBLygvLfHiFUqYMWvOtHirEo= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 49D106EC40 for ; Mon, 16 Aug 2021 12:12:44 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 49D106EC40 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mFYfj-0001Nt-9M; Mon, 16 Aug 2021 12:12:43 +0300 Date: Mon, 16 Aug 2021 11:49:02 +0300 To: Maxim Kokryashkin Message-ID: <20210816084902.GS27855@tarantool.org> References: <1628864967.181226130@f723.i.mail.ru> <20210814113834.1171307-1-m.kokryashkin@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210814113834.1171307-1-m.kokryashkin@tarantool.org> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.10.1 (2018-07-13) X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92087353F0EC44DD906AB4890CDABF0C5CB76CEE71D3E4007182A05F538085040E901CED43D4213BF9F9B77B3A31E5B5B739E98CA4449DF3B984D96647B129AEA X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE76ABD3380F320B62CEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637A6C16C7015BEC7F48638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D849983726BC44037FA58773C29DC6151A117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18618001F51B5FD3F9D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6BF3059D42242344A089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A526BC8B5A75E402494FAC5460D0C1D102EC2193E536234785D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA752DA3D96DA0CEF5C48E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3475FE4AA98865E23598FE97638AD7B1D810A69F63F885465CF6C309B46B1A798B305177A9E66C6E1E1D7E09C32AA3244C4C386C49523CFBB905799BC87E0AFCE3853296C06374E60283B48618A63566E0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojIrFL/N5KnVGqVCPhB4XTWg== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5DE953A5BC861124CCC6AA6C4A89ADC441A7C8D0F45F857DBFE9F1EFEE2F478337FB559BB5D741EB964C8C2C849690F8E70A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit v2] luajit-gdb: support dualnum mode 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: Igor Munkin via Tarantool-patches Reply-To: Igor Munkin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Max, Thanks for the patch! Please consider the comments below. At first, please use 'gdb:' instead of 'luajit-gdb:' like for the others patches. I would also use 'LJ_DUALNUM' instead of the plain 'dualnum'. On 14.08.21, Maxim Kokryashkin wrote: > luajit-gdb.py displays integers in LJ_DUALNUM mode as nan-s. The > dumper function produces output thinking of any input value as of a Minor: s/thinking of/considering/, but feel free to ignore. > double. However, in DUALNUM mode, integers and doubles are stored Please, be consistent in mode name: choose one from LJ_DUALNUM, DUALNUM or dualnum and use it patch-wide. > differently, so the `itype` of a float number must be less than Minor: It's either double (for the storage type) or floating point. > `LJ_TISNUM`, and the `itype` of an integer must be `LJ_TISNUM`. With > this fact in mind, we can easily differentiate one from another. > > Closes tarantool/tarantool#6224 > --- > Changes in v2: > - Fixed comments as per review by Sergey > > src/luajit-gdb.py | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-) > > diff --git a/src/luajit-gdb.py b/src/luajit-gdb.py > index c50405ad..d4882dd7 100644 > --- a/src/luajit-gdb.py > +++ b/src/luajit-gdb.py > def tvislightud(o): > if LJ_64 and not LJ_GC64: > @@ -343,7 +346,10 @@ def dump_lj_tudata(tv): > return 'userdata @ {}'.format(strx64(gcval(tv['gcr']))) > > def dump_lj_tnumx(tv): > - return 'number {}'.format(cast('double', tv['n'])) > + if tvisint(tv): > + return 'number {}'.format(cast('int32_t', tv['i'])) Side note: Agree with Sergey here. It is more convenient to understand that TValue structure for integer slot differs from double. > + else: > + return 'number {}'.format(cast('double', tv['n'])) > > def dump_lj_invalid(tv): > return 'not valid type @ {}'.format(strx64(gcval(tv['gcr']))) > @@ -683,7 +689,7 @@ The command requires no args and dumps current GC stats: > )) > > def init(commands): > - global LJ_64, LJ_GC64, LJ_FR2, PADDING > + global LJ_64, LJ_GC64, LJ_DUALNUM, LJ_TISNUM, LJ_FR2, PADDING Minor: Why did you split LJ_GC64 and LJ_FR2. I understand you want to group all LJ_* entries together, so you didn't just append the new ones, but please move the new LJ_* entries after the old ones. > > # XXX Fragile: though connecting the callback looks like a crap but it > # respects both Python 2 and Python 3 (see #4828). > @@ -724,6 +730,7 @@ def init(commands): > try: > LJ_64 = str(gdb.parse_and_eval('IRT_PTR')) == 'IRT_P64' > LJ_FR2 = LJ_GC64 = str(gdb.parse_and_eval('IRT_PGC')) == 'IRT_P64' > + LJ_DUALNUM = lookup('lj_lib_checknumber') is not None Ouch... Not such elegant as for other defines, but I see we have no choice here... Anyway, this doesn't work for the following scenario: | # gdb --args ./luajit -e 'print(1)' | | (gdb) source luajit-gdb.py | luajit-gdb.py failed to load: no debugging symbols found for libluajit However, the next case is fine: | # gdb --args ./luajit -e 'print(1)' | | (gdb) b lj_cf_print | Breakpoint 1 at 0x28350: file /luajit/src/lib_base.c, line 486. | (gdb) r | Starting program: /luajit/src/luajit -e print\(1\) | | Breakpoint 1, lj_cf_print (L=0x7fb7d57378) at /luajit/src/lib_base.c:486 | 486 ptrdiff_t i, nargs = L->top - L->base; | (gdb) source luajit-gdb.py | lj-arch command initialized | lj-tv command initialized | lj-str command initialized | lj-tab command initialized | lj-stack command initialized | lj-state command initialized | lj-gc command initialized | luajit-gdb.py is successfully loaded The problem is that you use that requires a frame, but there is none, until the program is run. The function you need for your case is . Consider the diff below: | diff --git a/src/luajit-gdb.py b/src/luajit-gdb.py | index 9ccca66a..4dc8c844 100644 | --- a/src/luajit-gdb.py | +++ b/src/luajit-gdb.py | @@ -731,7 +731,7 @@ def init(commands): | try: | LJ_64 = str(gdb.parse_and_eval('IRT_PTR')) == 'IRT_P64' | LJ_FR2 = LJ_GC64 = str(gdb.parse_and_eval('IRT_PGC')) == 'IRT_P64' | - LJ_DUALNUM = lookup('lj_lib_checknumber') is not None | + LJ_DUALNUM = gdb.lookup_global_symbol('lj_lib_checknumber') is not None | except: | gdb.write('luajit-gdb.py failed to load: ' | 'no debugging symbols found for libluajit\n') As a result, the extension loads fine even before the program is started: | # gdb --args ./luajit -e 'print(1)' | | (gdb) source luajit-gdb.py | lj-arch command initialized | lj-tv command initialized | lj-str command initialized | lj-tab command initialized | lj-stack command initialized | lj-state command initialized | lj-gc command initialized | luajit-gdb.py is successfully loaded BTW, it's worth to extend output with LJ_DUALNUM value. > except: > gdb.write('luajit-gdb.py failed to load: ' > 'no debugging symbols found for libluajit\n') > -- > 2.32.0 > -- Best regards, IM