[Tarantool-patches] [PATCH luajit] luajit-gdb: support full-range 64-bit lightud
Maxim Kokryashkin
max.kokryashkin at gmail.com
Wed Oct 5 17:43:31 MSK 2022
Following up the introduction of full-range 64-bit lightuserdata
support in commit 2cacfa8 ("Add support for full-range 64 bit
lightuserdata."), this patch modifies the corresponding dumper
behavior for LJ_64 platforms in the luajit-gdb extension.
Resolves tarantool/tarantool#6481
---
Branch: https://github.com/tarantool/luajit/tree/fckxorg/gh-6481-luajit-gdb-light-ud
Issue: https://github.com/tarantool/tarantool/issues/6481
src/luajit-gdb.py | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/luajit-gdb.py b/src/luajit-gdb.py
index 6480d014..2993f2c1 100644
--- a/src/luajit-gdb.py
+++ b/src/luajit-gdb.py
@@ -166,6 +166,9 @@ LJ_GCVMASK = ((1 << 47) - 1)
LJ_TISNUM = None
PADDING = None
+LJ_LIGHTUD_BITS_SEG = 8
+LJ_LIGHTUD_BITS_LO = 47 - LJ_LIGHTUD_BITS_SEG
+
# }}}
def itype(o):
@@ -315,6 +318,12 @@ def frames(L):
break
framelink = frame_prev(framelink)
+def lightudseg(u):
+ return (u >> LJ_LIGHTUD_BITS_LO) & ((1 << LJ_LIGHTUD_BITS_SEG) - 1)
+
+def lightudlo(u):
+ return u & ((1 << LJ_LIGHTUD_BITS_LO) - 1)
+
# Dumpers {{{
def dump_lj_tnil(tv):
@@ -327,7 +336,14 @@ def dump_lj_ttrue(tv):
return 'true'
def dump_lj_tlightud(tv):
- return 'light userdata @ {}'.format(strx64(gcval(tv['gcr'])))
+ if LJ_64:
+ u = int(tv['u64'])
+ seg = lightudseg(u)
+ segmap = mref('uint32_t *', G(L(None))['gc']['lightudseg'])
+ addr = (int(segmap[seg]) << 32) | lightudlo(u)
+ else:
+ addr = gcval(tv['gcr'])
+ return 'light userdata @ {}'.format(strx64(addr))
def dump_lj_tstr(tv):
return 'string {body} @ {address}'.format(
--
2.36.1
More information about the Tarantool-patches
mailing list