-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[lldb-dap] Add format support for evaluate request #169132
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
Conversation
|
@llvm/pr-subscribers-lldb Author: Sergei Druzhkov (DrSergei) ChangesThis patch adds support for format option in the Full diff: https://github.com/llvm/llvm-project/pull/169132.diff 4 Files Affected:
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index f85ab1910a2eb..306448602b48f 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -987,7 +987,9 @@ def request_writeMemory(self, memoryReference, data, offset=0, allowPartial=Fals
}
return self._send_recv(command_dict)
- def request_evaluate(self, expression, frameIndex=0, threadId=None, context=None):
+ def request_evaluate(
+ self, expression, frameIndex=0, threadId=None, context=None, is_hex=None
+ ):
stackFrame = self.get_stackFrame(frameIndex=frameIndex, threadId=threadId)
if stackFrame is None:
return []
@@ -997,6 +999,8 @@ def request_evaluate(self, expression, frameIndex=0, threadId=None, context=None
}
if context:
args_dict["context"] = context
+ if is_hex is not None:
+ args_dict["format"] = {"hex": is_hex}
command_dict = {
"command": "evaluate",
"type": "request",
diff --git a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py
index 3c233a5b43ebb..95573780e94bd 100644
--- a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py
+++ b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py
@@ -27,8 +27,11 @@ def assertEvaluate(
want_varref=False,
want_memref=True,
want_locref=False,
+ is_hex=None,
):
- resp = self.dap_server.request_evaluate(expression, context=self.context)
+ resp = self.dap_server.request_evaluate(
+ expression, context=self.context, is_hex=is_hex
+ )
self.assertTrue(
resp["success"], f"Failed to evaluate expression {expression!r}"
)
@@ -132,6 +135,12 @@ def run_test_evaluate_expressions(
if context == "repl":
self.assertEvaluate("", "21", want_type="int")
self.assertEvaluate("", "21", want_type="int")
+ self.assertEvaluate("static_int", "0x0000002a", want_type="int", is_hex=True)
+ self.assertEvaluate(
+ "non_static_int", "0x0000002b", want_type="int", is_hex=True
+ )
+ self.assertEvaluate("struct1.foo", "0x0000000f", want_type="int", is_hex=True)
+ self.assertEvaluate("struct2->foo", "0x00000010", want_type="int", is_hex=True)
self.assertEvaluate("static_int", "42", want_type="int")
self.assertEvaluate("non_static_int", "43", want_type="int")
self.assertEvaluate("struct1.foo", "15", want_type="int")
diff --git a/lldb/tools/lldb-dap/Handler/EvaluateRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/EvaluateRequestHandler.cpp
index ea8c3a2a4a296..637fc4be63bac 100644
--- a/lldb/tools/lldb-dap/Handler/EvaluateRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/EvaluateRequestHandler.cpp
@@ -84,8 +84,12 @@ EvaluateRequestHandler::Run(const EvaluateArguments &arguments) const {
if (value.GetError().Fail())
return ToError(value.GetError(), /*show_user=*/false);
- VariableDescription desc(value,
- dap.configuration.enableAutoVariableSummaries);
+ bool hex = false;
+ if (arguments.format)
+ hex = arguments.format->hex;
+
+ VariableDescription desc(value, dap.configuration.enableAutoVariableSummaries,
+ hex);
body.result = desc.GetResult(arguments.context);
body.type = desc.display_type_name;
@@ -98,7 +102,7 @@ EvaluateRequestHandler::Run(const EvaluateArguments &arguments) const {
body.memoryReference = EncodeMemoryReference(addr);
if (ValuePointsToCode(value) &&
- body.variablesReference != LLDB_DAP_INVALID_VARRERF)
+ body.variablesReference != LLDB_DAP_INVALID_VAR_REF)
body.valueLocationReference = PackLocation(body.variablesReference, true);
return body;
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
index 690a1d684d0e9..ee103ddf0b7a2 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
@@ -28,7 +28,7 @@
#include <optional>
#include <string>
-#define LLDB_DAP_INVALID_VARRERF INT64_MAX
+#define LLDB_DAP_INVALID_VAR_REF INT64_MAX
#define LLDB_DAP_INVALID_SRC_REF 0
#define LLDB_DAP_INVALID_VALUE_LOC 0
@@ -462,7 +462,7 @@ struct Scope {
/// remains suspended. See 'Lifetime of Object References' in the Overview
/// section for details.
////
- uint64_t variablesReference = LLDB_DAP_INVALID_VARRERF;
+ uint64_t variablesReference = LLDB_DAP_INVALID_VAR_REF;
/// The number of named variables in this scope.
/// The client can use this information to present the variables in a paged UI
|
🐧 Linux x64 Test Results
|
da-viper
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Only nits to address.
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
Outdated
Show resolved
Hide resolved
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
Outdated
Show resolved
Hide resolved
02c043e to
ebc4cfd
Compare
ashgti
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This patch adds support for format option in the
evaluaterequest according to DAP specification. Also, fixed typo inLLDB_DAP_INVALID_VARRERFconstant.