From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [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 3D39146970E for ; Wed, 5 Feb 2020 19:24:47 +0300 (MSK) From: Igor Munkin Date: Wed, 5 Feb 2020 19:22:26 +0300 Message-Id: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v2 luajit 0/3] Introduce gdb extension for LuaJIT List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org The series provides a gdb extension with commands for inspecting LuaJIT internals. To use it, just put 'source /src/luajit-gdb.py' in gdb. The extension obliges the one to provide gdbinfo for libluajit, otherwise loading can fail with the error: | (gdb) source /src/luajit-gdb.py | luajit-gdb.py failed to load: no debugging symbols found for libluajit When the loading succeeds the one see the following: | (gdb) source /src/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 Below is a description for the set of implemented commands below: ### lj-arch The command requires no args and dumps values of LJ_64 and LJ_GC64 compile-time flags. These values define the sizes of host and GC pointers respectively. NB: Compile-time defines are checked when script is being loaded: * When LJ_64 is enabled IRT_PTR is an IRT_P64 alias and an IRT_P32 one otherwise * When LJ_64 is enabled IRT_PGC is an IRT_P64 alias and an IRT_P32 one otherwise ### lj-tv The command recieves a (TValue address) and dumps the type and some info related to it. * LJ_TNIL: nil * LJ_TFALSE: false * LJ_TTRUE: true * LJ_TLIGHTUD: light userdata @ * LJ_TSTR: string @ * LJ_TUPVAL: upvalue @ * LJ_TTHREAD: thread @ * LJ_TPROTO: proto @ * LJ_TFUNC: - : Lua function @ , upvalues, - : C function - : fast function # * LJ_TTRACE: trace @ * LJ_TCDATA: cdata @ * LJ_TTAB: table @ (asize: , hmask: ) * LJ_TUDATA: userdata @ * LJ_TNUMX: number Whether the type of the given address differs from the listed above, then error message occurs. ### lj-str The command recieves a of the corresponding GCstr object and dumps the payload, size in bytes and hash. *Caveat*: Since Python 2 provides no native Unicode support, the payload is replaced with the corresponding error when decoding fails. ### lj-tab The command recieves a GCtab address and dumps the table contents: * Metatable address whether the one is set * Array part slots: : []: * Hash part nodes: : { } => { }; next = ### lj-stack The command recieves a lua_State address and dumps the given Lua coroutine guest stack: [] * : guest stack slot address * : - S: Bottom of the stack (the slot L->stack points to) - B: Base of the current guest frame (the slot L->base points to) - T: Top of the current guest frame (the slot L->top points to) - M: Last slot of the stack (the slot L->maxstack points to) * : see help lj-tv for more info * : framelink slot differs from the value slot: it contains info related to the function being executed within this guest frame, its type and link to the parent guest frame [] delta=, - : + L: VM performs a call as a result of bytecode execution + C: VM performs a call as a result of lj_vm_call + M: VM performs a call to a metamethod as a result of bytecode execution + V: Variable-length frame for storing arguments of a variadic function + CP: Protected C frame + PP: VM performs a call as a result of executinig pcall or xpcall If L is ommited the main coroutine is used. ### lj-state The command requires no args and dumps current VM and GC states * VM state: * GC state: * JIT state: ### lj-gc The command requires no args and dumps current GC stats: * total: * threshold: * debt: * estimate: * stepmul: * pause: * sweepstr: * root: * gray: * grayagain: * weak: Signed-off-by: Igor Munkin -- Changes in v2: * squashed "fixup" commits with the first one * added loading errors handling v1: https://lists.tarantool.org/pipermail/tarantool-patches/2020-January/013801.html Branch: https://github.com/tarantool/luajit/tree/imun/luajit-gdb Igor Munkin (3): gdb: introduce luajit-gdb extension gdb: adjust the extension to be used with Python 2 gdb: enhance the extension loading src/luajit-gdb.py | 687 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 687 insertions(+) create mode 100644 src/luajit-gdb.py -- 2.24.0