https://github.com/DrSergei updated https://github.com/llvm/llvm-project/pull/197645
>From e2b3583f338836a293c7e83162de21a332fb7556 Mon Sep 17 00:00:00 2001 From: Sergei Druzhkov <[email protected]> Date: Thu, 14 May 2026 13:02:06 +0300 Subject: [PATCH 1/2] [lldb-dap] Don't emit memory reference for constants --- .../API/tools/lldb-dap/evaluate/TestDAP_evaluate.py | 1 + lldb/tools/lldb-dap/Handler/EvaluateRequestHandler.cpp | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) 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 556168e5adfa8..328938b42b39f 100644 --- a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py +++ b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py @@ -155,6 +155,7 @@ def run_test_evaluate_expressions( self.assertEvaluate("non_static_int", "43", want_type="int") self.assertEvaluate("struct1.foo", "15", want_type="int") self.assertEvaluate("struct2->foo", "16", want_type="int") + self.assertEvaluate("10", "10", want_type="int", want_memref=False) if self.isResultExpandedDescription(): self.assertEvaluate( diff --git a/lldb/tools/lldb-dap/Handler/EvaluateRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/EvaluateRequestHandler.cpp index 7537eca72ec25..0917da637d8f7 100644 --- a/lldb/tools/lldb-dap/Handler/EvaluateRequestHandler.cpp +++ b/lldb/tools/lldb-dap/Handler/EvaluateRequestHandler.cpp @@ -118,6 +118,13 @@ EvaluateRequestHandler::Run(const EvaluateArguments &arguments) const { if (value.GetError().Fail()) return ToError(value.GetError(), /*show_user=*/false); + // Check original value type before calling `Persist`, because it change value + // type to const result + if (lldb::addr_t addr = value.GetLoadAddress(); + value.GetValueType() != lldb::eValueTypeConstResult && + addr != LLDB_INVALID_ADDRESS) + body.memoryReference = EncodeMemoryReference(addr); + if (is_repl_context) { // save the new variable expression dap.last_valid_variable_expression = std::move(expression); @@ -137,9 +144,6 @@ EvaluateRequestHandler::Run(const EvaluateArguments &arguments) const { body.variablesReference = dap.reference_storage.Insert( value, /*is_permanent=*/is_repl_context, /*is_internal=*/false); - if (lldb::addr_t addr = value.GetLoadAddress(); addr != LLDB_INVALID_ADDRESS) - body.memoryReference = EncodeMemoryReference(addr); - if (ValuePointsToCode(value) && body.variablesReference.Kind() != eReferenceKindInvalid) body.valueLocationReference = >From ced9c1365115a0ffdde412dcfc8e0ecc4bf617ad Mon Sep 17 00:00:00 2001 From: Sergei Druzhkov <[email protected]> Date: Fri, 15 May 2026 12:52:57 +0300 Subject: [PATCH 2/2] Fix review comments --- lldb/tools/lldb-dap/Handler/EvaluateRequestHandler.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lldb/tools/lldb-dap/Handler/EvaluateRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/EvaluateRequestHandler.cpp index 0917da637d8f7..8cd33f7458ae6 100644 --- a/lldb/tools/lldb-dap/Handler/EvaluateRequestHandler.cpp +++ b/lldb/tools/lldb-dap/Handler/EvaluateRequestHandler.cpp @@ -118,11 +118,11 @@ EvaluateRequestHandler::Run(const EvaluateArguments &arguments) const { if (value.GetError().Fail()) return ToError(value.GetError(), /*show_user=*/false); - // Check original value type before calling `Persist`, because it change value - // type to const result + // Check the original value type before calling `Persist`, because it changes + // the type to const result if (lldb::addr_t addr = value.GetLoadAddress(); - value.GetValueType() != lldb::eValueTypeConstResult && - addr != LLDB_INVALID_ADDRESS) + addr != LLDB_INVALID_ADDRESS && + value.GetValueType() != lldb::eValueTypeConstResult) body.memoryReference = EncodeMemoryReference(addr); if (is_repl_context) { _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
