Fix result of DAP setExpression 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.
diff --git a/gdb/python/lib/gdb/dap/evaluate.py b/gdb/python/lib/gdb/dap/evaluate.py index 651a404..5e3ebf7 100644 --- a/gdb/python/lib/gdb/dap/evaluate.py +++ b/gdb/python/lib/gdb/dap/evaluate.py
@@ -53,6 +53,18 @@ 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 @@ 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 df9afcf..853e153 100644 --- a/gdb/testsuite/gdb.dap/basic-dap.exp +++ b/gdb/testsuite/gdb.dap/basic-dap.exp
@@ -177,7 +177,7 @@ 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 \