From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by sourceware.org (Postfix) with ESMTPS id DD2563858C5F for ; Tue, 4 Apr 2023 17:08:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DD2563858C5F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-il1-x135.google.com with SMTP id t5so6117205ilu.5 for ; Tue, 04 Apr 2023 10:08:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1680628132; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=yW7MhkMzoyopTFxaiZZKdmkZc2n8BWw/VfkgX9d2rfE=; b=kCwmpjGywxKtZJrUtFw42yO44i4QOEg1+2+nTNvEneY0gaVGHKl/Jg8ssPlxkOh3+S eU/c6paXOicg3HdxWyI7YItgl1Pn/wR8P/oOGqctCcBp+HPUAaaO3jqKNDYUsEM6Dn9U Y5j34lwMi7/fSDj/R8jMcbmvcceBoRt7gdKEhh91PQsljt0I7dl0Gdft8tCIKPdXN0Pk c9RdLDXuKmhh5n2/LtxOPMHHER+K81mfnL3BOeWVuGijgVeLF1aLQb3FhKcVxOLjwKiP +dkxZhozDv3v3mZEobdbYASuUj/NJq/OD5YwlxJADvMN67t7cIIXRVo4EpwvdiibgsIQ zRgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680628132; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yW7MhkMzoyopTFxaiZZKdmkZc2n8BWw/VfkgX9d2rfE=; b=Hb4QQRpmbIPA8CpZJlIEpDktLnK+AJ1cSkyRe8wtPKNAVzpgzZFf9IteQWOSzHz7iU mDTPhDBRQezV2jXq35hhP58rHtyvx/f/SilIM9dmlfhzCMfe+AzkWDp8X1oIz/0v/kSH Shem65CCYwmM/5aH9q26G8EB2/j7mTldnz+5J8KDeBWT1yTjLCHp/dpAF4936jEpGFoG Nn19hlnkKWSnOnH7qyLd16cxbRJIC1PKiGgXmvUrL0ApiTItPeEkfhn4328M0ip+VtGu /RAWMLRUO1Vm46TYMmyx5yEUGF8+mnMgbLX67ce8YAqBwFpkUTc+CCgWq3hN1GAHqGMj vpKA== X-Gm-Message-State: AAQBX9dDVarA50ejR+6AGsm+IVdRGbPt0QQEKqtjNeFPxxhQtZh7v8J9 TMP5PmGZFwnnPb1Zmsj2iVx8G+1WuIcjoM5+pd9f+w== X-Google-Smtp-Source: AKy350agh8FY6rhX6TzGUd8vF00FpKji5dmsUJt6WtiMaVUjMDem+CAxon+4tGfFfqlJNiNgytfsNg== X-Received: by 2002:a92:d5c8:0:b0:322:fe6b:d779 with SMTP id d8-20020a92d5c8000000b00322fe6bd779mr2257896ilq.29.1680628131945; Tue, 04 Apr 2023 10:08:51 -0700 (PDT) Received: from localhost.localdomain (71-211-185-113.hlrn.qwest.net. [71.211.185.113]) by smtp.gmail.com with ESMTPSA id f4-20020a02a104000000b0040b4c29010fsm1188306jag.140.2023.04.04.10.08.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 10:08:51 -0700 (PDT) From: Tom Tromey Date: Tue, 04 Apr 2023 11:08:49 -0600 Subject: [PATCH 1/9] Use field_signed from Python MI commands MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230404-dap-loaded-sources-v1-1-75c796bd644b@adacore.com> References: <20230404-dap-loaded-sources-v1-0-75c796bd644b@adacore.com> In-Reply-To: <20230404-dap-loaded-sources-v1-0-75c796bd644b@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: If an MI command written in Python includes a number in its output, currently that is simply emitted as a string. However, it's convenient for a later patch if these are emitted using field_signed. This does not make a difference to ordinary MI clients. --- gdb/python/py-micmd.c | 15 +++++++++++++++ gdb/python/python-internal.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/gdb/python/py-micmd.c b/gdb/python/py-micmd.c index c7c5a609f56..09dd88ca268 100644 --- a/gdb/python/py-micmd.c +++ b/gdb/python/py-micmd.c @@ -293,6 +293,21 @@ serialize_mi_result_1 (PyObject *result, const char *field_name) } else { + if (PyLong_Check (result)) + { + int overflow = 0; + gdb_py_longest val = gdb_py_long_as_long_and_overflow (result, + &overflow); + if (PyErr_Occurred () != nullptr) + gdbpy_handle_exception (); + if (overflow == 0) + { + uiout->field_signed (field_name, val); + return; + } + /* Fall through to the string case on overflow. */ + } + gdb::unique_xmalloc_ptr string (gdbpy_obj_to_string (result)); if (string == nullptr) gdbpy_handle_exception (); diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 258f5c42537..617bdb23669 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -110,6 +110,7 @@ typedef PY_LONG_LONG gdb_py_longest; typedef unsigned PY_LONG_LONG gdb_py_ulongest; #define gdb_py_long_as_ulongest PyLong_AsUnsignedLongLong +#define gdb_py_long_as_long_and_overflow PyLong_AsLongLongAndOverflow #else /* HAVE_LONG_LONG */ @@ -118,6 +119,7 @@ typedef unsigned PY_LONG_LONG gdb_py_ulongest; typedef long gdb_py_longest; typedef unsigned long gdb_py_ulongest; #define gdb_py_long_as_ulongest PyLong_AsUnsignedLong +#define gdb_py_long_as_long_and_overflow PyLong_AsLongAndOverflow #endif /* HAVE_LONG_LONG */ -- 2.39.1