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 504726ECE3; Thu, 9 Jun 2022 13:14:09 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 504726ECE3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1654769649; bh=xH0eW8Ju40RjSPan7OZfe53nRg8Ia408LhBr+u28GYM=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=jyNhheVf11Dup6xGr+xDi++ShQptQ+XNgzgGzjRQQVfs8eftSiqUb59E62HyFkNTR 24+3GKlqUTxVpRwaRqCgd4j7oTC5L6D+JsVEJeyMWNUgVJJIxTTAclkPFTC5qwWoBV z83nTIwoqXgzcnvGIMmPNbWmObemtzLy5fTzSxgM= Received: from smtpng3.i.mail.ru (smtpng3.i.mail.ru [94.100.177.149]) (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 7D3DB6ECE3 for ; Thu, 9 Jun 2022 13:13:39 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7D3DB6ECE3 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1nzFAY-0007Ak-Nt; Thu, 09 Jun 2022 13:13:39 +0300 To: Maxim Kokryashkin , Igor Munkin Date: Thu, 9 Jun 2022 13:11:13 +0300 Message-Id: <7539a0ac196ba192636d5f6cfc1c03d9f50f7c4a.1654767443.git.skaplun@tarantool.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD97D44297578DBEB86154F2FD640FB217DD2F62882B2E12183182A05F5380850408E2D82749B6364DA8C2250A62E32AE96ADD7AB44791101EC691A9FF00CFD2E12 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE789805A6418246A1AEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006375341C8025CE2618E8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D85B256114D517C7245B0DF52ADB5E58C8117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF1175FABE1C0F9B6A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18C26CFBAC0749D213D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6AC294AFEFA671E80089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-8FC586DF: 6EFBBC1D9D64D975 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C83BF3A71D03FAA4AB551D94E2AB72FC8D21448B09CD5A82C9C2B6934AE262D3EE7EAB7254005DCED1C39E39C5FB3188C4EAF44D9B582CE87C8A4C02DF684249C42578FD4EBC74EEF699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D340A59E724FC7897F74308DB023C604445493E7F7D591CC37AB764E5CBA683CD6A7B42C7EB5583EF311D7E09C32AA3244C92DD7768674C84DCA357AD98CC14EBC8BBA718C7E6A9E042927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojgs1behNStknT8rlLfQhI5Q== X-Mailru-Sender: 689FA8AB762F739339CABD9B3CA9A7D66721024BCF470B7D3B4481C7CB11DD860FBE9A32752B8C9C2AA642CC12EC09F1FB559BB5D741EB962F61BD320559CF1EFD657A8799238ED55FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit 1/2] gdb: introduce dumpers for GCobj 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" Our gdb extension already has dumpers for TValues. But sometimes it may be useful to dump GCobjects without stack context. This patch adds additional wrappers around dumpers for GC objects, to get the corresponding GC object from a TValue. --- src/luajit-gdb.py | 151 +++++++++++++++++++++++++++++++--------------- 1 file changed, 102 insertions(+), 49 deletions(-) diff --git a/src/luajit-gdb.py b/src/luajit-gdb.py index baf66f66..779a25f8 100644 --- a/src/luajit-gdb.py +++ b/src/luajit-gdb.py @@ -301,35 +301,28 @@ gclen = { # Dumpers {{{ -def dump_lj_tnil(tv): - return 'nil' - -def dump_lj_tfalse(tv): - return 'false' +# GCobj dumpers. -def dump_lj_ttrue(tv): - return 'true' +def dump_lj_gco_lightud(gcobj): + return 'light userdata @ {}'.format(strx64(gcobj)) -def dump_lj_tlightud(tv): - return 'light userdata @ {}'.format(strx64(gcval(tv['gcr']))) - -def dump_lj_tstr(tv): +def dump_lj_gco_str(gcobj): return 'string {body} @ {address}'.format( - body = strdata(gcval(tv['gcr'])), - address = strx64(gcval(tv['gcr'])) + body = strdata(gcobj), + address = strx64(gcobj) ) -def dump_lj_tupval(tv): - return 'upvalue @ {}'.format(strx64(gcval(tv['gcr']))) +def dump_lj_gco_upval(gcobj): + return 'upvalue @ {}'.format(strx64(gcobj)) -def dump_lj_tthread(tv): - return 'thread @ {}'.format(strx64(gcval(tv['gcr']))) +def dump_lj_gco_thread(gcobj): + return 'thread @ {}'.format(strx64(gcobj)) -def dump_lj_tproto(tv): - return 'proto @ {}'.format(strx64(gcval(tv['gcr']))) +def dump_lj_gco_proto(gcobj): + return 'proto @ {}'.format(strx64(gcobj)) -def dump_lj_tfunc(tv): - func = cast('struct GCfuncC *', gcval(tv['gcr'])) +def dump_lj_gco_func(gcobj): + func = cast('struct GCfuncC *', gcobj) ffid = func['ffid'] if ffid == 0: @@ -345,57 +338,117 @@ def dump_lj_tfunc(tv): else: return 'fast function #{}'.format(int(ffid)) -def dump_lj_ttrace(tv): - trace = cast('struct GCtrace *', gcval(tv['gcr'])) +def dump_lj_gco_trace(gcobj): + trace = cast('struct GCtrace *', gcobj) return 'trace {traceno} @ {addr}'.format( traceno = strx64(trace['traceno']), addr = strx64(trace) ) -def dump_lj_tcdata(tv): - return 'cdata @ {}'.format(strx64(gcval(tv['gcr']))) +def dump_lj_gco_cdata(gcobj): + return 'cdata @ {}'.format(strx64(gcobj)) -def dump_lj_ttab(tv): - table = cast('GCtab *', gcval(tv['gcr'])) +def dump_lj_gco_tab(gcobj): + table = cast('GCtab *', gcobj) return 'table @ {gcr} (asize: {asize}, hmask: {hmask})'.format( gcr = strx64(table), asize = table['asize'], hmask = strx64(table['hmask']), ) -def dump_lj_tudata(tv): - return 'userdata @ {}'.format(strx64(gcval(tv['gcr']))) +def dump_lj_gco_udata(gcobj): + return 'userdata @ {}'.format(strx64(gcobj)) + +def dump_lj_gco_invalid(gcobj): + return 'not valid type @ {}'.format(strx64(gcobj)) + +# TValue dumpers. + +def dump_lj_tv_nil(tv): + return 'nil' + +def dump_lj_tv_false(tv): + return 'false' + +def dump_lj_tv_true(tv): + return 'true' + +def dump_lj_tv_lightud(tv): + return dump_lj_gco_lightud(gcval(tv['gcr'])) + +def dump_lj_tv_str(tv): + return dump_lj_gco_str(gcval(tv['gcr'])) + +def dump_lj_tv_upval(tv): + return dump_lj_gco_upval(gcval(tv['gcr'])) + +def dump_lj_tv_thread(tv): + return dump_lj_gco_thread(gcval(tv['gcr'])) + +def dump_lj_tv_proto(tv): + return dump_lj_gco_proto(gcval(tv['gcr'])) + +def dump_lj_tv_func(tv): + return dump_lj_gco_func(gcval(tv['gcr'])) + +def dump_lj_tv_trace(tv): + return dump_lj_gco_trace(gcval(tv['gcr'])) -def dump_lj_tnumx(tv): +def dump_lj_tv_cdata(tv): + return dump_lj_gco_cdata(gcval(tv['gcr'])) + +def dump_lj_tv_tab(tv): + return dump_lj_gco_tab(gcval(tv['gcr'])) + +def dump_lj_tv_udata(tv): + return dump_lj_gco_udata(gcval(tv['gcr'])) + +def dump_lj_tv_numx(tv): if tvisint(tv): return 'integer {}'.format(cast('int32_t', tv['i'])) else: return 'number {}'.format(cast('double', tv['n'])) -def dump_lj_invalid(tv): - return 'not valid type @ {}'.format(strx64(gcval(tv['gcr']))) +def dump_lj_tv_invalid(tv): + return dump_lj_tv_udata(gcval(tv['gcr'])) # }}} -dumpers = { - 'LJ_TNIL': dump_lj_tnil, - 'LJ_TFALSE': dump_lj_tfalse, - 'LJ_TTRUE': dump_lj_ttrue, - 'LJ_TLIGHTUD': dump_lj_tlightud, - 'LJ_TSTR': dump_lj_tstr, - 'LJ_TUPVAL': dump_lj_tupval, - 'LJ_TTHREAD': dump_lj_tthread, - 'LJ_TPROTO': dump_lj_tproto, - 'LJ_TFUNC': dump_lj_tfunc, - 'LJ_TTRACE': dump_lj_ttrace, - 'LJ_TCDATA': dump_lj_tcdata, - 'LJ_TTAB': dump_lj_ttab, - 'LJ_TUDATA': dump_lj_tudata, - 'LJ_TNUMX': dump_lj_tnumx, +gco_dumpers = { + 'LJ_TLIGHTUD': dump_lj_gco_lightud, + 'LJ_TSTR': dump_lj_gco_str, + 'LJ_TUPVAL': dump_lj_gco_upval, + 'LJ_TTHREAD': dump_lj_gco_thread, + 'LJ_TPROTO': dump_lj_gco_proto, + 'LJ_TFUNC': dump_lj_gco_func, + 'LJ_TTRACE': dump_lj_gco_trace, + 'LJ_TCDATA': dump_lj_gco_cdata, + 'LJ_TTAB': dump_lj_gco_tab, + 'LJ_TUDATA': dump_lj_gco_udata, } +tv_dumpers = { + 'LJ_TNIL': dump_lj_tv_nil, + 'LJ_TFALSE': dump_lj_tv_false, + 'LJ_TTRUE': dump_lj_tv_true, + 'LJ_TLIGHTUD': dump_lj_tv_lightud, + 'LJ_TSTR': dump_lj_tv_str, + 'LJ_TUPVAL': dump_lj_tv_upval, + 'LJ_TTHREAD': dump_lj_tv_thread, + 'LJ_TPROTO': dump_lj_tv_proto, + 'LJ_TFUNC': dump_lj_tv_func, + 'LJ_TTRACE': dump_lj_tv_trace, + 'LJ_TCDATA': dump_lj_tv_cdata, + 'LJ_TTAB': dump_lj_tv_tab, + 'LJ_TUDATA': dump_lj_tv_udata, + 'LJ_TNUMX': dump_lj_tv_numx, +} + +def dump_gcobj(gcobj): + return gco_dumpers.get(typenames(i2notu32(gcobj['gch']['gct'])), dump_lj_gco_invalid)(gcobj) + def dump_tvalue(tvalue): - return dumpers.get(typenames(itypemap(tvalue)), dump_lj_invalid)(tvalue) + return tv_dumpers.get(typenames(itypemap(tvalue)), dump_lj_tv_invalid)(tvalue) def dump_framelink(L, fr): fr2 = fr + LJ_FR2 @@ -408,7 +461,7 @@ def dump_framelink(L, fr): p = 'P' if frame_typep(fr2) & FRAME_P else '' ), d = cast('TValue *', fr2) - cast('TValue *', frame_prev(fr2)), - f = dump_lj_tfunc(fr), + f = dump_lj_tv_func(fr), ) def dump_stack_slot(L, slot, base=None, top=None, eol='\n'): -- 2.34.1