Tarantool development patches archive
 help / color / mirror / Atom feed
From: Sergey Kaplun via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Mikhail Elhimov <m.elhimov@vk.team>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH luajit] dbg: display fast function name along with ffid
Date: Tue, 22 Sep 2026 12:16:04 +0300	[thread overview]
Message-ID: <arJHVOZ93FihKMfU@root> (raw)
In-Reply-To: <20260909130730.362946-1-m.elhimov@vk.team>

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

      reply	other threads:[~2026-09-22  9:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-09 13:07 Mikhail Elhimov via Tarantool-patches
2026-09-22  9:16 ` Sergey Kaplun via Tarantool-patches [this message]

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=arJHVOZ93FihKMfU@root \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=m.elhimov@vk.team \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit] dbg: display fast function name along with ffid' \
    /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