From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id E66266EC40; Sat, 14 Aug 2021 14:39:10 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E66266EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1628941151; bh=Bw70hOkcijQ1XLz9E7r7whrzjTEls7TJjmNH2ULe5o8=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=OqiFl1RQGkzNXNwivjgCvF2zC5TIL1lO5uTOhxfchyMg6nXpeWjPJFEZCMIRHEBLs qqem7KwTpd8hNO4pjs3kp0NNXhwJLUWvre4wyJaMxoQzKx2tCoPNDgsQGK1nlWJ2tX WWYTr1fxX0uSgiqt+BjraUbud47fKgiDed9QfvjU= Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 16BB76EC40 for ; Sat, 14 Aug 2021 14:39:10 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 16BB76EC40 Received: by mail-lj1-f173.google.com with SMTP id d16so1553124ljq.4 for ; Sat, 14 Aug 2021 04:39:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PUqSyriY11ZyBYzznsj/scmfr1L2lAZhtE9duEcW1cU=; b=U3D2X0Oz+dF6hrIW0IFn2tWgP52DrUJjTjp5mDMWkVCwJqNqfXv6KmvodqC1jNVBZd 8wMp/4Cp+BFoEZ1e99Q28QvkS0MQUDDoSaDqkCgL2x7qcnEiKU/Xm2o3xxqmmyGkbX6u f/m5gpxiuFlGVyeUNe8jfXXK/lszYHuD9d8/m/n7wN5CZi64IO7N0GxHFs1yBOLQ3dfC 0WFvz5dX25eOUmbOiwctEtn/6JN9mODIyZf1H5tyopYKPSC3Ezvgy3xf8ISBLUjD+1uK oQpZncPWfudZpXqb8VCcYlTlvSSa/cS/z7wgGnOvxp1aagSTpMBl2PtqcFxQIPTrhY7R J+CQ== X-Gm-Message-State: AOAM530286YEnir0s4pzkw7FSN4mTXQ4JqX2VXbJlu/RpaIYoMrrSpbY RxMkR5+7P/Ft0SnVow6jT7+XF+vxxGVYmPdv X-Google-Smtp-Source: ABdhPJwPkdQm9P94Ly36DdXH12kjP0gd5M4oTtDloBzc5MfTWoWXSJOstUYKo/N92v8KoiJl86XWJw== X-Received: by 2002:a05:651c:983:: with SMTP id b3mr5087890ljq.287.1628941149273; Sat, 14 Aug 2021 04:39:09 -0700 (PDT) Received: from localhost.localdomain ([2a00:1370:8131:3d05:1dd6:a1a1:b1ab:2171]) by smtp.gmail.com with ESMTPSA id x16sm461938ljc.29.2021.08.14.04.39.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Aug 2021 04:39:08 -0700 (PDT) X-Google-Original-From: Maxim Kokryashkin To: tarantool-patches@dev.tarantool.org, imun@tarantool.org, skaplun@tarantool.org Date: Sat, 14 Aug 2021 14:38:34 +0300 Message-Id: <20210814113834.1171307-1-m.kokryashkin@tarantool.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <1628864967.181226130@f723.i.mail.ru> References: <1628864967.181226130@f723.i.mail.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit v2] luajit-gdb: support dualnum mode X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Maxim Kokryashkin via Tarantool-patches Reply-To: Maxim Kokryashkin Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" luajit-gdb.py displays integers in LJ_DUALNUM mode as nan-s. The dumper function produces output thinking of any input value as of a double. However, in DUALNUM mode, integers and doubles are stored differently, so the `itype` of a float number must be less than `LJ_TISNUM`, and the `itype` of an integer must be `LJ_TISNUM`. With this fact in mind, we can easily differentiate one from another. Closes tarantool/tarantool#6224 --- Changes in v2: - Fixed comments as per review by Sergey src/luajit-gdb.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/luajit-gdb.py b/src/luajit-gdb.py index c50405ad..d4882dd7 100644 --- a/src/luajit-gdb.py +++ b/src/luajit-gdb.py @@ -238,8 +238,11 @@ def jit_state(g): 0x15: 'ERR', }.get(int(J(g)['state']), 'INVALID') +def tvisint(o): + return LJ_DUALNUM and itype(o) == LJ_TISNUM + def tvisnumber(o): - return itype(o) <= (0xfffeffff if LJ_64 and not LJ_GC64 else LJ_T['NUMX']) + return itype(o) <= LJ_TISNUM def tvislightud(o): if LJ_64 and not LJ_GC64: @@ -343,7 +346,10 @@ def dump_lj_tudata(tv): return 'userdata @ {}'.format(strx64(gcval(tv['gcr']))) def dump_lj_tnumx(tv): - return 'number {}'.format(cast('double', tv['n'])) + if tvisint(tv): + return 'number {}'.format(cast('int32_t', tv['i'])) + else: + return 'number {}'.format(cast('double', tv['n'])) def dump_lj_invalid(tv): return 'not valid type @ {}'.format(strx64(gcval(tv['gcr']))) @@ -683,7 +689,7 @@ The command requires no args and dumps current GC stats: )) def init(commands): - global LJ_64, LJ_GC64, LJ_FR2, PADDING + global LJ_64, LJ_GC64, LJ_DUALNUM, LJ_TISNUM, LJ_FR2, PADDING # XXX Fragile: though connecting the callback looks like a crap but it # respects both Python 2 and Python 3 (see #4828). @@ -724,6 +730,7 @@ def init(commands): try: LJ_64 = str(gdb.parse_and_eval('IRT_PTR')) == 'IRT_P64' LJ_FR2 = LJ_GC64 = str(gdb.parse_and_eval('IRT_PGC')) == 'IRT_P64' + LJ_DUALNUM = lookup('lj_lib_checknumber') is not None except: gdb.write('luajit-gdb.py failed to load: ' 'no debugging symbols found for libluajit\n') @@ -733,6 +740,7 @@ def init(commands): command(name) PADDING = ' ' * len(':' + hex((1 << (47 if LJ_GC64 else 32)) - 1)) + LJ_TISNUM = 0xfffeffff if LJ_64 and not LJ_GC64 else LJ_T['NUMX'] gdb.write('luajit-gdb.py is successfully loaded\n') -- 2.32.0