* [Tarantool-patches] [PATCH] gdb: support full-range 64-bit lightuserdata
@ 2022-12-01 21:15 Maxim Kokryashkin via Tarantool-patches
2022-12-02 10:16 ` Igor Munkin via Tarantool-patches
0 siblings, 1 reply; 2+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2022-12-01 21:15 UTC (permalink / raw)
To: tarantool-patches, sergos, imun
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
---
src/luajit-gdb.py | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/luajit-gdb.py b/src/luajit-gdb.py
index 6480d014..e5c94000 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,18 @@ def frames(L):
break
framelink = frame_prev(framelink)
+if LJ_64:
+ def lightudV(tv):
+ 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:
+ def lightudV(tv):
+ return gcval(tv['gcr'])
+
# Dumpers {{{
def dump_lj_tnil(tv):
@@ -327,7 +345,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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Tarantool-patches] [PATCH] gdb: support full-range 64-bit lightuserdata
2022-12-01 21:15 [Tarantool-patches] [PATCH] gdb: support full-range 64-bit lightuserdata Maxim Kokryashkin via Tarantool-patches
@ 2022-12-02 10:16 ` Igor Munkin via Tarantool-patches
0 siblings, 0 replies; 2+ messages in thread
From: Igor Munkin via Tarantool-patches @ 2022-12-02 10:16 UTC (permalink / raw)
To: Maxim Kokryashkin; +Cc: tarantool-patches
Max,
Thanks for the fixes, but the patch doesn't work now. See my comments
below.
On 02.12.22, Maxim Kokryashkin wrote:
> 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
> ---
> src/luajit-gdb.py | 20 +++++++++++++++++++-
> 1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/src/luajit-gdb.py b/src/luajit-gdb.py
> index 6480d014..e5c94000 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,18 @@ def frames(L):
> break
> framelink = frame_prev(framelink)
>
This variable is always false at the moment of declaration, so the hack
doesn't work...
> +if LJ_64:
> + def lightudV(tv):
> + 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:
> + def lightudV(tv):
> + return gcval(tv['gcr'])
> +
In my previous review I meant something similar to the following:
| import random
|
| LJ_64 = None
|
| def lightudV_segmented():
| print(LJ_64, "Segmented lightuserdata is used")
|
| def lightudV_raw():
| print(LJ_64, "Raw lightuserdata is used")
|
| def init():
| global lightudV, LJ_64
| LJ_64 = random.randint(0, 1)
| lightudV = lightudV_segmented if LJ_64 else lightudV_raw
|
| init()
| lightudV()
In other words, you have to choose the implementation of lightudV on
extension initilalization step (when LJ_64 is resolved), not on script
load phase.
> # Dumpers {{{
>
> def dump_lj_tnil(tv):
> @@ -327,7 +345,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
>
--
Best regards,
IM
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-02 10:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-01 21:15 [Tarantool-patches] [PATCH] gdb: support full-range 64-bit lightuserdata Maxim Kokryashkin via Tarantool-patches
2022-12-02 10:16 ` Igor Munkin via Tarantool-patches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox