<HTML><BODY><div>While I was working on another luajit-gdb enhancement,</div><div>I noticed that I forgot to add LJ_DUALNUM and LJ_TISNUM</div><div>declarations. So here is the diff that fixes it:</div><div>===========================================</div><div><div>diff --git a/src/luajit-gdb.py b/src/luajit-gdb.py<br>index d4882dd7..b656a808 100644<br>--- a/src/luajit-gdb.py<br>+++ b/src/luajit-gdb.py<br>@@ -157,9 +157,10 @@ def frame_prev(framelink):<br> LJ_64 = None<br> LJ_GC64 = None<br> LJ_FR2 = None<br>+LJ_DUALNUM = None</div><div> LJ_GCVMASK = ((1 << 47) - 1)<br>-<br>+LJ_TISNUM = None<br> PADDING = None</div><div> # }}}<br>===========================================</div></div><div> </div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;">Суббота, 14 августа 2021, 14:39 +03:00 от Maxim Kokryashkin <max.kokryashkin@gmail.com>:<br> <div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_16289411501679557349_BODY">luajit-gdb.py displays integers in LJ_DUALNUM mode as nan-s. The<br>dumper function produces output thinking of any input value as of a<br>double. However, in DUALNUM mode, integers and doubles are stored<br>differently, so the `itype` of a float number must be less than<br>`LJ_TISNUM`, and the `itype` of an integer must be `LJ_TISNUM`. With<br>this fact in mind, we can easily differentiate one from another.<br><br>Closes tarantool/tarantool#6224<br>---<br>Changes in v2:<br> - Fixed comments as per review by Sergey<br><br> src/luajit-gdb.py | 14 +++++++++++---<br> 1 file changed, 11 insertions(+), 3 deletions(-)<br><br>diff --git a/src/luajit-gdb.py b/src/luajit-gdb.py<br>index c50405ad..d4882dd7 100644<br>--- a/src/luajit-gdb.py<br>+++ b/src/luajit-gdb.py<br>@@ -238,8 +238,11 @@ def jit_state(g):<br> 0x15: 'ERR',<br> }.get(int(J(g)['state']), 'INVALID')<br> <br>+def tvisint(o):<br>+ return LJ_DUALNUM and itype(o) == LJ_TISNUM<br>+<br> def tvisnumber(o):<br>- return itype(o) <= (0xfffeffff if LJ_64 and not LJ_GC64 else LJ_T['NUMX'])<br>+ return itype(o) <= LJ_TISNUM<br> <br> def tvislightud(o):<br> if LJ_64 and not LJ_GC64:<br>@@ -343,7 +346,10 @@ def dump_lj_tudata(tv):<br> return 'userdata @ {}'.format(strx64(gcval(tv['gcr'])))<br> <br> def dump_lj_tnumx(tv):<br>- return 'number {}'.format(cast('double', tv['n']))<br>+ if tvisint(tv):<br>+ return 'number {}'.format(cast('int32_t', tv['i']))<br>+ else:<br>+ return 'number {}'.format(cast('double', tv['n']))<br> <br> def dump_lj_invalid(tv):<br> return 'not valid type @ {}'.format(strx64(gcval(tv['gcr'])))<br>@@ -683,7 +689,7 @@ The command requires no args and dumps current GC stats:<br> ))<br> <br> def init(commands):<br>- global LJ_64, LJ_GC64, LJ_FR2, PADDING<br>+ global LJ_64, LJ_GC64, LJ_DUALNUM, LJ_TISNUM, LJ_FR2, PADDING<br> <br> # XXX Fragile: though connecting the callback looks like a crap but it<br> # respects both Python 2 and Python 3 (see #4828).<br>@@ -724,6 +730,7 @@ def init(commands):<br> try:<br> LJ_64 = str(gdb.parse_and_eval('IRT_PTR')) == 'IRT_P64'<br> LJ_FR2 = LJ_GC64 = str(gdb.parse_and_eval('IRT_PGC')) == 'IRT_P64'<br>+ LJ_DUALNUM = lookup('lj_lib_checknumber') is not None<br> except:<br> gdb.write('luajit-gdb.py failed to load: '<br> 'no debugging symbols found for libluajit\n')<br>@@ -733,6 +740,7 @@ def init(commands):<br> command(name)<br> <br> PADDING = ' ' * len(':' + hex((1 << (47 if LJ_GC64 else 32)) - 1))<br>+ LJ_TISNUM = 0xfffeffff if LJ_64 and not LJ_GC64 else LJ_T['NUMX']<br> <br> gdb.write('luajit-gdb.py is successfully loaded\n')<br> <br>--<br>2.32.0</div></div></div></div></blockquote><div> </div></BODY></HTML>