[Tarantool-patches] [PATCH] gdb: display fast function name along with ffid
Mikhail Elhimov
m.elhimov at vk.team
Wed Aug 7 14:31:28 MSK 2024
Part of tarantool/tarantool#4808
---
Branch: https://github.com/tarantool/luajit/tree/elhimov/gh-4808-display-fast-function-name
Issue: https://github.com/tarantool/tarantool/issues/4808
src/luajit-gdb.py | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/luajit-gdb.py b/src/luajit-gdb.py
index d2070e9b..967124a8 100644
--- a/src/luajit-gdb.py
+++ b/src/luajit-gdb.py
@@ -4,6 +4,7 @@
import re
import gdb
import sys
+import itertools
# make script compatible with the ancient Python {{{
@@ -14,6 +15,7 @@ if LEGACY:
CONNECTED = False
int = long
range = xrange
+ filter = itertools.ifilter
# }}}
@@ -74,6 +76,14 @@ def strx64(val):
hex(int(cast('uint64_t', val) & 0xFFFFFFFFFFFFFFFF)))
+def enumval_name(type, val, default):
+ assert type.code == gdb.TYPE_CODE_ENUM, \
+ "enumval_name expects enum type but type of code {} was given".format(type.code)
+ enumval_attr = 'enumval' if hasattr(type.fields()[0], 'enumval') else 'bitpos'
+ field = next(filter(lambda x: getattr(x, enumval_attr) == val, type.fields()), None)
+ return field.name if field is not None else default
+
+
# Types {{{
@@ -426,7 +436,7 @@ def dump_lj_tproto(tv):
def dump_lj_tfunc(tv):
func = cast('struct GCfuncC *', gcval(tv['gcr']))
- ffid = func['ffid']
+ ffid = int(func['ffid'])
if ffid == 0:
pt = funcproto(func)
@@ -439,7 +449,9 @@ def dump_lj_tfunc(tv):
elif ffid == 1:
return 'C function @ {}'.format(strx64(func['f']))
else:
- return 'fast function #{}'.format(int(ffid))
+ ffid_enum = gdb.parse_and_eval('FF__MAX').type
+ ffid_name = enumval_name(ffid_enum, ffid, 'UNKNOWN')
+ return 'fast function #{}({})'.format(ffid, ffid_name)
def dump_lj_ttrace(tv):
--
2.43.0
More information about the Tarantool-patches
mailing list