Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,14 @@ 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: Optional[bool] = None,
):
stackFrame = self.get_stackFrame(frameIndex=frameIndex, threadId=threadId)
if stackFrame is None:
return []
Expand All @@ -997,6 +1004,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",
Expand Down
11 changes: 10 additions & 1 deletion lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
)
Expand Down Expand Up @@ -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")
Expand Down
8 changes: 5 additions & 3 deletions lldb/tools/lldb-dap/Handler/EvaluateRequestHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ EvaluateRequestHandler::Run(const EvaluateArguments &arguments) const {
if (value.GetError().Fail())
return ToError(value.GetError(), /*show_user=*/false);

VariableDescription desc(value,
dap.configuration.enableAutoVariableSummaries);
const bool hex = arguments.format ? arguments.format->hex : false;

VariableDescription desc(value, dap.configuration.enableAutoVariableSummaries,
hex);

body.result = desc.GetResult(arguments.context);
body.type = desc.display_type_name;
Expand All @@ -98,7 +100,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;
Expand Down
4 changes: 2 additions & 2 deletions lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
Loading