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 DA79D3857028 for ; Wed, 28 Jun 2023 13:56:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DA79D3857028 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 e9e14a558f8ab-345b231322fso10564205ab.2 for ; Wed, 28 Jun 2023 06:56:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1687960577; x=1690552577; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=gpvhuk6WnPGiixoVl4tq8tH8uZXPZK4BVy+izu1lrmw=; b=SgCWRdgpHyjLjVEUjnJw2Ri73NvoJiLyoyl68QXIGMM0e8F3EOMLi1KPmZXqSRmF3q 04NGaWRdfG0kRh1Z7MTYDLmETB9T/6GJjv9SLo3kOm4sCYGK/D9pofHeAAH7rz9A4ZYo ktU45vWqHzii4k6IvZfir/kx3DyAm+TuTtVboOkLP/aogW1m23AgILaWgUSK1JXDnG2N 7M7sXc8jOrf4P0Uc/8rjgQi/tDs2bBbkPe/SdHT58w69GoQY9FBNVBb/DVTsjoU9lyX5 bJyA06V7SQ0KScbPJAxVZXjZlLMqNpxxgOOkLz257kaAC606xJzQdr81PVQmH7H8/EyR KDWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687960577; x=1690552577; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gpvhuk6WnPGiixoVl4tq8tH8uZXPZK4BVy+izu1lrmw=; b=P6m1eqdk3L6qURlJgTmTnoWihC9t8ipAEecYKFM1fm65u2XDMGIiGsK6PJ22rMSzYx QPEHRJYB/iuMyJ8DmEqpI0Rm2Xh31p+A8JHIjHqTIgDemeT4SXIKj/8H1HrbZmXVd6QP 5ptF1Gps+bdDO7M8tBHd4Oxn1WBpiMP/aSib5SJd1ToxhO8ob7M6znlRGXMYxh72dG4A v7qyWvo03l/aZOjQwMnGIPLC8LVjvGvIFiaiautQ5eiBmmyX8Gq5UXpeOeIgltMsuZMK tMqBa7ENy68Hw34WfQW42UxBFHO5EM44uzc9lD1iE6q1B6l6RfWMfTJnws/gsLsAY5e5 RqeQ== X-Gm-Message-State: AC+VfDzI/pViacE13u99IXvvNxN25xsXm6Fo0ehwfH/xe1lzp1r2Vksv 12OZFN9I1srFRIoNfUeN6PY6wuOTpCFayTdihZTsoQ== X-Google-Smtp-Source: ACHHUZ6EtDCE6owxAI82w7sfTXxJM7P1kClW2ottwy1eaaOeFp/uijTD8fLOLSulU+4bfa2IV/Nipg== X-Received: by 2002:a92:cbcf:0:b0:33a:4ec2:86a7 with SMTP id s15-20020a92cbcf000000b0033a4ec286a7mr12369595ilq.6.1687960577100; Wed, 28 Jun 2023 06:56:17 -0700 (PDT) Received: from localhost.localdomain (71-211-136-248.hlrn.qwest.net. [71.211.136.248]) by smtp.gmail.com with ESMTPSA id o14-20020a92dace000000b0033b2a123254sm3389139ilq.61.2023.06.28.06.56.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jun 2023 06:56:16 -0700 (PDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Fix result of DAP setExpression Date: Wed, 28 Jun 2023 07:56:10 -0600 Message-Id: <20230628135610.2695419-1-tromey@adacore.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.2 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,T_SCC_BODY_TEXT_LINE 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: A co-worker, Andry, noticed that the DAP setExpression implementation returned the wrong fields -- it used "result" rather than "value", and included "memoryReference", which isn't in the spec (an odd oversight, IMO). This patch fixes the problems. --- gdb/python/lib/gdb/dap/evaluate.py | 14 +++++++++++++- gdb/testsuite/gdb.dap/basic-dap.exp | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gdb/python/lib/gdb/dap/evaluate.py b/gdb/python/lib/gdb/dap/evaluate.py index 651a4046a34..5e3ebf7fa24 100644 --- a/gdb/python/lib/gdb/dap/evaluate.py +++ b/gdb/python/lib/gdb/dap/evaluate.py @@ -53,6 +53,18 @@ def _eval_for_hover(expr, frame_id): return _evaluate(expr, frame_id) +class _SetResult(VariableReference): + def __init__(self, value): + super().__init__(None, value, "value") + + def to_object(self): + result = super().to_object() + # This is not specified in the setExpression result. + if "memoryReference" in result: + del result["memoryReference"] + return result + + # Helper function to perform an assignment. @in_gdb_thread def _set_expression(expression, value, frame_id): @@ -64,7 +76,7 @@ def _set_expression(expression, value, frame_id): lhs = gdb.parse_and_eval(expression, global_context=global_context) rhs = gdb.parse_and_eval(value, global_context=global_context) lhs.assign(rhs) - return EvaluateResult(lhs).to_object() + return _SetResult(lhs).to_object() # Helper function to evaluate a gdb command in a certain frame. diff --git a/gdb/testsuite/gdb.dap/basic-dap.exp b/gdb/testsuite/gdb.dap/basic-dap.exp index df9afcfcdfc..853e1536eab 100644 --- a/gdb/testsuite/gdb.dap/basic-dap.exp +++ b/gdb/testsuite/gdb.dap/basic-dap.exp @@ -177,7 +177,7 @@ dap_match_values "global value in main" [lindex $obj 0] \ set obj [dap_check_request_and_response "set global in main" \ setExpression {o expression [s global_variable] value [s 23]}] dap_match_values "global value in main after set" [lindex $obj 0] \ - "body result" 23 \ + "body value" 23 \ "body type" int set obj [dap_request_and_response \ -- 2.40.1