[Lldb-commits] [lldb] 14ccba2 - Promote scalars to load addresses when dereferencing them.
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Tue Mar 2 14:30:51 PST 2021
Author: Adrian Prantl
Date: 2021-03-02T14:30:39-08:00
New Revision: 14ccba26bd4d4f78cf5ec2ca8bb55c95913a3ec5
URL: https://github.com/llvm/llvm-project/commit/14ccba26bd4d4f78cf5ec2ca8bb55c95913a3ec5
DIFF: https://github.com/llvm/llvm-project/commit/14ccba26bd4d4f78cf5ec2ca8bb55c95913a3ec5.diff
LOG: Promote scalars to load addresses when dereferencing them.
This is a follow-up to 188b0747c1664d962e94f00b5e3caac529fa1e26. This
is a very narrow fix to a more general problem. LLDB should be better
at distinguishing between implict and memory location descriptions.
rdar://74902042
Added:
Modified:
lldb/source/Expression/DWARFExpression.cpp
lldb/unittests/Expression/DWARFExpressionTest.cpp
Removed:
################################################################################
diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index 6e78b9aa841a6..a8843ca0543b0 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -1064,10 +1064,12 @@ bool DWARFExpression::Evaluate(
return false;
}
stack.back().GetScalar() = load_Addr;
- stack.back().SetValueType(Value::ValueType::LoadAddress);
- // Fall through to load address code below...
+ // Fall through to load address promotion code below.
} LLVM_FALLTHROUGH;
case Value::ValueType::Scalar:
+ // Promote Scalar to LoadAddress and fall through.
+ stack.back().SetValueType(Value::ValueType::LoadAddress);
+ LLVM_FALLTHROUGH;
case Value::ValueType::LoadAddress:
if (exe_ctx) {
if (process) {
diff --git a/lldb/unittests/Expression/DWARFExpressionTest.cpp b/lldb/unittests/Expression/DWARFExpressionTest.cpp
index ad56207659d20..7fcd967990cef 100644
--- a/lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ b/lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -41,6 +41,8 @@ static llvm::Expected<Scalar> Evaluate(llvm::ArrayRef<uint8_t> expr,
switch (result.GetValueType()) {
case Value::ValueType::Scalar:
return result.GetScalar();
+ case Value::ValueType::LoadAddress:
+ return LLDB_INVALID_ADDRESS;
case Value::ValueType::HostAddress: {
// Convert small buffers to scalars to simplify the tests.
DataBufferHeap &buf = result.GetBuffer();
@@ -344,6 +346,12 @@ TEST_F(DWARFExpressionMockProcessTest, DW_OP_deref) {
ASSERT_TRUE(process_sp);
ExecutionContext exe_ctx(process_sp);
- EXPECT_THAT_EXPECTED(Evaluate({DW_OP_lit4, DW_OP_deref}, {}, {}, &exe_ctx),
+ // Implicit location: *0x4.
+ EXPECT_THAT_EXPECTED(Evaluate({DW_OP_lit4, DW_OP_deref, DW_OP_stack_value},
+ {}, {}, &exe_ctx),
llvm::HasValue(GetScalar(32, 0x07060504, false)));
+ // Memory location: *(*0x4).
+ // Evaluate returns LLDB_INVALID_ADDRESS for all load addresses.
+ EXPECT_THAT_EXPECTED(Evaluate({DW_OP_lit4, DW_OP_deref}, {}, {}, &exe_ctx),
+ llvm::HasValue(Scalar(LLDB_INVALID_ADDRESS)));
}
More information about the lldb-commits
mailing list