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 C7B746E200; Fri, 18 Jun 2021 09:23:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C7B746E200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1623997432; bh=k/TrfE4ToOoPqDr3PCBRD9PyWqdyZnAEsP8iw2+M1J0=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=lgvACmEMDmXRVFRTClRHWgVK7iwrnzkbnvnO2YrXlVgIiLZYHBnu7JloOthyYRefh zLGCWC8vqxBa+tTqYU2C6CpRmNBqDxV8mMebjvAvPoXV7GvFOnytritxVfLYj6oW1d YdFzZp854PPNaNJ0s1j/QE/58A5hVfcWW8CC+9K4= Received: from smtp31.i.mail.ru (smtp31.i.mail.ru [94.100.177.91]) (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 1F1D96E200 for ; Fri, 18 Jun 2021 09:23:51 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1F1D96E200 Received: by smtp31.i.mail.ru with esmtpa (envelope-from ) id 1lu7uv-0003b5-Sn; Fri, 18 Jun 2021 09:23:50 +0300 To: Sergey Ostanevich , Igor Munkin Date: Fri, 18 Jun 2021 09:22:34 +0300 Message-Id: <20210618062234.871-1-skaplun@tarantool.org> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD91C2C07775F13263A38E2610A94B554561BE460F683D6B25800894C459B0CD1B9EF302CCD86C92ABBB9B9215A72C5FA8D04303251EFEA349B7F7399A604DAC192 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7A34C649281B21B01EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637F832FB01FC7F589C8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8EA808C9D4082296A92F4A94D50C40DCA117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18F04B652EEC242312D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6A45692FFBBD75A6A089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C128C1281A48FD13CB851170B1A5D75507D0BAC11ABC2DBCB9C2B6934AE262D3EE7EAB7254005DCED9B4539D1DB52DF411E0A4E2319210D9B64D260DF9561598F01A9E91200F654B06CE7B4E551862B828E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D340297C696F996E38417C0EA183F339B7AE09159A925BEC11136669CF9B1A0B2B6E3F9D2DA9EDEE47D1D7E09C32AA3244C8B7AFAF9EDD85A510E3BD8853AC0E9164DBEAD0ED6C55A80927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojbL9S8ysBdXgQJMOue9B65l6OgatpKmUZ X-Mailru-Sender: 3B9A0136629DC91206CBC582EFEF4CB4935D4163C1D7CBCA18A2CD2911A3CD513B7D59E5EA7EFF0EF2400F607609286E924004A7DEC283833C7120B22964430C52B393F8C72A41A89437F6177E88F7363CDA0F3B3F5B9367 X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit v1] tools: fix luajit-gdb stack dump 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" When there is only one frame (so-called dummy frame) with a dummy thread on stack bottom at L->base - 1 - LJ_FR2, stack dump does not show stack slots from bottom to top, because the frame link is already pointed to stack bottom (dummy thread mentioned above). Its output looks like the following: | 0x7fb512ac40:0x7fb512ac70 [ ] 7 slots: Red zone | 0x7fb512ac38 [ M] | 0x7fb512ab28:0x7fb512ac30 [ ] 34 slots: Free stack slots | 0x7fb512ab20 [ T ] | 0x7fb512ab08:0x7fb512ab10 [S ] FRAME: dummy L This patch unrolled first loop iteration. Stack dump first inspect all fields for the top frame and then continue if there are other frames. After patch the output looks like the following: | 0x7fb512ac40:0x7fb512ac70 [ ] 7 slots: Red zone | 0x7fb512ac38 [ M] | 0x7fb512ab28:0x7fb512ac30 [ ] 34 slots: Free stack slots | 0x7fb512ab20 [ T ] | 0x7fb512ab18 [ ] VALUE: string 0 "/tmp/net_box.lua:6: err in ser" @ 0x7fb512ade8 | 0x7fb512ab10 [ B ] VALUE: table @ 0x7fb512ac80 (asize: 0, hmask: 0x0) | 0x7fb512ab00:0x7fb512ab08 [S ] FRAME: dummy L --- Branch: https://github.com/tarantool/luajit/tree/skaplun/fix-luajit-gdb Steps to test behaviour: 0) Clone branch 1) Build tarantool with GC64 or not (I've tested both cases) 2) Run the following script by Tarantool via gdb. | $ cat /tmp/netbox.lua | box.cfg{log_level = 50, listen = "127.0.0.1:3802"} | box.schema.user.grant('guest','read,write,execute','universe', nil, {if_not_exists=true}) | local net_box = require"net.box" | local cn = net_box:connect("127.0.0.1:3802") | local function f() | return setmetatable({}, {__serialize = function() error[[err in ser]] end}) | end | _G.f = f | local r, st = cn:call("f") | print(r,st) | $ gdb --args ./tarantool /tmp/netbox.lua | ... | (gdb) source ~/builds_workspace/luajit/fix-luajit-gdb/src/luajit-gdb.py | ... 3) Set breakpoint to ./src/lua/msgpack.c:234, and run | (gdb) b ./src/lua/msgpack.c:234 I'm not sure about your sources version, so you can just set breakpoin to mp_encode(), run and continue (need two entries). We are interested in the line #234: | 233|.......if (luaL_tofield(L, cfg, opts, lua_gettop(L), &field) < 0) | 234|.......|.......return luaT_error(L); And dump the stack: | (gdb) lj-stack L | 0x7fb512ac40:0x7fb512ac70 [ ] 7 slots: Red zone | 0x7fb512ac38 [ M] | 0x7fb512ab28:0x7fb512ac30 [ ] 34 slots: Free stack slots | 0x7fb512ab20 [ T ] | 0x7fb512ab18 [ ] VALUE: string 0 "/tmp/net_box.lua:6: err in ser" @ 0x7fb512ade8 | 0x7fb512ab10 [ B ] VALUE: table @ 0x7fb512ac80 (asize: 0, hmask: 0x0) | 0x7fb512ab00:0x7fb512ab08 [S ] FRAME: dummy L src/luajit-gdb.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/luajit-gdb.py b/src/luajit-gdb.py index f1fd6230..a3dad585 100644 --- a/src/luajit-gdb.py +++ b/src/luajit-gdb.py @@ -424,16 +424,26 @@ def dump_stack(L, base=None, top=None): ) ]) + '\n' + # Set framelink for the top frame. Dump frame slots even for dummy frame. slot = top - 1 framelink = base - (1 + LJ_FR2) + while slot > framelink + LJ_FR2: + dump += dump_stack_slot(L, slot, base, top) + slot -= 1 + # If there are other frames -- continue. while framelink > mref('TValue *', L['stack']): - while slot > framelink + LJ_FR2: - dump += dump_stack_slot(L, slot, base, top) - slot -= 1 + assert slot == framelink + LJ_FR2, "Invalid slot during frame unwind" dump += dump_framelink(L, framelink) framelink = frame_prev(framelink + LJ_FR2) - LJ_FR2 slot -= 1 + LJ_FR2 + while slot > framelink + LJ_FR2: + dump += dump_stack_slot(L, slot, base, top) + slot -= 1 + + assert slot == framelink + LJ_FR2, "Invalid slot after frame unwind" + # Skip nil slot for the last frame for 2-slot frames. + slot -= LJ_FR2 dump += '{fr}{padding} [S ] FRAME: dummy L'.format( fr = slot, -- 2.31.0