* [Tarantool-patches] [PATCH luajit] dbg: display fast function name along with ffid
@ 2026-09-09 13:07 Mikhail Elhimov via Tarantool-patches
2026-09-22 9:16 ` Sergey Kaplun via Tarantool-patches
0 siblings, 1 reply; 10+ messages in thread
From: Mikhail Elhimov via Tarantool-patches @ 2026-09-09 13:07 UTC (permalink / raw)
To: Sergey Kaplun, Sergey Bronnikov, Evgeniy Temirgaleev; +Cc: tarantool-patches
Part of tarantool/tarantool#4808
---
This patch is to be applied after the 'avoid hardcoded enums' patch.
Branch: https://github.com/tarantool/luajit/tree/elhimov/gh-4808-display-fast-function-name
Related issue: https://github.com/tarantool/tarantool/issues/4808
src/luajit_dbg.py | 17 +++++++++++------
.../debug-extension-tests.py | 2 +-
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/luajit_dbg.py b/src/luajit_dbg.py
index 1ac1d275..262fdad1 100644
--- a/src/luajit_dbg.py
+++ b/src/luajit_dbg.py
@@ -1682,8 +1682,11 @@ def ir_kint64(ir):
# Dumpers.
+FF_NAMES = EnumBasedList('FastFunc', 'FF__MAX', cut_prefix, 'FF_')
+
# GCobj dumpers.
+
def dump_lj_gco_str(gcobj):
return 'string {body} @ {address}'.format(
body=strdata(gcobj),
@@ -1705,7 +1708,7 @@ def dump_lj_gco_proto(gcobj):
def dump_lj_gco_func(gcobj):
func = dbg.cast('struct GCfuncC *', gcobj)
- ffid = func['ffid']
+ ffid = int(func['ffid'])
if ffid == 0:
pt = funcproto(func)
@@ -1718,7 +1721,8 @@ def dump_lj_gco_func(gcobj):
elif ffid == 1:
return 'C function @ {}'.format(strx64(func['f']))
else:
- return 'fast function #{}'.format(int(ffid))
+ ffname = FF_NAMES[ffid] if ffid < len(FF_NAMES) else "unknown"
+ return 'fast function #{}({})'.format(ffid, ffname)
def dump_lj_gco_trace(gcobj):
@@ -2068,7 +2072,7 @@ def dump_proto(proto):
def dump_func(func):
- ffid = func['ffid']
+ ffid = int(func['ffid'])
if ffid == 0:
pt = funcproto(func)
@@ -2076,7 +2080,8 @@ def dump_func(func):
elif ffid == 1:
return 'C function @ {}\n'.format(strx64(func['f']))
else:
- return 'fast function #{}\n'.format(int(ffid))
+ ffname = FF_NAMES[ffid] if ffid < len(FF_NAMES) else "unknown"
+ return 'fast function #{}({})\n'.format(ffid, ffname)
# FFI dumpers.
@@ -2702,7 +2707,7 @@ the type and some info related to it.
* LJ_TFUNC: <LFUNC|CFUNC|FFUNC>
<LFUNC>: Lua function @ <gcr>, <nupvals> upvalues, <chunk:line>
<CFUNC>: C function <mcode address>
- <FFUNC>: fast function #<ffid>
+ <FFUNC>: fast function #<ffid>(<ffname>)
* LJ_TTRACE: trace <traceno> @ <gcr>
* LJ_TCDATA: cdata @ <gcr>
* LJ_TTAB: table @ <gcr> (asize: <asize>, hmask: <hmask>)
@@ -2921,7 +2926,7 @@ the type and some info related to it.
* LJ_TFUNC: <LFUNC|CFUNC|FFUNC>
<LFUNC>: Lua function @ <gcr>, <nupvals> upvalues, <chunk:line>
<CFUNC>: C function <mcode address>
- <FFUNC>: fast function #<ffid>
+ <FFUNC>: fast function #<ffid>(<ffname>)
* LJ_TTRACE: trace <traceno> @ <gcr>
* LJ_TCDATA: cdata @ <gcr>
* LJ_TTAB: table @ <gcr> (asize: <asize>, hmask: <hmask>)
diff --git a/test/tarantool-debugger-tests/debug-extension-tests.py b/test/tarantool-debugger-tests/debug-extension-tests.py
index 9989032b..40a27c3a 100644
--- a/test/tarantool-debugger-tests/debug-extension-tests.py
+++ b/test/tarantool-debugger-tests/debug-extension-tests.py
@@ -338,7 +338,7 @@ GCO_RX = (
r'thread @ ' + RX_ADDR + r'\n'
r'Lua function @ ' + RX_ADDR + r', [0-9]+ upvalues, .+:[0-9]+\n'
r'C function @ ' + RX_ADDR + r'\n'
- r'fast function #[0-9]+\n'
+ r'fast function #[0-9]+\(\w+\)\n'
r'cdata @ ' + RX_ADDR + r' \[\d+\] <int \*> 0x0\n'
r'table @ ' + RX_ADDR + r' \(asize: \d+, hmask: ' + RX_HASH + r'\)\n'
r'userdata @ ' + RX_ADDR + r'\n'
--
2.43.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Tarantool-patches] [PATCH luajit] dbg: display fast function name along with ffid
2026-09-09 13:07 [Tarantool-patches] [PATCH luajit] dbg: display fast function name along with ffid Mikhail Elhimov via Tarantool-patches
@ 2026-09-22 9:16 ` Sergey Kaplun via Tarantool-patches
2026-09-23 22:55 ` Mikhail Elhimov via Tarantool-patches
2026-09-24 16:48 ` [Tarantool-patches] [PATCH luajit v2] " Mikhail Elhimov via Tarantool-patches
0 siblings, 2 replies; 10+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2026-09-22 9:16 UTC (permalink / raw)
To: Mikhail Elhimov; +Cc: tarantool-patches
Hi, Mikhail!
Thanks for the patch!
Generally, LGTM, with minor suggestions below.
On 09.09.26, Mikhail Elhimov wrote:
> Part of tarantool/tarantool#4808
> ---
> This patch is to be applied after the 'avoid hardcoded enums' patch.
>
> Branch: https://github.com/tarantool/luajit/tree/elhimov/gh-4808-display-fast-function-name
> Related issue: https://github.com/tarantool/tarantool/issues/4808
>
> src/luajit_dbg.py | 17 +++++++++++------
> .../debug-extension-tests.py | 2 +-
> 2 files changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/src/luajit_dbg.py b/src/luajit_dbg.py
> index 1ac1d275..262fdad1 100644
> --- a/src/luajit_dbg.py
> +++ b/src/luajit_dbg.py
> @@ -1682,8 +1682,11 @@ def ir_kint64(ir):
>
> # Dumpers.
>
> +FF_NAMES = EnumBasedList('FastFunc', 'FF__MAX', cut_prefix, 'FF_')
It would be nice to replace `_` in functions names to `.`.
Resulting: math_min -> math.min
Minor: I would rather placed it somewhere into the section:
| # LuaJIT macro implementations and structure access.
> +
> # GCobj dumpers.
>
> +
> def dump_lj_gco_str(gcobj):
> return 'string {body} @ {address}'.format(
> body=strdata(gcobj),
> @@ -1705,7 +1708,7 @@ def dump_lj_gco_proto(gcobj):
>
> def dump_lj_gco_func(gcobj):
> func = dbg.cast('struct GCfuncC *', gcobj)
> - ffid = func['ffid']
> + ffid = int(func['ffid'])
>
> if ffid == 0:
> pt = funcproto(func)
> @@ -1718,7 +1721,8 @@ def dump_lj_gco_func(gcobj):
> elif ffid == 1:
> return 'C function @ {}'.format(strx64(func['f']))
> else:
> - return 'fast function #{}'.format(int(ffid))
> + ffname = FF_NAMES[ffid] if ffid < len(FF_NAMES) else "unknown"
> + return 'fast function #{}({})'.format(ffid, ffname)
I suggest the following format insted:
| 'fast function {} (#{})'.format(ffname, ffid)
Generally we needed ffid less then the function name.
>
>
> def dump_lj_gco_trace(gcobj):
> @@ -2068,7 +2072,7 @@ def dump_proto(proto):
>
>
> def dump_func(func):
> - ffid = func['ffid']
> + ffid = int(func['ffid'])
>
> if ffid == 0:
> pt = funcproto(func)
> @@ -2076,7 +2080,8 @@ def dump_func(func):
> elif ffid == 1:
> return 'C function @ {}\n'.format(strx64(func['f']))
> else:
> - return 'fast function #{}\n'.format(int(ffid))
> + ffname = FF_NAMES[ffid] if ffid < len(FF_NAMES) else "unknown"
> + return 'fast function #{}({})\n'.format(ffid, ffname)
I suggest the following format insted:
| 'fast function {} (#{})\n'.format(ffname, ffid)
Generally we needed ffid less then the function name.
>
>
> # FFI dumpers.
> @@ -2702,7 +2707,7 @@ the type and some info related to it.
> * LJ_TFUNC: <LFUNC|CFUNC|FFUNC>
> <LFUNC>: Lua function @ <gcr>, <nupvals> upvalues, <chunk:line>
> <CFUNC>: C function <mcode address>
> - <FFUNC>: fast function #<ffid>
> + <FFUNC>: fast function #<ffid>(<ffname>)
I suggest the following format instead:
| <FFUNC>: fast function <ffname> (#<ffid>)
> * LJ_TTRACE: trace <traceno> @ <gcr>
> * LJ_TCDATA: cdata @ <gcr>
> * LJ_TTAB: table @ <gcr> (asize: <asize>, hmask: <hmask>)
> @@ -2921,7 +2926,7 @@ the type and some info related to it.
> * LJ_TFUNC: <LFUNC|CFUNC|FFUNC>
> <LFUNC>: Lua function @ <gcr>, <nupvals> upvalues, <chunk:line>
> <CFUNC>: C function <mcode address>
> - <FFUNC>: fast function #<ffid>
I suggest the following format instead:
| <FFUNC>: fast function <ffname> (#<ffid>)
> + <FFUNC>: fast function #<ffid>(<ffname>)
> * LJ_TTRACE: trace <traceno> @ <gcr>
> * LJ_TCDATA: cdata @ <gcr>
> * LJ_TTAB: table @ <gcr> (asize: <asize>, hmask: <hmask>)
> diff --git a/test/tarantool-debugger-tests/debug-extension-tests.py b/test/tarantool-debugger-tests/debug-extension-tests.py
> index 9989032b..40a27c3a 100644
> --- a/test/tarantool-debugger-tests/debug-extension-tests.py
> +++ b/test/tarantool-debugger-tests/debug-extension-tests.py
> @@ -338,7 +338,7 @@ GCO_RX = (
> r'thread @ ' + RX_ADDR + r'\n'
> r'Lua function @ ' + RX_ADDR + r', [0-9]+ upvalues, .+:[0-9]+\n'
> r'C function @ ' + RX_ADDR + r'\n'
> - r'fast function #[0-9]+\n'
> + r'fast function #[0-9]+\(\w+\)\n'
Lets check the specific name here. I suggest `math.min` to check the
_ -> . mapping.
> r'cdata @ ' + RX_ADDR + r' \[\d+\] <int \*> 0x0\n'
> r'table @ ' + RX_ADDR + r' \(asize: \d+, hmask: ' + RX_HASH + r'\)\n'
> r'userdata @ ' + RX_ADDR + r'\n'
> --
> 2.43.0
>
--
Best regards,
Sergey Kaplun
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Tarantool-patches] [PATCH luajit] dbg: display fast function name along with ffid
2026-09-22 9:16 ` Sergey Kaplun via Tarantool-patches
@ 2026-09-23 22:55 ` Mikhail Elhimov via Tarantool-patches
2026-09-24 16:48 ` [Tarantool-patches] [PATCH luajit v2] " Mikhail Elhimov via Tarantool-patches
1 sibling, 0 replies; 10+ messages in thread
From: Mikhail Elhimov via Tarantool-patches @ 2026-09-23 22:55 UTC (permalink / raw)
To: Sergey Kaplun; +Cc: tarantool-patches
Hi, Sergey!
Thanks for the review! See my comments below
On 22.09.2026 12:16, Sergey Kaplun wrote:
> Hi, Mikhail!
> Thanks for the patch!
> Generally, LGTM, with minor suggestions below.
>
> On 09.09.26, Mikhail Elhimov wrote:
>> Part of tarantool/tarantool#4808
>> ---
>> This patch is to be applied after the 'avoid hardcoded enums' patch.
>>
>> Branch: https://github.com/tarantool/luajit/tree/elhimov/gh-4808-display-fast-function-name
>> Related issue: https://github.com/tarantool/tarantool/issues/4808
>>
>> src/luajit_dbg.py | 17 +++++++++++------
>> .../debug-extension-tests.py | 2 +-
>> 2 files changed, 12 insertions(+), 7 deletions(-)
>>
>> diff --git a/src/luajit_dbg.py b/src/luajit_dbg.py
>> index 1ac1d275..262fdad1 100644
>> --- a/src/luajit_dbg.py
>> +++ b/src/luajit_dbg.py
>> @@ -1682,8 +1682,11 @@ def ir_kint64(ir):
>>
>> # Dumpers.
>>
>> +FF_NAMES = EnumBasedList('FastFunc', 'FF__MAX', cut_prefix, 'FF_')
> It would be nice to replace `_` in functions names to `.`.
> Resulting: math_min -> math.min
Then what about these and similar ones (they have 3 underscores in a row):
ffi_meta___index
io_method___gc
?
May be replace only first underscore?
> Minor: I would rather placed it somewhere into the section:
> | # LuaJIT macro implementations and structure access.
Done
>> +
>> # GCobj dumpers.
>>
>> +
>> def dump_lj_gco_str(gcobj):
>> return 'string {body} @ {address}'.format(
>> body=strdata(gcobj),
>> @@ -1705,7 +1708,7 @@ def dump_lj_gco_proto(gcobj):
>>
>> def dump_lj_gco_func(gcobj):
>> func = dbg.cast('struct GCfuncC *', gcobj)
>> - ffid = func['ffid']
>> + ffid = int(func['ffid'])
>>
>> if ffid == 0:
>> pt = funcproto(func)
>> @@ -1718,7 +1721,8 @@ def dump_lj_gco_func(gcobj):
>> elif ffid == 1:
>> return 'C function @ {}'.format(strx64(func['f']))
>> else:
>> - return 'fast function #{}'.format(int(ffid))
>> + ffname = FF_NAMES[ffid] if ffid < len(FF_NAMES) else "unknown"
>> + return 'fast function #{}({})'.format(ffid, ffname)
> I suggest the following format insted:
> | 'fast function {} (#{})'.format(ffname, ffid)
>
> Generally we needed ffid less then the function name.
Done
>>
>>
>> def dump_lj_gco_trace(gcobj):
>> @@ -2068,7 +2072,7 @@ def dump_proto(proto):
>>
>>
>> def dump_func(func):
>> - ffid = func['ffid']
>> + ffid = int(func['ffid'])
>>
>> if ffid == 0:
>> pt = funcproto(func)
>> @@ -2076,7 +2080,8 @@ def dump_func(func):
>> elif ffid == 1:
>> return 'C function @ {}\n'.format(strx64(func['f']))
>> else:
>> - return 'fast function #{}\n'.format(int(ffid))
>> + ffname = FF_NAMES[ffid] if ffid < len(FF_NAMES) else "unknown"
>> + return 'fast function #{}({})\n'.format(ffid, ffname)
> I suggest the following format insted:
> | 'fast function {} (#{})\n'.format(ffname, ffid)
>
> Generally we needed ffid less then the function name.
Done
>>
>>
>> # FFI dumpers.
>> @@ -2702,7 +2707,7 @@ the type and some info related to it.
>> * LJ_TFUNC: <LFUNC|CFUNC|FFUNC>
>> <LFUNC>: Lua function @ <gcr>, <nupvals> upvalues, <chunk:line>
>> <CFUNC>: C function <mcode address>
>> - <FFUNC>: fast function #<ffid>
>> + <FFUNC>: fast function #<ffid>(<ffname>)
> I suggest the following format instead:
>
> | <FFUNC>: fast function <ffname> (#<ffid>)
Done
>> * LJ_TTRACE: trace <traceno> @ <gcr>
>> * LJ_TCDATA: cdata @ <gcr>
>> * LJ_TTAB: table @ <gcr> (asize: <asize>, hmask: <hmask>)
>> @@ -2921,7 +2926,7 @@ the type and some info related to it.
>> * LJ_TFUNC: <LFUNC|CFUNC|FFUNC>
>> <LFUNC>: Lua function @ <gcr>, <nupvals> upvalues, <chunk:line>
>> <CFUNC>: C function <mcode address>
>> - <FFUNC>: fast function #<ffid>
> I suggest the following format instead:
>
> | <FFUNC>: fast function <ffname> (#<ffid>)
Done
>> + <FFUNC>: fast function #<ffid>(<ffname>)
>> * LJ_TTRACE: trace <traceno> @ <gcr>
>> * LJ_TCDATA: cdata @ <gcr>
>> * LJ_TTAB: table @ <gcr> (asize: <asize>, hmask: <hmask>)
>> diff --git a/test/tarantool-debugger-tests/debug-extension-tests.py b/test/tarantool-debugger-tests/debug-extension-tests.py
>> index 9989032b..40a27c3a 100644
>> --- a/test/tarantool-debugger-tests/debug-extension-tests.py
>> +++ b/test/tarantool-debugger-tests/debug-extension-tests.py
>> @@ -338,7 +338,7 @@ GCO_RX = (
>> r'thread @ ' + RX_ADDR + r'\n'
>> r'Lua function @ ' + RX_ADDR + r', [0-9]+ upvalues, .+:[0-9]+\n'
>> r'C function @ ' + RX_ADDR + r'\n'
>> - r'fast function #[0-9]+\n'
>> + r'fast function #[0-9]+\(\w+\)\n'
> Lets check the specific name here. I suggest `math.min` to check the
> _ -> . mapping.
No problem, but first we need to agree on how to handle underscores (see
above comment about multiple undescores)
>
>> ing r'cdata @ ' + RX_ADDR + r' \[\d+\] <int \*> 0x0\n'
>> r'table @ ' + RX_ADDR + r' \(asize: \d+, hmask: ' + RX_HASH + r'\)\n'
>> r'userdata @ ' + RX_ADDR + r'\n'
>> --
>> 2.43.0
>>
--
Best regards,
Mikhail Elhimov
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Tarantool-patches] [PATCH luajit v2] dbg: display fast function name along with ffid
2026-09-22 9:16 ` Sergey Kaplun via Tarantool-patches
2026-09-23 22:55 ` Mikhail Elhimov via Tarantool-patches
@ 2026-09-24 16:48 ` Mikhail Elhimov via Tarantool-patches
2026-09-24 20:14 ` [Tarantool-patches] [PATCH luajit v3] " Mikhail Elhimov via Tarantool-patches
1 sibling, 1 reply; 10+ messages in thread
From: Mikhail Elhimov via Tarantool-patches @ 2026-09-24 16:48 UTC (permalink / raw)
To: Sergey Kaplun, Sergey Bronnikov, Evgeniy Temirgaleev; +Cc: tarantool-patches
Part of tarantool/tarantool#4808
---
Changes in v2:
- Format is changed to 'ffname (#ffid)'
- Replaced single '_' with '.' in ffname
- Adjusted tests to check mapping
This patch is to be applied after https://lists.tarantool.org/pipermail/tarantool-patches/2026-September/030791.html.
Branch: https://github.com/tarantool/luajit/tree/elhimov/gh-4808-display-fast-function-name
Related issue: https://github.com/tarantool/tarantool/issues/4808
src/luajit_dbg.py | 19 +++++++++++++------
.../debug-extension-tests.py | 6 ++++--
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/src/luajit_dbg.py b/src/luajit_dbg.py
index 5cd23a88..a564801b 100644
--- a/src/luajit_dbg.py
+++ b/src/luajit_dbg.py
@@ -1121,6 +1121,11 @@ def frames(L):
# LuaJIT macro implementations and structure access.
+# Get FastFunc enum members and replace any single '_' with '.'.
+FF_NAMES = EnumBasedList('FastFunc', 'FF__MAX', lambda x:
+ re.sub('(?<!_)_(?!_)', '.', cut_prefix(x, 'FF_')))
+
+
def mref(typename, obj):
return dbg.cast(typename, obj['ptr64'] if LJ_GC64 else obj['ptr32'])
@@ -1716,7 +1721,7 @@ def dump_lj_gco_proto(gcobj):
def dump_lj_gco_func(gcobj):
func = dbg.cast('struct GCfuncC *', gcobj)
- ffid = func['ffid']
+ ffid = int(func['ffid'])
if ffid == 0:
pt = funcproto(func)
@@ -1729,7 +1734,8 @@ def dump_lj_gco_func(gcobj):
elif ffid == 1:
return 'C function @ {}'.format(strx64(func['f']))
else:
- return 'fast function #{}'.format(int(ffid))
+ ffname = FF_NAMES[ffid] if ffid < len(FF_NAMES) else "unknown"
+ return 'fast function {} (#{})'.format(ffname, ffid)
def dump_lj_gco_trace(gcobj):
@@ -2079,7 +2085,7 @@ def dump_proto(proto):
def dump_func(func):
- ffid = func['ffid']
+ ffid = int(func['ffid'])
if ffid == 0:
pt = funcproto(func)
@@ -2087,7 +2093,8 @@ def dump_func(func):
elif ffid == 1:
return 'C function @ {}\n'.format(strx64(func['f']))
else:
- return 'fast function #{}\n'.format(int(ffid))
+ ffname = FF_NAMES[ffid] if ffid < len(FF_NAMES) else "unknown"
+ return 'fast function {} (#{})\n'.format(ffname, ffid)
# FFI dumpers.
@@ -2713,7 +2720,7 @@ the type and some info related to it.
* LJ_TFUNC: <LFUNC|CFUNC|FFUNC>
<LFUNC>: Lua function @ <gcr>, <nupvals> upvalues, <chunk:line>
<CFUNC>: C function <mcode address>
- <FFUNC>: fast function #<ffid>
+ <FFUNC>: fast function <ffname> (#<ffid>)
* LJ_TTRACE: trace <traceno> @ <gcr>
* LJ_TCDATA: cdata @ <gcr>
* LJ_TTAB: table @ <gcr> (asize: <asize>, hmask: <hmask>)
@@ -2932,7 +2939,7 @@ the type and some info related to it.
* LJ_TFUNC: <LFUNC|CFUNC|FFUNC>
<LFUNC>: Lua function @ <gcr>, <nupvals> upvalues, <chunk:line>
<CFUNC>: C function <mcode address>
- <FFUNC>: fast function #<ffid>
+ <FFUNC>: fast function <ffname> (#<ffid>)
* LJ_TTRACE: trace <traceno> @ <gcr>
* LJ_TCDATA: cdata @ <gcr>
* LJ_TTAB: table @ <gcr> (asize: <asize>, hmask: <hmask>)
diff --git a/test/tarantool-debugger-tests/debug-extension-tests.py b/test/tarantool-debugger-tests/debug-extension-tests.py
index 5e369f00..86954909 100644
--- a/test/tarantool-debugger-tests/debug-extension-tests.py
+++ b/test/tarantool-debugger-tests/debug-extension-tests.py
@@ -326,7 +326,7 @@ GCO_ARGS = (
'coroutine.create(function() end),\n'
'function() end,\n'
'require,\n'
- 'print,\n'
+ 'math.min,\n'
'ffi.new("int*"),\n'
'{1},\n'
'newproxy(),\n'
@@ -338,7 +338,7 @@ GCO_RX = (
r'thread @ ' + RX_ADDR + r'\n'
r'Lua function @ ' + RX_ADDR + r', [0-9]+ upvalues, .+:[0-9]+\n'
r'C function @ ' + RX_ADDR + r'\n'
- r'fast function #[0-9]+\n'
+ r'fast function math.min (#[0-9]+)\n'
r'cdata @ ' + RX_ADDR + r' \[\d+\] <int \*> 0x0\n'
r'table @ ' + RX_ADDR + r' \(asize: \d+, hmask: ' + RX_HASH + r'\)\n'
r'userdata @ ' + RX_ADDR + r'\n'
@@ -367,6 +367,7 @@ class TestLJTV(TestCaseBase):
# Sorted in LJT order.
lua_script = (
'local ffi = require("ffi")\n'
+ 'local math = require("math")\n'
'print(\n'
' nil,\n'
' false,\n'
@@ -435,6 +436,7 @@ class TestLJGCo(TestCaseBase):
lua_script = (
'local ffi = require("ffi")\n'
+ 'local math = require("math")\n'
'print(\n' +
GCO_ARGS +
' 1\n' # Stub for the pattern.
--
2.43.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Tarantool-patches] [PATCH luajit v3] dbg: display fast function name along with ffid
2026-09-24 16:48 ` [Tarantool-patches] [PATCH luajit v2] " Mikhail Elhimov via Tarantool-patches
@ 2026-09-24 20:14 ` Mikhail Elhimov via Tarantool-patches
2026-09-28 13:02 ` Sergey Bronnikov via Tarantool-patches
0 siblings, 1 reply; 10+ messages in thread
From: Mikhail Elhimov via Tarantool-patches @ 2026-09-24 20:14 UTC (permalink / raw)
To: Sergey Kaplun, Sergey Bronnikov, Evgeniy Temirgaleev; +Cc: tarantool-patches
Part of tarantool/tarantool#4808
---
Changes in v3:
- Fixed fast function regexp in tests
Changes in v2:
- Format is changed to 'ffname (#ffid)'
- Replaced single '_' with '.' in ffname
- Adjusted tests to check mapping
This patch is to be applied after https://lists.tarantool.org/pipermail/tarantool-patches/2026-September/030791.html.
Branch: https://github.com/tarantool/luajit/tree/elhimov/gh-4808-display-fast-function-name
Related issue: https://github.com/tarantool/tarantool/issues/4808
src/luajit_dbg.py | 19 +++++++++++++------
.../debug-extension-tests.py | 6 ++++--
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/src/luajit_dbg.py b/src/luajit_dbg.py
index 5cd23a88..a564801b 100644
--- a/src/luajit_dbg.py
+++ b/src/luajit_dbg.py
@@ -1121,6 +1121,11 @@ def frames(L):
# LuaJIT macro implementations and structure access.
+# Get FastFunc enum members and replace any single '_' with '.'.
+FF_NAMES = EnumBasedList('FastFunc', 'FF__MAX', lambda x:
+ re.sub('(?<!_)_(?!_)', '.', cut_prefix(x, 'FF_')))
+
+
def mref(typename, obj):
return dbg.cast(typename, obj['ptr64'] if LJ_GC64 else obj['ptr32'])
@@ -1716,7 +1721,7 @@ def dump_lj_gco_proto(gcobj):
def dump_lj_gco_func(gcobj):
func = dbg.cast('struct GCfuncC *', gcobj)
- ffid = func['ffid']
+ ffid = int(func['ffid'])
if ffid == 0:
pt = funcproto(func)
@@ -1729,7 +1734,8 @@ def dump_lj_gco_func(gcobj):
elif ffid == 1:
return 'C function @ {}'.format(strx64(func['f']))
else:
- return 'fast function #{}'.format(int(ffid))
+ ffname = FF_NAMES[ffid] if ffid < len(FF_NAMES) else "unknown"
+ return 'fast function {} (#{})'.format(ffname, ffid)
def dump_lj_gco_trace(gcobj):
@@ -2079,7 +2085,7 @@ def dump_proto(proto):
def dump_func(func):
- ffid = func['ffid']
+ ffid = int(func['ffid'])
if ffid == 0:
pt = funcproto(func)
@@ -2087,7 +2093,8 @@ def dump_func(func):
elif ffid == 1:
return 'C function @ {}\n'.format(strx64(func['f']))
else:
- return 'fast function #{}\n'.format(int(ffid))
+ ffname = FF_NAMES[ffid] if ffid < len(FF_NAMES) else "unknown"
+ return 'fast function {} (#{})\n'.format(ffname, ffid)
# FFI dumpers.
@@ -2713,7 +2720,7 @@ the type and some info related to it.
* LJ_TFUNC: <LFUNC|CFUNC|FFUNC>
<LFUNC>: Lua function @ <gcr>, <nupvals> upvalues, <chunk:line>
<CFUNC>: C function <mcode address>
- <FFUNC>: fast function #<ffid>
+ <FFUNC>: fast function <ffname> (#<ffid>)
* LJ_TTRACE: trace <traceno> @ <gcr>
* LJ_TCDATA: cdata @ <gcr>
* LJ_TTAB: table @ <gcr> (asize: <asize>, hmask: <hmask>)
@@ -2932,7 +2939,7 @@ the type and some info related to it.
* LJ_TFUNC: <LFUNC|CFUNC|FFUNC>
<LFUNC>: Lua function @ <gcr>, <nupvals> upvalues, <chunk:line>
<CFUNC>: C function <mcode address>
- <FFUNC>: fast function #<ffid>
+ <FFUNC>: fast function <ffname> (#<ffid>)
* LJ_TTRACE: trace <traceno> @ <gcr>
* LJ_TCDATA: cdata @ <gcr>
* LJ_TTAB: table @ <gcr> (asize: <asize>, hmask: <hmask>)
diff --git a/test/tarantool-debugger-tests/debug-extension-tests.py b/test/tarantool-debugger-tests/debug-extension-tests.py
index 5e369f00..fe5e34f5 100644
--- a/test/tarantool-debugger-tests/debug-extension-tests.py
+++ b/test/tarantool-debugger-tests/debug-extension-tests.py
@@ -326,7 +326,7 @@ GCO_ARGS = (
'coroutine.create(function() end),\n'
'function() end,\n'
'require,\n'
- 'print,\n'
+ 'math.min,\n'
'ffi.new("int*"),\n'
'{1},\n'
'newproxy(),\n'
@@ -338,7 +338,7 @@ GCO_RX = (
r'thread @ ' + RX_ADDR + r'\n'
r'Lua function @ ' + RX_ADDR + r', [0-9]+ upvalues, .+:[0-9]+\n'
r'C function @ ' + RX_ADDR + r'\n'
- r'fast function #[0-9]+\n'
+ r'fast function math.min \(#[0-9]+\)\n'
r'cdata @ ' + RX_ADDR + r' \[\d+\] <int \*> 0x0\n'
r'table @ ' + RX_ADDR + r' \(asize: \d+, hmask: ' + RX_HASH + r'\)\n'
r'userdata @ ' + RX_ADDR + r'\n'
@@ -367,6 +367,7 @@ class TestLJTV(TestCaseBase):
# Sorted in LJT order.
lua_script = (
'local ffi = require("ffi")\n'
+ 'local math = require("math")\n'
'print(\n'
' nil,\n'
' false,\n'
@@ -435,6 +436,7 @@ class TestLJGCo(TestCaseBase):
lua_script = (
'local ffi = require("ffi")\n'
+ 'local math = require("math")\n'
'print(\n' +
GCO_ARGS +
' 1\n' # Stub for the pattern.
--
2.43.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Tarantool-patches] [PATCH luajit v3] dbg: display fast function name along with ffid
2026-09-24 20:14 ` [Tarantool-patches] [PATCH luajit v3] " Mikhail Elhimov via Tarantool-patches
@ 2026-09-28 13:02 ` Sergey Bronnikov via Tarantool-patches
2026-10-07 16:27 ` Mikhail Elhimov via Tarantool-patches
2026-10-07 16:33 ` [Tarantool-patches] [PATCH luajit v4] " Mikhail Elhimov via Tarantool-patches
0 siblings, 2 replies; 10+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2026-09-28 13:02 UTC (permalink / raw)
To: Mikhail Elhimov, Sergey Kaplun, Evgeniy Temirgaleev; +Cc: tarantool-patches
Hi, Mikhail,
thanks for the patch! LGTM with minor comments below.
Sergey
On 9/24/26 23:14, Mikhail Elhimov wrote:
> Part of tarantool/tarantool#4808
> ---
> Changes in v3:
> - Fixed fast function regexp in tests
>
> Changes in v2:
> - Format is changed to 'ffname (#ffid)'
> - Replaced single '_' with '.' in ffname
> - Adjusted tests to check mapping
>
> This patch is to be applied after https://lists.tarantool.org/pipermail/tarantool-patches/2026-September/030791.html.
>
> Branch: https://github.com/tarantool/luajit/tree/elhimov/gh-4808-display-fast-function-name
> Related issue: https://github.com/tarantool/tarantool/issues/4808
>
> src/luajit_dbg.py | 19 +++++++++++++------
> .../debug-extension-tests.py | 6 ++++--
> 2 files changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/src/luajit_dbg.py b/src/luajit_dbg.py
> index 5cd23a88..a564801b 100644
> --- a/src/luajit_dbg.py
> +++ b/src/luajit_dbg.py
> @@ -1121,6 +1121,11 @@ def frames(L):
> # LuaJIT macro implementations and structure access.
>
>
> +# Get FastFunc enum members and replace any single '_' with '.'.
> +FF_NAMES = EnumBasedList('FastFunc', 'FF__MAX', lambda x:
> + re.sub('(?<!_)_(?!_)', '.', cut_prefix(x, 'FF_')))
> +
> +
> def mref(typename, obj):
> return dbg.cast(typename, obj['ptr64'] if LJ_GC64 else obj['ptr32'])
>
> @@ -1716,7 +1721,7 @@ def dump_lj_gco_proto(gcobj):
>
> def dump_lj_gco_func(gcobj):
> func = dbg.cast('struct GCfuncC *', gcobj)
> - ffid = func['ffid']
> + ffid = int(func['ffid'])
>
> if ffid == 0:
> pt = funcproto(func)
> @@ -1729,7 +1734,8 @@ def dump_lj_gco_func(gcobj):
> elif ffid == 1:
> return 'C function @ {}'.format(strx64(func['f']))
> else:
> - return 'fast function #{}'.format(int(ffid))
> + ffname = FF_NAMES[ffid] if ffid < len(FF_NAMES) else "unknown"
use single quotes
> + return 'fast function {} (#{})'.format(ffname, ffid)
>
>
> def dump_lj_gco_trace(gcobj):
> @@ -2079,7 +2085,7 @@ def dump_proto(proto):
>
>
> def dump_func(func):
> - ffid = func['ffid']
> + ffid = int(func['ffid'])
>
> if ffid == 0:
> pt = funcproto(func)
> @@ -2087,7 +2093,8 @@ def dump_func(func):
> elif ffid == 1:
> return 'C function @ {}\n'.format(strx64(func['f']))
> else:
> - return 'fast function #{}\n'.format(int(ffid))
> + ffname = FF_NAMES[ffid] if ffid < len(FF_NAMES) else "unknown"
the same is used in dump_lj_gco_func(), I would create a helper for this
> + return 'fast function {} (#{})\n'.format(ffname, ffid)
>
>
> # FFI dumpers.
> @@ -2713,7 +2720,7 @@ the type and some info related to it.
> * LJ_TFUNC: <LFUNC|CFUNC|FFUNC>
> <LFUNC>: Lua function @ <gcr>, <nupvals> upvalues, <chunk:line>
> <CFUNC>: C function <mcode address>
> - <FFUNC>: fast function #<ffid>
> + <FFUNC>: fast function <ffname> (#<ffid>)
> * LJ_TTRACE: trace <traceno> @ <gcr>
> * LJ_TCDATA: cdata @ <gcr>
> * LJ_TTAB: table @ <gcr> (asize: <asize>, hmask: <hmask>)
> @@ -2932,7 +2939,7 @@ the type and some info related to it.
> * LJ_TFUNC: <LFUNC|CFUNC|FFUNC>
> <LFUNC>: Lua function @ <gcr>, <nupvals> upvalues, <chunk:line>
> <CFUNC>: C function <mcode address>
> - <FFUNC>: fast function #<ffid>
> + <FFUNC>: fast function <ffname> (#<ffid>)
> * LJ_TTRACE: trace <traceno> @ <gcr>
> * LJ_TCDATA: cdata @ <gcr>
> * LJ_TTAB: table @ <gcr> (asize: <asize>, hmask: <hmask>)
> diff --git a/test/tarantool-debugger-tests/debug-extension-tests.py b/test/tarantool-debugger-tests/debug-extension-tests.py
> index 5e369f00..fe5e34f5 100644
> --- a/test/tarantool-debugger-tests/debug-extension-tests.py
> +++ b/test/tarantool-debugger-tests/debug-extension-tests.py
fallback "unknown" is not covered
> @@ -326,7 +326,7 @@ GCO_ARGS = (
> 'coroutine.create(function() end),\n'
> 'function() end,\n'
> 'require,\n'
> - 'print,\n'
> + 'math.min,\n'
> 'ffi.new("int*"),\n'
> '{1},\n'
> 'newproxy(),\n'
added also tests for: getmetatable(io.stdout).__gc and
getmetatable(io.stdout).__tostring to cover regexp
> @@ -338,7 +338,7 @@ GCO_RX = (
> r'thread @ ' + RX_ADDR + r'\n'
> r'Lua function @ ' + RX_ADDR + r', [0-9]+ upvalues, .+:[0-9]+\n'
> r'C function @ ' + RX_ADDR + r'\n'
> - r'fast function #[0-9]+\n'
> + r'fast function math.min \(#[0-9]+\)\n'
> r'cdata @ ' + RX_ADDR + r' \[\d+\] <int \*> 0x0\n'
> r'table @ ' + RX_ADDR + r' \(asize: \d+, hmask: ' + RX_HASH + r'\)\n'
> r'userdata @ ' + RX_ADDR + r'\n'
> @@ -367,6 +367,7 @@ class TestLJTV(TestCaseBase):
> # Sorted in LJT order.
> lua_script = (
> 'local ffi = require("ffi")\n'
> + 'local math = require("math")\n'
> 'print(\n'
> ' nil,\n'
> ' false,\n'
> @@ -435,6 +436,7 @@ class TestLJGCo(TestCaseBase):
>
> lua_script = (
> 'local ffi = require("ffi")\n'
> + 'local math = require("math")\n'
> 'print(\n' +
> GCO_ARGS +
> ' 1\n' # Stub for the pattern.
add also a test with "lj-func" for any ffunc
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Tarantool-patches] [PATCH luajit v3] dbg: display fast function name along with ffid
2026-09-28 13:02 ` Sergey Bronnikov via Tarantool-patches
@ 2026-10-07 16:27 ` Mikhail Elhimov via Tarantool-patches
2026-10-07 16:33 ` [Tarantool-patches] [PATCH luajit v4] " Mikhail Elhimov via Tarantool-patches
1 sibling, 0 replies; 10+ messages in thread
From: Mikhail Elhimov via Tarantool-patches @ 2026-10-07 16:27 UTC (permalink / raw)
To: Sergey Bronnikov, Sergey Kaplun, Evgeniy Temirgaleev; +Cc: tarantool-patches
Hi, Sergey!
Thanks for the review! Updated according to your comments.
On 28.09.2026 16:02, Sergey Bronnikov wrote:
> Hi, Mikhail,
>
> thanks for the patch! LGTM with minor comments below.
>
> Sergey
>
> On 9/24/26 23:14, Mikhail Elhimov wrote:
>> Part of tarantool/tarantool#4808
>> ---
>> Changes in v3:
>> - Fixed fast function regexp in tests
>>
>> Changes in v2:
>> - Format is changed to 'ffname (#ffid)'
>> - Replaced single '_' with '.' in ffname
>> - Adjusted tests to check mapping
>>
>> This patch is to be applied after
>> https://lists.tarantool.org/pipermail/tarantool-patches/2026-September/030791.html.
>>
>> Branch:
>> https://github.com/tarantool/luajit/tree/elhimov/gh-4808-display-fast-function-name
>> Related issue: https://github.com/tarantool/tarantool/issues/4808
>>
>> src/luajit_dbg.py | 19 +++++++++++++------
>> .../debug-extension-tests.py | 6 ++++--
>> 2 files changed, 17 insertions(+), 8 deletions(-)
>>
>> diff --git a/src/luajit_dbg.py b/src/luajit_dbg.py
>> index 5cd23a88..a564801b 100644
>> --- a/src/luajit_dbg.py
>> +++ b/src/luajit_dbg.py
>> @@ -1121,6 +1121,11 @@ def frames(L):
>> # LuaJIT macro implementations and structure access.
>> +# Get FastFunc enum members and replace any single '_' with '.'.
>> +FF_NAMES = EnumBasedList('FastFunc', 'FF__MAX', lambda x:
>> + re.sub('(?<!_)_(?!_)', '.', cut_prefix(x,
>> 'FF_')))
>> +
>> +
>> def mref(typename, obj):
>> return dbg.cast(typename, obj['ptr64'] if LJ_GC64 else
>> obj['ptr32'])
>> @@ -1716,7 +1721,7 @@ def dump_lj_gco_proto(gcobj):
>> def dump_lj_gco_func(gcobj):
>> func = dbg.cast('struct GCfuncC *', gcobj)
>> - ffid = func['ffid']
>> + ffid = int(func['ffid'])
>> if ffid == 0:
>> pt = funcproto(func)
>> @@ -1729,7 +1734,8 @@ def dump_lj_gco_func(gcobj):
>> elif ffid == 1:
>> return 'C function @ {}'.format(strx64(func['f']))
>> else:
>> - return 'fast function #{}'.format(int(ffid))
>> + ffname = FF_NAMES[ffid] if ffid < len(FF_NAMES) else "unknown"
> use single quotes
Done
>> + return 'fast function {} (#{})'.format(ffname, ffid)
>> def dump_lj_gco_trace(gcobj):
>> @@ -2079,7 +2085,7 @@ def dump_proto(proto):
>> def dump_func(func):
>> - ffid = func['ffid']
>> + ffid = int(func['ffid'])
>> if ffid == 0:
>> pt = funcproto(func)
>> @@ -2087,7 +2093,8 @@ def dump_func(func):
>> elif ffid == 1:
>> return 'C function @ {}\n'.format(strx64(func['f']))
>> else:
>> - return 'fast function #{}\n'.format(int(ffid))
>> + ffname = FF_NAMES[ffid] if ffid < len(FF_NAMES) else "unknown"
> the same is used in dump_lj_gco_func(), I would create a helper for this
Done
>> + return 'fast function {} (#{})\n'.format(ffname, ffid)
>> # FFI dumpers.
>> @@ -2713,7 +2720,7 @@ the type and some info related to it.
>> * LJ_TFUNC: <LFUNC|CFUNC|FFUNC>
>> <LFUNC>: Lua function @ <gcr>, <nupvals> upvalues, <chunk:line>
>> <CFUNC>: C function <mcode address>
>> - <FFUNC>: fast function #<ffid>
>> + <FFUNC>: fast function <ffname> (#<ffid>)
>> * LJ_TTRACE: trace <traceno> @ <gcr>
>> * LJ_TCDATA: cdata @ <gcr>
>> * LJ_TTAB: table @ <gcr> (asize: <asize>, hmask: <hmask>)
>> @@ -2932,7 +2939,7 @@ the type and some info related to it.
>> * LJ_TFUNC: <LFUNC|CFUNC|FFUNC>
>> <LFUNC>: Lua function @ <gcr>, <nupvals> upvalues, <chunk:line>
>> <CFUNC>: C function <mcode address>
>> - <FFUNC>: fast function #<ffid>
>> + <FFUNC>: fast function <ffname> (#<ffid>)
>> * LJ_TTRACE: trace <traceno> @ <gcr>
>> * LJ_TCDATA: cdata @ <gcr>
>> * LJ_TTAB: table @ <gcr> (asize: <asize>, hmask: <hmask>)
>> diff --git a/test/tarantool-debugger-tests/debug-extension-tests.py
>> b/test/tarantool-debugger-tests/debug-extension-tests.py
>> index 5e369f00..fe5e34f5 100644
>> --- a/test/tarantool-debugger-tests/debug-extension-tests.py
>> +++ b/test/tarantool-debugger-tests/debug-extension-tests.py
> fallback "unknown" is not covered
Added the requested tests (both for 'lj-func' and 'lj-gco')
>> @@ -326,7 +326,7 @@ GCO_ARGS = (
>> 'coroutine.create(function() end),\n'
>> 'function() end,\n'
>> 'require,\n'
>> - 'print,\n'
>> + 'math.min,\n'
>> 'ffi.new("int*"),\n'
>> '{1},\n'
>> 'newproxy(),\n'
> added also tests for: getmetatable(io.stdout).__gc and
> getmetatable(io.stdout).__tostring to cover regexp
Done
>> @@ -338,7 +338,7 @@ GCO_RX = (
>> r'thread @ ' + RX_ADDR + r'\n'
>> r'Lua function @ ' + RX_ADDR + r', [0-9]+ upvalues, .+:[0-9]+\n'
>> r'C function @ ' + RX_ADDR + r'\n'
>> - r'fast function #[0-9]+\n'
>> + r'fast function math.min \(#[0-9]+\)\n'
>> r'cdata @ ' + RX_ADDR + r' \[\d+\] <int \*> 0x0\n'
>> r'table @ ' + RX_ADDR + r' \(asize: \d+, hmask: ' + RX_HASH +
>> r'\)\n'
>> r'userdata @ ' + RX_ADDR + r'\n'
>> @@ -367,6 +367,7 @@ class TestLJTV(TestCaseBase):
>> # Sorted in LJT order.
>> lua_script = (
>> 'local ffi = require("ffi")\n'
>> + 'local math = require("math")\n'
>> 'print(\n'
>> ' nil,\n'
>> ' false,\n'
>> @@ -435,6 +436,7 @@ class TestLJGCo(TestCaseBase):
>> lua_script = (
>> 'local ffi = require("ffi")\n'
>> + 'local math = require("math")\n'
>> 'print(\n' +
>> GCO_ARGS +
>> ' 1\n' # Stub for the pattern.
> add also a test with "lj-func" for any ffunc
Done
--
Best regards,
Mikhail Elhimov
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Tarantool-patches] [PATCH luajit v4] dbg: display fast function name along with ffid
2026-09-28 13:02 ` Sergey Bronnikov via Tarantool-patches
2026-10-07 16:27 ` Mikhail Elhimov via Tarantool-patches
@ 2026-10-07 16:33 ` Mikhail Elhimov via Tarantool-patches
2026-10-08 10:58 ` Sergey Bronnikov via Tarantool-patches
1 sibling, 1 reply; 10+ messages in thread
From: Mikhail Elhimov via Tarantool-patches @ 2026-10-07 16:33 UTC (permalink / raw)
To: Sergey Kaplun, Sergey Bronnikov, Evgeniy Temirgaleev; +Cc: tarantool-patches
Part of tarantool/tarantool#4808
---
Changes in v4:
* Adjusted mapping of enum member to name ('_' is replaced with '.' only if it is not preceded by another '_')
* Added tests of various ff (including unknown)
* Reduced code duplication
* Fixed typos
Changes in v3:
* Fixed fast function regexp in tests
Changes in v2:
* Format is changed to 'ffname (#ffid)'
* Replaced single '_' with '.' in ffname
* Adjusted tests to check mapping
This patch is to be applied after https://lists.tarantool.org/pipermail/tarantool-patches/2026-September/030791.html.
Branch: https://github.com/tarantool/luajit/tree/elhimov/gh-4808-display-fast-function-name
Related issue: https://github.com/tarantool/tarantool/issues/4808
src/luajit_dbg.py | 36 +++--
.../debug-extension-tests.py | 125 ++++++++++++++----
2 files changed, 119 insertions(+), 42 deletions(-)
diff --git a/src/luajit_dbg.py b/src/luajit_dbg.py
index 7c2d085f..1d553fb9 100644
--- a/src/luajit_dbg.py
+++ b/src/luajit_dbg.py
@@ -1121,6 +1121,11 @@ def frames(L):
# LuaJIT macro implementations and structure access.
+# Get FastFunc enum members and replace any single '_' with '.'.
+FF_NAMES = EnumBasedList('FastFunc', 'FF__MAX', lambda x:
+ re.sub('(?<!_)_', '.', cut_prefix(x, 'FF_')))
+
+
def mref(typename, obj):
return dbg.cast(typename, obj['ptr64'] if LJ_GC64 else obj['ptr32'])
@@ -1693,6 +1698,11 @@ def ir_kint64(ir):
# Dumpers.
+def dump_fast_function(ffid):
+ ffname = FF_NAMES[ffid] if ffid < len(FF_NAMES) else 'unknown'
+ return 'fast function {} (#{})'.format(ffname, ffid)
+
+
# GCobj dumpers.
def dump_lj_gco_str(gcobj):
@@ -1716,7 +1726,7 @@ def dump_lj_gco_proto(gcobj):
def dump_lj_gco_func(gcobj):
func = dbg.cast('struct GCfuncC *', gcobj)
- ffid = func['ffid']
+ ffid = int(func['ffid'])
if ffid == 0:
pt = funcproto(func)
@@ -1729,7 +1739,7 @@ def dump_lj_gco_func(gcobj):
elif ffid == 1:
return 'C function @ {}'.format(strx64(func['f']))
else:
- return 'fast function #{}'.format(int(ffid))
+ return dump_fast_function(ffid)
def dump_lj_gco_trace(gcobj):
@@ -2063,7 +2073,7 @@ def dump_proto(proto):
startbc = proto_bc(proto)
func_loc = proto_loc(proto)
# Location has the following format: '{chunk}:{firstline}'.
- dump = '{func_loc}-{lastline}\n'.format(
+ dump = '{func_loc}-{lastline}'.format(
func_loc=func_loc,
lastline=proto['firstline'] + proto['numline'],
)
@@ -2072,22 +2082,22 @@ def dump_proto(proto):
return '=> ' + str(npc_from + delta).zfill(4)
for bcnum in range(0, int(proto['sizebc'])):
- dump += (str(bcnum).zfill(4) + ' ' + dump_bc(
+ dump += '\n' + str(bcnum).zfill(4) + ' ' + dump_bc(
startbc[bcnum], jmp_format=jmp_format, jmp_ctx=bcnum, proto=proto,
- ) + '\n')
+ )
return dump
def dump_func(func):
- ffid = func['ffid']
+ ffid = int(func['ffid'])
if ffid == 0:
pt = funcproto(func)
return dump_proto(pt)
elif ffid == 1:
- return 'C function @ {}\n'.format(strx64(func['f']))
+ return 'C function @ {}'.format(strx64(func['f']))
else:
- return 'fast function #{}\n'.format(int(ffid))
+ return dump_fast_function(ffid)
# FFI dumpers.
@@ -2669,7 +2679,7 @@ function:
'''
def execute(self, arg):
- dbg.write('{}'.format(dump_func(dbg.cast('GCfuncC *', dbg.eval(arg)))))
+ dbg.write(dump_func(dbg.cast('GCfuncC *', dbg.eval(arg))) + '\n')
class LJGC(dbg.LJBase):
@@ -2713,7 +2723,7 @@ the type and some info related to it.
* LJ_TFUNC: <LFUNC|CFUNC|FFUNC>
<LFUNC>: Lua function @ <gcr>, <nupvals> upvalues, <chunk:line>
<CFUNC>: C function <mcode address>
- <FFUNC>: fast function #<ffid>
+ <FFUNC>: fast function <ffname> (#<ffid>)
* LJ_TTRACE: trace <traceno> @ <gcr>
* LJ_TCDATA: cdata @ <gcr>
* LJ_TTAB: table @ <gcr> (asize: <asize>, hmask: <hmask>)
@@ -2786,9 +2796,7 @@ function:
'''
def execute(self, arg):
- dbg.write('{}'.format(
- dump_proto(dbg.cast('GCproto *', dbg.eval(arg)))
- ))
+ dbg.write(dump_proto(dbg.cast('GCproto *', dbg.eval(arg))) + '\n')
class LJDumpStack(dbg.LJBase):
@@ -2932,7 +2940,7 @@ the type and some info related to it.
* LJ_TFUNC: <LFUNC|CFUNC|FFUNC>
<LFUNC>: Lua function @ <gcr>, <nupvals> upvalues, <chunk:line>
<CFUNC>: C function <mcode address>
- <FFUNC>: fast function #<ffid>
+ <FFUNC>: fast function <ffname> (#<ffid>)
* LJ_TTRACE: trace <traceno> @ <gcr>
* LJ_TCDATA: cdata @ <gcr>
* LJ_TTAB: table @ <gcr> (asize: <asize>, hmask: <hmask>)
diff --git a/test/tarantool-debugger-tests/debug-extension-tests.py b/test/tarantool-debugger-tests/debug-extension-tests.py
index 5e369f00..b6e51185 100644
--- a/test/tarantool-debugger-tests/debug-extension-tests.py
+++ b/test/tarantool-debugger-tests/debug-extension-tests.py
@@ -35,6 +35,10 @@ if LLDB:
'--source-quietly',
'--source'
]
+
+ def modify_obj_cmd(obj, val):
+ return 'expression {} = {}'.format(obj, val)
+
else:
# GDB.
INFERIOR_ARGS = '--args'
@@ -43,6 +47,9 @@ else:
# Don't run any initialization scripts.
RUN_CMD_FILE = ['--batch', '--nx', '--quiet', '--command']
+ def modify_obj_cmd(obj, val):
+ return 'set var {} = {}'.format(obj, val)
+
TEST_VERBOSE = os.getenv('DEBUGGER_TEST_VERBOSE', default=False)
RX_ADDR = r'0x[a-f0-9]+'
@@ -320,13 +327,31 @@ class TestLJStackFunc(TestCaseBase):
pattern = STACK_RX
+FFUNC_ARGS = (
+ 'print,\n'
+ 'math.min,\n'
+ 'getmetatable(io.stdout).close,\n'
+ 'getmetatable(io.stdout).__gc,\n'
+ 'getmetatable(io.stdout).__tostring,\n'
+)
+
+
+FFUNC_RX = (
+ r'fast function print \(#[0-9]+\)\n'
+ r'fast function math.min \(#[0-9]+\)\n'
+ r'fast function io.method.close \(#[0-9]+\)\n'
+ r'fast function io.method.__gc \(#[0-9]+\)\n'
+ r'fast function io.method.__tostring \(#[0-9]+\)\n'
+)
+
+
# Sorted in LJT order.
GCO_ARGS = (
'"hello",\n'
'coroutine.create(function() end),\n'
'function() end,\n'
- 'require,\n'
- 'print,\n'
+ 'require,\n' +
+ FFUNC_ARGS +
'ffi.new("int*"),\n'
'{1},\n'
'newproxy(),\n'
@@ -337,8 +362,8 @@ GCO_RX = (
r'string \"hello\" @ ' + RX_ADDR + r'\n'
r'thread @ ' + RX_ADDR + r'\n'
r'Lua function @ ' + RX_ADDR + r', [0-9]+ upvalues, .+:[0-9]+\n'
- r'C function @ ' + RX_ADDR + r'\n'
- r'fast function #[0-9]+\n'
+ r'C function @ ' + RX_ADDR + r'\n' +
+ FFUNC_RX +
r'cdata @ ' + RX_ADDR + r' \[\d+\] <int \*> 0x0\n'
r'table @ ' + RX_ADDR + r' \(asize: \d+, hmask: ' + RX_HASH + r'\)\n'
r'userdata @ ' + RX_ADDR + r'\n'
@@ -347,26 +372,15 @@ GCO_RX = (
class TestLJTV(TestCaseBase):
location = 'lj_cf_print'
- extension_cmds = (
- 'lj-tv L->base\n'
- 'lj-tv L->base + 1\n'
- 'lj-tv L->base + 2\n'
- 'lj-tv L->base + 3\n'
- 'lj-tv L->base + 4\n'
- 'lj-tv L->base + 5\n'
- 'lj-tv L->base + 6\n'
- 'lj-tv L->base + 7\n'
- 'lj-tv L->base + 8\n'
- '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'
+ extension_cmds = ''.join(
+ ('lj-tv L->base+{}\n'.format(i)
+ for i in range(4 + GCO_ARGS.count('\n') + 2))
)
# Sorted in LJT order.
lua_script = (
'local ffi = require("ffi")\n'
+ 'local math = require("math")\n'
'print(\n'
' nil,\n'
' false,\n'
@@ -422,19 +436,14 @@ class TestLJTab(TestCaseBase):
class TestLJGCo(TestCaseBase):
location = 'lj_cf_print'
- extension_cmds = (
- 'lj-gco ' + gcval('L->base + 0') + '\n'
- 'lj-gco ' + gcval('L->base + 1') + '\n'
- 'lj-gco ' + gcval('L->base + 2') + '\n'
- 'lj-gco ' + gcval('L->base + 3') + '\n'
- 'lj-gco ' + gcval('L->base + 4') + '\n'
- 'lj-gco ' + gcval('L->base + 5') + '\n'
- 'lj-gco ' + gcval('L->base + 6') + '\n'
- 'lj-gco ' + gcval('L->base + 7') + '\n'
+ extension_cmds = ''.join(
+ ('lj-gco ' + gcval('L->base + {}'.format(i)) + '\n'
+ for i in range(GCO_ARGS.count('\n')))
)
lua_script = (
'local ffi = require("ffi")\n'
+ 'local math = require("math")\n'
'print(\n' +
GCO_ARGS +
' 1\n' # Stub for the pattern.
@@ -444,6 +453,66 @@ class TestLJGCo(TestCaseBase):
pattern = GCO_RX
+class TestLJGCoFFUnknown(TestCaseBase):
+ location = 'lj_cf_print'
+
+ val = '((GCfuncC *)' + gcval('L->base') + ')'
+ extension_cmds = (
+ 'lj-gco ' + val + '\n' +
+ modify_obj_cmd(val + '->ffid', 242) + '\n'
+ 'lj-gco ' + val + '\n' +
+ modify_obj_cmd(val + '->ffid', 253) + '\n'
+ 'lj-gco ' + val + '\n'
+ )
+
+ lua_script = 'print(pcall)'
+
+ pattern = (
+ r'fast function pcall \(#[0-9]+\)\n'
+ r'fast function unknown \(#242\)\n'
+ r'fast function unknown \(#253\)\n'
+ )
+
+
+class TestLJFuncFFKnown(TestCaseBase):
+ location = 'lj_cf_print'
+ extension_cmds = ''.join(
+ ('lj-func ' + gcval('L->base + {}'.format(i)) + '\n'
+ for i in range(FFUNC_ARGS.count('\n')))
+ )
+
+ lua_script = (
+ 'local math = require("math")\n'
+ 'print(\n' +
+ FFUNC_ARGS +
+ ' 1\n' # Stub for the pattern.
+ ')\n'
+ )
+
+ pattern = FFUNC_RX
+
+
+class TestLJFuncFFUnknown(TestCaseBase):
+ location = 'lj_cf_print'
+
+ val = '((GCfuncC *)' + gcval('L->base') + ')'
+ extension_cmds = (
+ 'lj-func ' + val + '\n' +
+ modify_obj_cmd(val + '->ffid', 242) + '\n'
+ 'lj-func ' + val + '\n' +
+ modify_obj_cmd(val + '->ffid', 253) + '\n'
+ 'lj-func ' + val + '\n'
+ )
+
+ lua_script = 'print(pcall)'
+
+ pattern = (
+ r'fast function pcall \(#[0-9]+\)\n'
+ r'fast function unknown \(#242\)\n'
+ r'fast function unknown \(#253\)\n'
+ )
+
+
PROTO_FUNC_SCRIPT = (
'local uvname = false\n'
'local function testf(...)\n'
--
2.43.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Tarantool-patches] [PATCH luajit v4] dbg: display fast function name along with ffid
2026-10-07 16:33 ` [Tarantool-patches] [PATCH luajit v4] " Mikhail Elhimov via Tarantool-patches
@ 2026-10-08 10:58 ` Sergey Bronnikov via Tarantool-patches
0 siblings, 0 replies; 10+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2026-10-08 10:58 UTC (permalink / raw)
To: Mikhail Elhimov, Sergey Kaplun, Evgeniy Temirgaleev; +Cc: tarantool-patches
Hi, Mikhail!
thanks for the patch! LGTM
Sergey
On 10/7/26 19:33, Mikhail Elhimov wrote:
> Part of tarantool/tarantool#4808
> ---
> Changes in v4:
> * Adjusted mapping of enum member to name ('_' is replaced with '.' only if it is not preceded by another '_')
> * Added tests of various ff (including unknown)
> * Reduced code duplication
> * Fixed typos
>
> Changes in v3:
> * Fixed fast function regexp in tests
>
> Changes in v2:
> * Format is changed to 'ffname (#ffid)'
> * Replaced single '_' with '.' in ffname
> * Adjusted tests to check mapping
>
> This patch is to be applied after https://lists.tarantool.org/pipermail/tarantool-patches/2026-September/030791.html.
>
> Branch: https://github.com/tarantool/luajit/tree/elhimov/gh-4808-display-fast-function-name
> Related issue: https://github.com/tarantool/tarantool/issues/4808
>
<snipped>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Tarantool-patches] [PATCH luajit v3] dbg: display fast function name along with ffid
2026-09-23 22:27 [Tarantool-patches] [PATCH luajit v2] dbg: avoid hardcoded enums (get them from target) Mikhail Elhimov via Tarantool-patches
@ 2026-09-24 17:33 ` Mikhail Elhimov via Tarantool-patches
0 siblings, 0 replies; 10+ messages in thread
From: Mikhail Elhimov via Tarantool-patches @ 2026-09-24 17:33 UTC (permalink / raw)
To: Sergey Kaplun, Sergey Bronnikov, Evgeniy Temirgaleev; +Cc: tarantool-patches
Part of tarantool/tarantool#4808
---
Changes in v3:
- Fixed fast function regexp in tests
Changes in v2:
- Format is changed to 'ffname (#ffid)'
- Replaced single '_' with '.' in ffname
- Adjusted tests to check mapping
This patch is to be applied after https://lists.tarantool.org/pipermail/tarantool-patches/2026-September/030791.html.
Branch: https://github.com/tarantool/luajit/tree/elhimov/gh-4808-display-fast-function-name
Related issue: https://github.com/tarantool/tarantool/issues/4808
src/luajit_dbg.py | 19 +++++++++++++------
.../debug-extension-tests.py | 6 ++++--
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/src/luajit_dbg.py b/src/luajit_dbg.py
index 5cd23a88..a564801b 100644
--- a/src/luajit_dbg.py
+++ b/src/luajit_dbg.py
@@ -1121,6 +1121,11 @@ def frames(L):
# LuaJIT macro implementations and structure access.
+# Get FastFunc enum members and replace any single '_' with '.'.
+FF_NAMES = EnumBasedList('FastFunc', 'FF__MAX', lambda x:
+ re.sub('(?<!_)_(?!_)', '.', cut_prefix(x, 'FF_')))
+
+
def mref(typename, obj):
return dbg.cast(typename, obj['ptr64'] if LJ_GC64 else obj['ptr32'])
@@ -1716,7 +1721,7 @@ def dump_lj_gco_proto(gcobj):
def dump_lj_gco_func(gcobj):
func = dbg.cast('struct GCfuncC *', gcobj)
- ffid = func['ffid']
+ ffid = int(func['ffid'])
if ffid == 0:
pt = funcproto(func)
@@ -1729,7 +1734,8 @@ def dump_lj_gco_func(gcobj):
elif ffid == 1:
return 'C function @ {}'.format(strx64(func['f']))
else:
- return 'fast function #{}'.format(int(ffid))
+ ffname = FF_NAMES[ffid] if ffid < len(FF_NAMES) else "unknown"
+ return 'fast function {} (#{})'.format(ffname, ffid)
def dump_lj_gco_trace(gcobj):
@@ -2079,7 +2085,7 @@ def dump_proto(proto):
def dump_func(func):
- ffid = func['ffid']
+ ffid = int(func['ffid'])
if ffid == 0:
pt = funcproto(func)
@@ -2087,7 +2093,8 @@ def dump_func(func):
elif ffid == 1:
return 'C function @ {}\n'.format(strx64(func['f']))
else:
- return 'fast function #{}\n'.format(int(ffid))
+ ffname = FF_NAMES[ffid] if ffid < len(FF_NAMES) else "unknown"
+ return 'fast function {} (#{})\n'.format(ffname, ffid)
# FFI dumpers.
@@ -2713,7 +2720,7 @@ the type and some info related to it.
* LJ_TFUNC: <LFUNC|CFUNC|FFUNC>
<LFUNC>: Lua function @ <gcr>, <nupvals> upvalues, <chunk:line>
<CFUNC>: C function <mcode address>
- <FFUNC>: fast function #<ffid>
+ <FFUNC>: fast function <ffname> (#<ffid>)
* LJ_TTRACE: trace <traceno> @ <gcr>
* LJ_TCDATA: cdata @ <gcr>
* LJ_TTAB: table @ <gcr> (asize: <asize>, hmask: <hmask>)
@@ -2932,7 +2939,7 @@ the type and some info related to it.
* LJ_TFUNC: <LFUNC|CFUNC|FFUNC>
<LFUNC>: Lua function @ <gcr>, <nupvals> upvalues, <chunk:line>
<CFUNC>: C function <mcode address>
- <FFUNC>: fast function #<ffid>
+ <FFUNC>: fast function <ffname> (#<ffid>)
* LJ_TTRACE: trace <traceno> @ <gcr>
* LJ_TCDATA: cdata @ <gcr>
* LJ_TTAB: table @ <gcr> (asize: <asize>, hmask: <hmask>)
diff --git a/test/tarantool-debugger-tests/debug-extension-tests.py b/test/tarantool-debugger-tests/debug-extension-tests.py
index 5e369f00..fe5e34f5 100644
--- a/test/tarantool-debugger-tests/debug-extension-tests.py
+++ b/test/tarantool-debugger-tests/debug-extension-tests.py
@@ -326,7 +326,7 @@ GCO_ARGS = (
'coroutine.create(function() end),\n'
'function() end,\n'
'require,\n'
- 'print,\n'
+ 'math.min,\n'
'ffi.new("int*"),\n'
'{1},\n'
'newproxy(),\n'
@@ -338,7 +338,7 @@ GCO_RX = (
r'thread @ ' + RX_ADDR + r'\n'
r'Lua function @ ' + RX_ADDR + r', [0-9]+ upvalues, .+:[0-9]+\n'
r'C function @ ' + RX_ADDR + r'\n'
- r'fast function #[0-9]+\n'
+ r'fast function math.min \(#[0-9]+\)\n'
r'cdata @ ' + RX_ADDR + r' \[\d+\] <int \*> 0x0\n'
r'table @ ' + RX_ADDR + r' \(asize: \d+, hmask: ' + RX_HASH + r'\)\n'
r'userdata @ ' + RX_ADDR + r'\n'
@@ -367,6 +367,7 @@ class TestLJTV(TestCaseBase):
# Sorted in LJT order.
lua_script = (
'local ffi = require("ffi")\n'
+ 'local math = require("math")\n'
'print(\n'
' nil,\n'
' false,\n'
@@ -435,6 +436,7 @@ class TestLJGCo(TestCaseBase):
lua_script = (
'local ffi = require("ffi")\n'
+ 'local math = require("math")\n'
'print(\n' +
GCO_ARGS +
' 1\n' # Stub for the pattern.
--
2.43.0
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-10-08 10:58 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-09 13:07 [Tarantool-patches] [PATCH luajit] dbg: display fast function name along with ffid Mikhail Elhimov via Tarantool-patches
2026-09-22 9:16 ` Sergey Kaplun via Tarantool-patches
2026-09-23 22:55 ` Mikhail Elhimov via Tarantool-patches
2026-09-24 16:48 ` [Tarantool-patches] [PATCH luajit v2] " Mikhail Elhimov via Tarantool-patches
2026-09-24 20:14 ` [Tarantool-patches] [PATCH luajit v3] " Mikhail Elhimov via Tarantool-patches
2026-09-28 13:02 ` Sergey Bronnikov via Tarantool-patches
2026-10-07 16:27 ` Mikhail Elhimov via Tarantool-patches
2026-10-07 16:33 ` [Tarantool-patches] [PATCH luajit v4] " Mikhail Elhimov via Tarantool-patches
2026-10-08 10:58 ` Sergey Bronnikov via Tarantool-patches
2026-09-23 22:27 [Tarantool-patches] [PATCH luajit v2] dbg: avoid hardcoded enums (get them from target) Mikhail Elhimov via Tarantool-patches
2026-09-24 17:33 ` [Tarantool-patches] [PATCH luajit v3] dbg: display fast function name along with ffid Mikhail Elhimov 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