From: Igor Munkin <imun@tarantool.org>
To: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH v2 luajit 2/3] gdb: adjust the extension to be used with Python 2
Date: Wed, 5 Feb 2020 19:22:28 +0300 [thread overview]
Message-ID: <29107e6f02c622f414fdaa08bb82a89ca0e30396.1580917791.git.imun@tarantool.org> (raw)
In-Reply-To: <cover.1580917791.git.imun@tarantool.org>
This patch covers all problems faced while using the extension via gdb
compiled with Python 2.
Signed-off-by: Igor Munkin <imun@tarantool.org>
---
src/luajit-gdb.py | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/src/luajit-gdb.py b/src/luajit-gdb.py
index 77da5e6..90df101 100644
--- a/src/luajit-gdb.py
+++ b/src/luajit-gdb.py
@@ -1,5 +1,14 @@
import re
import gdb
+import sys
+
+# make script compatible with the ancient Python {{{
+
+if re.match(r'^2\.', sys.version):
+ int = long
+ range = xrange
+
+# }}}
gtype_cache = {}
@@ -47,7 +56,8 @@ def i2notu32(val):
return ~int(val) & 0xFFFFFFFF
def strx64(val):
- return hex(cast('uint64_t', val) & 0xFFFFFFFFFFFFFFFF)
+ return re.sub('L?$', '',
+ hex(int(cast('uint64_t', val) & 0xFFFFFFFFFFFFFFFF)))
# Types {{{
@@ -169,7 +179,9 @@ def gcval(obj):
def L(L=None):
# lookup a symbol for the main coroutine considering the host app
- for l in (L, *map(lambda l: lookup(l), (
+ # XXX Fragile: though the loop initialization looks like a crap but it
+ # respects both Python 2 and Python 3.
+ for l in [ L ] + list(map(lambda l: lookup(l), (
# LuaJIT main coro (see luajit/src/luajit.c)
'globalL',
# Tarantool main coro (see tarantool/src/lua/init.h)
@@ -234,7 +246,10 @@ def tvislightud(o):
def strdata(obj):
# String is printed with pointer to it, thanks to gdb. Just strip it.
- return str(cast('char *', cast('GCstr *', obj) + 1))[len(PADDING):]
+ try:
+ return str(cast('char *', cast('GCstr *', obj) + 1))[len(PADDING):]
+ except UnicodeEncodeError:
+ return "<luajit-gdb: error occured while rendering non-ascii slot>"
def itypemap(o):
if LJ_64 and not LJ_GC64:
--
2.24.0
next prev parent reply other threads:[~2020-02-05 16:24 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-05 16:22 [Tarantool-patches] [PATCH v2 luajit 0/3] Introduce gdb extension for LuaJIT Igor Munkin
2020-02-05 16:22 ` [Tarantool-patches] [PATCH v2 luajit 1/3] gdb: introduce luajit-gdb extension Igor Munkin
2020-02-13 13:24 ` Igor Munkin
2020-02-05 16:22 ` Igor Munkin [this message]
2020-02-05 16:22 ` [Tarantool-patches] [PATCH v2 luajit 3/3] gdb: enhance the extension loading Igor Munkin
2020-02-13 11:48 ` Igor Munkin
2020-02-13 12:24 ` Igor Munkin
2020-02-26 22:41 ` [Tarantool-patches] [PATCH v2 luajit 0/3] Introduce gdb extension for LuaJIT Alexander Turenko
2020-02-28 10:46 ` Igor Munkin
2020-03-02 16:00 ` Igor Munkin
2020-03-03 14:16 ` Sergey Ostanevich
2020-02-26 22:45 ` Alexander Turenko
2020-02-27 10:48 ` Igor Munkin
2020-02-27 11:35 ` Alexander Turenko
2020-03-03 16:17 ` Igor Munkin
2020-03-03 22:39 ` Alexander Turenko
2020-03-17 22:46 ` Igor Munkin
2020-02-26 23:04 ` Alexander Turenko
2020-02-27 10:13 ` Igor Munkin
2020-02-26 23:10 ` Alexander Turenko
2020-02-27 10:37 ` Igor Munkin
2020-03-05 7:44 ` Kirill Yukhin
2020-03-05 9:22 ` Igor Munkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=29107e6f02c622f414fdaa08bb82a89ca0e30396.1580917791.git.imun@tarantool.org \
--to=imun@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH v2 luajit 2/3] gdb: adjust the extension to be used with Python 2' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox