From: Sergey Kaplun via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Mikhail Elhimov <m.elhimov@vk.team>,
Sergey Bronnikov <sergeyb@tarantool.org>,
Evgeniy Temirgaleev <e.temirgaleev@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH v2 luajit 4/6] lldb: support full-range 64-bit lightuserdata
Date: Tue, 19 May 2026 15:39:11 +0300 [thread overview]
Message-ID: <20260519123913.178775-5-skaplun@tarantool.org> (raw)
In-Reply-To: <20260519123913.178775-1-skaplun@tarantool.org>
This commit adds the missed support for the full-range 64-bit light
userdata, which was lost during lldb extension implementation. The
corresponding entries for the test of lj-tv are sorted according to LJT*
types.
---
src/luajit_lldb.py | 20 +++++++++++++-
.../debug-extension-tests.py | 27 ++++++++++++-------
2 files changed, 36 insertions(+), 11 deletions(-)
diff --git a/src/luajit_lldb.py b/src/luajit_lldb.py
index 7668a94c..e3fe82fc 100644
--- a/src/luajit_lldb.py
+++ b/src/luajit_lldb.py
@@ -18,6 +18,12 @@ IRT_P64 = 9
LJ_GCVMASK = ((1 << 47) - 1)
LJ_TISNUM = None
+# These constants are meaningful only for 'LJ_64' mode.
+LJ_LIGHTUD_BITS_SEG = 8
+LJ_LIGHTUD_BITS_LO = 47 - LJ_LIGHTUD_BITS_SEG
+LIGHTUD_SEG_MASK = (1 << LJ_LIGHTUD_BITS_SEG) - 1
+LIGHTUD_LO_MASK = (1 << LJ_LIGHTUD_BITS_LO) - 1
+
# Debugger specific {{{
@@ -440,6 +446,18 @@ def tvisnumber(o):
return itype(o) <= LJ_TISNUM
+def lightudV(tv):
+ if LJ_64:
+ u = int(tv['u64'])
+ # lightudseg macro expanded.
+ seg = (u >> LJ_LIGHTUD_BITS_LO) & LIGHTUD_SEG_MASK
+ segmap = mref('uint32_t *', G(L(None))['gc']['lightudseg'])
+ # lightudlo macro expanded.
+ return (int(segmap[seg]) << 32) | (u & LIGHTUD_LO_MASK)
+ else:
+ return gcval(tv['gcr'])
+
+
def dump_lj_tnil(tv):
return 'nil'
@@ -453,7 +471,7 @@ def dump_lj_ttrue(tv):
def dump_lj_tlightud(tv):
- return 'light userdata @ {}'.format(strx64(gcval(tv['gcr'])))
+ return 'light userdata @ {}'.format(strx64(lightudV(tv)))
def dump_lj_tstr(tv):
diff --git a/test/tarantool-debugger-tests/debug-extension-tests.py b/test/tarantool-debugger-tests/debug-extension-tests.py
index f3ce3ced..2b67e151 100644
--- a/test/tarantool-debugger-tests/debug-extension-tests.py
+++ b/test/tarantool-debugger-tests/debug-extension-tests.py
@@ -211,23 +211,28 @@ class TestLJTV(TestCaseBase):
'lj-tv L->base + 9\n'
'lj-tv L->base + 10\n'
'lj-tv L->base + 11\n'
+ 'lj-tv L->base + 12\n'
+ 'lj-tv L->base + 13\n'
)
+ # Sorted in LJT order.
lua_script = (
'local ffi = require("ffi")\n'
'print(\n'
' nil,\n'
' false,\n'
' true,\n'
+ ' debug.upvalueid(print, 1), \n' # lightuserdata
' "hello",\n'
- ' {1},\n'
- ' 1,\n'
- ' 1.1,\n'
' coroutine.create(function() end),\n'
- ' ffi.new("int*"),\n'
' function() end,\n'
+ ' require,\n'
' print,\n'
- ' require\n'
+ ' ffi.new("int*"),\n'
+ ' {1},\n'
+ ' newproxy(),\n'
+ ' 1,\n'
+ ' 1.1\n'
')\n'
)
@@ -235,15 +240,17 @@ class TestLJTV(TestCaseBase):
r'nil\n'
r'false\n'
r'true\n'
+ r'light userdata @ ' + RX_ADDR + r'\n'
r'string \"hello\" @ ' + RX_ADDR + r'\n'
- r'table @ ' + RX_ADDR + r' \(asize: \d+, hmask: ' + RX_HASH + r'\)\n'
- r'(number|integer) .*1.*\n'
- r'number 1.1\d+\n'
r'thread @ ' + RX_ADDR + r'\n'
- r'cdata @ ' + RX_ADDR + r'\n'
r'Lua function @ ' + RX_ADDR + r', [0-9]+ upvalues, .+:[0-9]+\n'
- r'fast function #[0-9]+\n'
r'C function @ ' + RX_ADDR + r'\n'
+ r'fast function #[0-9]+\n'
+ r'cdata @ ' + RX_ADDR + r'\n'
+ r'table @ ' + RX_ADDR + r' \(asize: \d+, hmask: ' + RX_HASH + r'\)\n'
+ r'userdata @ ' + RX_ADDR + r'\n'
+ r'(number|integer) .*1.*\n'
+ r'number 1.1\d+\n'
)
--
2.53.0
next prev parent reply other threads:[~2026-05-19 12:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 12:39 [Tarantool-patches] [PATCH v2 luajit 0/6] Unified extension for debuggers Sergey Kaplun via Tarantool-patches
2026-05-19 12:39 ` [Tarantool-patches] [PATCH v2 luajit 1/6] test: introduce tests for debugging extensions Sergey Kaplun via Tarantool-patches
2026-05-19 12:39 ` [Tarantool-patches] [PATCH v2 luajit 2/6] lldb: refactor extension Sergey Kaplun via Tarantool-patches
2026-05-19 12:39 ` [Tarantool-patches] [PATCH v2 luajit 3/6] dbg: sort initialization of commands Sergey Kaplun via Tarantool-patches
2026-05-19 12:39 ` Sergey Kaplun via Tarantool-patches [this message]
2026-05-19 12:39 ` [Tarantool-patches] [PATCH v2 luajit 5/6] dbg: generalize extension Sergey Kaplun via Tarantool-patches
2026-05-19 12:39 ` [Tarantool-patches] [PATCH v2 luajit 6/6] ci: introduce workflow to test debugger extension Sergey Kaplun via Tarantool-patches
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=20260519123913.178775-5-skaplun@tarantool.org \
--to=tarantool-patches@dev.tarantool.org \
--cc=e.temirgaleev@tarantool.org \
--cc=m.elhimov@vk.team \
--cc=sergeyb@tarantool.org \
--cc=skaplun@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH v2 luajit 4/6] lldb: support full-range 64-bit lightuserdata' \
/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