Skip to content

[lldb][lldb-dap] setVariable request should send the correct response #130773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 16, 2025

Conversation

da-viper
Copy link
Contributor

@da-viper da-viper commented Mar 11, 2025

The display value was incorrectly sent as "result" instead of "value".

@llvmbot
Copy link
Member

llvmbot commented Mar 11, 2025

@llvm/pr-subscribers-lldb

Author: Ebuka Ezike (da-viper)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/130773.diff

2 Files Affected:

  • (modified) lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py (+12-2)
  • (modified) lldb/tools/lldb-dap/Handler/SetVariableRequestHandler.cpp (+1-1)
diff --git a/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py b/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py
index ee5b49de14d98..286bf3390a440 100644
--- a/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py
+++ b/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py
@@ -313,10 +313,20 @@ def do_test_scopes_variables_setVariable_evaluate(
 
         # Set a variable value whose name is synthetic, like a variable index
         # and verify the value by reading it
-        self.dap_server.request_setVariable(varRef, "[0]", 100)
+        variable_value = 100
+        response = self.dap_server.request_setVariable(varRef, "[0]", variable_value)
+        # Verify dap sent the correct response
+        verify_response = {
+            "type": "int",
+            "value": str(variable_value),
+            "variablesReference": 0,
+        }
+        for key, value in verify_response.items():
+            self.assertEqual(value, response["body"][key])
+
         response = self.dap_server.request_variables(varRef, start=0, count=1)
         self.verify_variables(
-            make_buffer_verify_dict(0, 1, 100), response["body"]["variables"]
+            make_buffer_verify_dict(0, 1, variable_value), response["body"]["variables"]
         )
 
         # Set a variable value whose name is a real child value, like "pt.x"
diff --git a/lldb/tools/lldb-dap/Handler/SetVariableRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/SetVariableRequestHandler.cpp
index 7d2f13f0a327e..8b46490d6f4f2 100644
--- a/lldb/tools/lldb-dap/Handler/SetVariableRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/SetVariableRequestHandler.cpp
@@ -146,7 +146,7 @@ void SetVariableRequestHandler::operator()(
     bool success = variable.SetValueFromCString(value.data(), error);
     if (success) {
       VariableDescription desc(variable, dap.enable_auto_variable_summaries);
-      EmplaceSafeString(body, "result", desc.display_value);
+      EmplaceSafeString(body, "value", desc.display_value);
       EmplaceSafeString(body, "type", desc.display_type_name);
 
       // We don't know the index of the variable in our dap.variables

@vogelsgesang
Copy link
Member

vogelsgesang commented Mar 11, 2025

@da-viper do you have commit access by now? Can you merge this by yourself (after potentially waiting for other reviews)

@da-viper
Copy link
Contributor Author

No, how do I get it ?

@vogelsgesang
Copy link
Member

@da-viper
Copy link
Contributor Author

@da-viper do you have commit access by now? Can you merge this by yourself (after potentially waiting for other reviews)

Yes I do have access now

Copy link
Member

@JDevlieghere JDevlieghere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please try to write a little summary of the problem in the commit description before you merge this. Something like:

The display value was incorrectly sent as "result" instead of "value".

A good description is really helpful when someone is looking through a list of commits.

The display value was incorrectly sent as "result" instead of "value".
@da-viper da-viper force-pushed the fix-set-variables branch from 3c39668 to 1a70dca Compare March 16, 2025 23:01
@da-viper da-viper merged commit 125c4db into llvm:main Mar 16, 2025
10 checks passed
@da-viper da-viper deleted the fix-set-variables branch March 16, 2025 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants