From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp62.i.mail.ru (smtp62.i.mail.ru [217.69.128.42]) (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 57E3D46970E for ; Mon, 3 Feb 2020 16:48:02 +0300 (MSK) Date: Mon, 3 Feb 2020 16:48:01 +0300 From: Sergey Ostanevich Message-ID: <20200203134801.GE547@tarantool.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Subject: Re: [Tarantool-patches] [PATCH luajit 0/4] Introduce gdb extension for LuaJIT List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Munkin Cc: tarantool-patches@dev.tarantool.org Hi! Thanks for the patch! 1. It would be nice to include at least short description on how to hook up the script into the gdb. I used "source " - is it intended? 2. If there's no tarantool running - then most of commands fail with error: (gdb) source /workspaces/tarantool.review/third_party/luajit/src/luajit-gdb.py (gdb) lj-arch LJ_64: True, LJ_GC64: False (gdb) lj-gc Traceback (most recent call last): File "/workspaces/tarantool.review/third_party/luajit/src/luajit-gdb.py", line 615, in invoke g = G(L(None)) File "/workspaces/tarantool.review/third_party/luajit/src/luajit-gdb.py", line 188, in L 'tarantool_L', File "/workspaces/tarantool.review/third_party/luajit/src/luajit-gdb.py", line 184, in for l in [ L ] + list(map(lambda l: lookup(l), ( File "/workspaces/tarantool.review/third_party/luajit/src/luajit-gdb.py", line 32, in lookup variable, _ = gdb.lookup_symbol(symbol) gdb.error: No frame selected. Error occurred in Python command: No frame selected. 3. You didn't mention it anywhere but you rely on internal symbols of tarantool, so it will fail when debugging stripped executable or a non-tarantool one: (gdb) source /workspaces/tarantool.review/third_party/luajit/src/luajit-gdb.py Traceback (most recent call last): File "/workspaces/tarantool.review/third_party/luajit/src/luajit-gdb.py", line 154, in LJ_64 = str(gdb.parse_and_eval('IRT_PTR')) == 'IRT_P64' gdb.error: No symbol "IRT_PTR" in current context. I believe those should be augmented with grace failures with some meaningful explanation. Otherwise I have no objections neither in code, nor in split patchset. Regards, Sergos On 27 Jan 23:41, Igor Munkin wrote: > The series provides a gdb extension with commands for inspecting LuaJIT > internals. The following set of commands is implemented now: > > ### 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 > > --- > > Branch: https://github.com/tarantool/luajit/tree/imun/luajit-gdb > > Igor Munkin (4): > gdb: introduce luajit-gdb extension > gdb: make existing commands more verbose > gdb: make several enhancements > gdb: adjust extension to be used with Python 2 > > src/luajit-gdb.py | 699 ++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 699 insertions(+) > create mode 100644 src/luajit-gdb.py > > -- > 2.24.0 >