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 92A0A6EC55; Sat, 31 Jul 2021 16:36:56 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 92A0A6EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1627738616; bh=T7FaiQfChWI0BdkUhG9ooNvEseYkG44ZGA9G3LWebhM=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Q7w2AsQhgkFJL7GNM+AHD7rlj0PBPnvdCiM97AEHoVgN08atLf4BDHcDQI4WH1Di5 VMPtynTWbyTqG4ySqtHHVGt5L2g2dlIWZ8XuYhKiwJXso8AyOOzcZF3HhkT2XYEeTa ifVTzq8ORLwaFGbQsH1gq+BooBUyGBhG1F9N4RQ4= Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (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 DBF996EC55 for ; Sat, 31 Jul 2021 16:36:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org DBF996EC55 Received: by mail-lf1-f54.google.com with SMTP id b6so1230607lff.10 for ; Sat, 31 Jul 2021 06:36:54 -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:mime-version :content-transfer-encoding; bh=aoS178ZwrT4eQDfNNw28cuXhyHnjY3KRL6UtyZg61FA=; b=oplpjdxRkxltUGvLmzigVRbHc0yIYyOAX1tz04MdRbjywOYsDlA58c7LqOcYFfWX0B +OKZgpvTv3nVWFaKebzFA5pj4W90Rwh9Qis+K4oDAUJH4n8oelbFQ9p56a8D80QuMtur mS0oSfad64Gk9hMOKiu6I9KnJZPi9lZyPcjjIw8Spqs+g28WUTBDrqwp6ENcL9OT2Z7+ T0mT62MIJ/I5sW/exfpmNJOOuWPNDfmGSxOqiUSHCml2J0ZP4saCFMFOEpnD7MB9IBPk nmuLM9+9hRxP7qpqpWfOw1u7qNkchwTSqMygOB3Lz5TiAcyUOT22i88i0gu4GvnG2kJs FUCA== X-Gm-Message-State: AOAM531JDkD5w4ONDIi1ef3hGFLqIRGdbfoFts9KNRvYHhCIhWpVGtGG W6KhDz6+JJ2iRWugkrCFJdNnpWioIhtWW07L X-Google-Smtp-Source: ABdhPJwqiAiLcVjtjB5Dqs4YrFkYgTlx2JVgUtlNTlaUzIgzqP+bHsJ0NHmkt/AgcCVBg875BkzRuQ== X-Received: by 2002:a05:6512:3090:: with SMTP id z16mr5914967lfd.426.1627738614107; Sat, 31 Jul 2021 06:36:54 -0700 (PDT) Received: from localhost.localdomain ([2a00:1370:8131:3d05:bf85:8453:170:43a7]) by smtp.gmail.com with ESMTPSA id i24sm354523ljm.97.2021.07.31.06.36.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Jul 2021 06:36:53 -0700 (PDT) X-Google-Original-From: Maxim Kokryashkin To: tarantool-patches@dev.tarantool.org, imun@tarantool.org, skaplun@tarantool.org Date: Sat, 31 Jul 2021 16:36:48 +0300 Message-Id: <20210731133648.25660-1-m.kokryashkin@tarantool.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit] 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" For x86/x64 LJ_DUALNUM mode is disabled. But for some other arches (arm or arm64, for example) it is enabled by default. luajit-gdb.py displays integers in LJ_DUALNUM mode as nan-s. As it turned out, luajit-gdb detects those integers as integers, but there was a problem with the dumper function itself. The dumper function produces output thinking of any input value as of a double. However, in DUALNUM mode, integers and floats 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. But in any mode, lua numbers are stored as doubles on the C side, so it takes an ugly cast chain on the Python side to perform the some sort of the `reinterpret_cast` because the gdb module doesn't have any mechanism to get the address of a symbol. Closes tarantool/tarantool#6224 --- Github branch: https://github.com/tarantool/luajit/tree/fckxorg/gh-6224-support-dulanum Issue: https://github.com/tarantool/tarantool/issues/6224 For more info, see line 273 in lj_obj.h src/luajit-gdb.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/luajit-gdb.py b/src/luajit-gdb.py index c50405ad..5f79c277 100644 --- a/src/luajit-gdb.py +++ b/src/luajit-gdb.py @@ -343,7 +343,11 @@ 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 itype(tv) == (0xfffeffff if LJ_64 and not LJ_GC64 else LJ_T['NUMX']): + integer = cast('int32_t', cast('uint64_t', cast('void*', tv['n'])) & 0xFFFFFFFF) + return 'number {}'.format(integer) + else: + return 'number {}'.format(cast('double', tv['n'])) def dump_lj_invalid(tv): return 'not valid type @ {}'.format(strx64(gcval(tv['gcr']))) -- 2.32.0