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 9C6266EC40; Wed, 7 Jul 2021 10:12:01 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9C6266EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1625641921; bh=iGxq3zj/qkYedkOc1Kc4P/4vTFd77iqQX2yZITrkN3k=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=NIJJhGFy1yV8rrpmxNz1dVdlhwG+uXLTpSKZPaXeebDEfSOoldvmq9CscP5Vo8GB6 sGJhVulYp41nL5mX+PjaLHM2XFHYIG35UN63q83rp5oU9r2kmfI4lbQuZvmFz6vKj9 chApiD3ceOtgl9uklX3U/MDtzLY584s15KEeUC5E= Received: from smtp55.i.mail.ru (smtp55.i.mail.ru [217.69.128.35]) (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 D39A06EC40 for ; Wed, 7 Jul 2021 10:11:59 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D39A06EC40 Received: by smtp55.i.mail.ru with esmtpa (envelope-from ) id 1m11iw-0007W2-Lg; Wed, 07 Jul 2021 10:11:59 +0300 To: tarantool-patches@dev.tarantool.org, imun@tarantool.org, skaplun@tarantool.org Date: Wed, 7 Jul 2021 10:10:46 +0300 Message-Id: <20210707071046.649107-1-m.shishatskiy@tarantool.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD954DFF1DC42D673FB64496B12B6C6FB871CAFB561BC326F0E182A05F538085040584FC2D57919C70B3833344F1117D5A2F5B3DFB9F84D16FF3D007FCDBEDC4CB0 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE70B8ADF238913687CB287FD4696A6DC2FA8DF7F3B2552694A4E2F5AFA99E116B42401471946AA11AF7680F9384605B90375092E6AE21AB47A8F08D7030A58E5AD1A62830130A00468AEEEE3FBA3A834EE7353EFBB5533756644FE9905A23AFB6022C96E3A6544805A7CC58092D0C1486EA471835C12D1D9774AD6D5ED66289B5259CC434672EE6371117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658359CC434672EE6371117882F4460429728AD0CFFFB425014E868A13BD56FB6657D81D268191BDAD3DC09775C1D3CA48CFAD535A657613EBCEBA3038C0950A5D36C8A9BA7A39EFB766EC990983EF5C0329BA3038C0950A5D36D5E8D9A59859A8B6B7057F79CCFA8C9476E601842F6C81A1F004C906525384307823802FF610243DF43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7CDA0371536F40842743847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C44FE9905A23AFB6022C96E3A6544805A7CC58092D0C1486E9C2B6934AE262D3EE7EAB7254005DCEDB6797EC2B47515381E0A4E2319210D9B64D260DF9561598F01A9E91200F654B0C8396ECC17DE1DB78E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34F1257DC9690AEBA149D440A0EC07AF32C30A782B705631F606C80861DC6C85C4A18E3A5FE847999B1D7E09C32AA3244C2A1DF913C8E0CBFB4C58E2CE3000FD327C0C08F7987826B9927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojwWhFrYo6Pn1riGo54/QSkw== X-Mailru-Sender: EFA0F3A8419EF21622E4D85484454F2CE6156A4ABC3C108F3833344F1117D5A29BBFB9D4C9B768562376072A51849BFFE66B5C1DBFD5D09D5E022D45988A037B448E0EA96F20AB367402F9BA4338D657ED14614B50AE0675 X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit] gdb: fix misalignment in lj-stack for LJ_GC64 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 Shishatskiy via Tarantool-patches Reply-To: Mikhail Shishatskiy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Since commit 58790750b9c4bd4c21d883f109ab552a2e202a15 ('gdb: introduce luajit-gdb extension') when luajit-gdb.py is introduced, Lua stack slots printed by lj-stack command are misaligned, when LJ_GC64 is enabled. The issue is that PADDING variable used for aligning single slots in the output is initialized before LuaJIT build mode is defined in function, so the result was the following: | 0x7ffff7fb0d90:0x7ffff7fb0dc0 [ ] 7 slots: Red zone | 0x7ffff7fb0d88 [ M] | 0x7ffff7fb0cc0:0x7ffff7fb0d80 [ ] 25 slots: Free stack slots | 0x7ffff7fb0cb8 [ T ] | ... In scope of this patch, PADDING initialization is also moved to function right after all commands are loaded. As a result, the output looks as expected: | 0x7ffff7fb0d90:0x7ffff7fb0dc0 [ ] 7 slots: Red zone | 0x7ffff7fb0d88 [ M] | 0x7ffff7fb0cc0:0x7ffff7fb0d80 [ ] 25 slots: Free stack slots | 0x7ffff7fb0cb8 [ T ] | ... Fixes tarantool/tarantool#5876 --- Branch: https://github.com/tarantool/luajit/tree/shishqa/gh-5876 To test changes do the following: | $ gdb -q --args ./luajit -e 'print("QQ")' | Reading symbols from ./luajit... | 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 | (gdb) lj-arch | LJ_64: True, LJ_GC64: True | (gdb) b lj_cf_print | Breakpoint 1 at 0x298b0: file /mnt/WorkDisk/share/dev/__tarantool/lj-tarantool/src/lib_base.c, line 485. | (gdb) r | Starting program: /mnt/WorkDisk/share/dev/__tarantool/lj-tarantool/src/luajit -e print\(\"QQ\"\) | | Breakpoint 1, lj_cf_print (L=0x0) | at /mnt/WorkDisk/share/dev/__tarantool/lj-tarantool/src/lib_base.c:485 | 485 { | (gdb) s | 486 ptrdiff_t i, nargs = L->top - L->base; | (gdb) lj-stack L | 0x7ffff7fa8d90:0x7ffff7fa8dc0 [ ] 7 slots: Red zone | 0x7ffff7fa8d88 [ M] | 0x7ffff7fa8cc0:0x7ffff7fa8d80 [ ] 25 slots: Free stack slots | 0x7ffff7fa8cb8 [ T ] | 0x7ffff7fa8cb0 [ B ] VALUE: string "QQ" @ 0x7ffff7fb1178 | 0x7ffff7fa8ca0:0x7ffff7fa8ca8 [ ] FRAME: [L] delta=2, fast function #29 | 0x7ffff7fa8c90:0x7ffff7fa8c98 [ ] FRAME: [V] delta=2, Lua function @ 0x7ffff7fb1240, 0 upvalues, "=(command line)":0 | 0x7ffff7fa8c80:0x7ffff7fa8c88 [ ] FRAME: [CP] delta=4, Lua function @ 0x7ffff7fb1240, 0 upvalues, "=(command line)":0 | 0x7ffff7fa8c78 [ ] VALUE: C function @ 0x55555555c962 | 0x7ffff7fa8c70 [ ] VALUE: light userdata @ 0x0 | 0x7ffff7fa8c60:0x7ffff7fa8c68 [ ] FRAME: [CP] delta=2, C function @ 0x55555555df1c | 0x7ffff7fa8c58:0x7ffff7fa8c60 [S ] FRAME: dummy L src/luajit-gdb.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/luajit-gdb.py b/src/luajit-gdb.py index f1fd6230..720d989a 100644 --- a/src/luajit-gdb.py +++ b/src/luajit-gdb.py @@ -160,7 +160,7 @@ LJ_FR2 = None LJ_GCVMASK = ((1 << 47) - 1) -PADDING = ' ' * len(':' + hex((1 << (47 if LJ_GC64 else 32)) - 1)) +PADDING = None # }}} @@ -665,7 +665,7 @@ The command requires no args and dumps current GC stats: )) def init(commands): - global LJ_64, LJ_GC64, LJ_FR2 + global LJ_64, LJ_GC64, LJ_FR2, PADDING # XXX Fragile: though connecting the callback looks like a crap but it # respects both Python 2 and Python 3 (see #4828). @@ -714,6 +714,8 @@ def init(commands): for name, command in commands.items(): command(name) + PADDING = ' ' * len(':' + hex((1 << (47 if LJ_GC64 else 32)) - 1)) + gdb.write('luajit-gdb.py is successfully loaded\n') def load(event=None): -- 2.32.0