public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix result of DAP setExpression
@ 2023-06-28 13:56 Tom Tromey
  2023-07-07 19:57 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2023-06-28 13:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix result of DAP setExpression
  2023-06-28 13:56 [PATCH] Fix result of DAP setExpression Tom Tromey
@ 2023-07-07 19:57 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2023-07-07 19:57 UTC (permalink / raw)
  To: Tom Tromey via Gdb-patches; +Cc: Tom Tromey

>>>>> "Tom" == Tom Tromey via Gdb-patches <gdb-patches@sourceware.org> writes:

Tom> A co-worker, Andry, noticed that the DAP setExpression implementation
Tom> returned the wrong fields -- it used "result" rather than "value", and
Tom> included "memoryReference", which isn't in the spec (an odd oversight,
Tom> IMO).

Tom> This patch fixes the problems.

I'm checking this in.

Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-07 19:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-28 13:56 [PATCH] Fix result of DAP setExpression Tom Tromey
2023-07-07 19:57 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).