Tarantool development patches archive
 help / color / mirror / Atom feed
From: Maxim Kokryashkin via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: tarantool-patches@dev.tarantool.org, sergos@tarantool.org,
	imun@tarantool.org
Subject: [Tarantool-patches] [PATCH luajit v2] gdb: support full-range 64-bit lightuserdata
Date: Mon,  5 Dec 2022 12:56:52 +0300	[thread overview]
Message-ID: <20221205095652.231379-1-m.kokryashkin@tarantool.org> (raw)

Following up the introduction of full-range 64-bit lightuserdata
support in commit 2cacfa8e7ffefb715abf55dc5b0c708c63251868 ('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
---
Changes in v2:
- Restored the initial lightudV specification mechanism.

Issue: https://github.com/tarantool/tarantool/issues/6481
Branch: https://github.com/tarantool/luajit/tree/fckxorg/gh-6481-luajit-gdb-light-ud

 src/luajit-gdb.py | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/luajit-gdb.py b/src/luajit-gdb.py
index 6480d014..96ee2289 100644
--- a/src/luajit-gdb.py
+++ b/src/luajit-gdb.py
@@ -166,6 +166,12 @@ LJ_GCVMASK = ((1 << 47) - 1)
 LJ_TISNUM = None
 PADDING = 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
+
 # }}}
 
 def itype(o):
@@ -315,6 +321,17 @@ def frames(L):
             break
         framelink = frame_prev(framelink)
 
+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'])
+
 # Dumpers {{{
 
 def dump_lj_tnil(tv):
@@ -327,7 +344,7 @@ def dump_lj_ttrue(tv):
     return 'true'
 
 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):
     return 'string {body} @ {address}'.format(
-- 
2.38.1


             reply	other threads:[~2022-12-05  9:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-05  9:56 Maxim Kokryashkin via Tarantool-patches [this message]
2022-12-12  9:46 ` Igor Munkin 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=20221205095652.231379-1-m.kokryashkin@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=imun@tarantool.org \
    --cc=max.kokryashkin@gmail.com \
    --cc=sergos@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit v2] gdb: 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