[Lldb-commits] [PATCH] D77108: [lldb/DWARF] Fix evaluator crash when accessing empty stack
Med Ismail Bennani via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Mar 31 08:49:27 PDT 2020
mib updated this revision to Diff 253895.
mib marked an inline comment as done.
mib added a comment.
Addressed Pavel's request.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77108/new/
https://reviews.llvm.org/D77108
Files:
lldb/source/Expression/DWARFExpression.cpp
lldb/unittests/Expression/DWARFExpressionTest.cpp
Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===================================================================
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -234,6 +234,10 @@
llvm::Failed());
}
+TEST(DWARFExpression, DW_OP_stack_value) {
+ EXPECT_THAT_EXPECTED(Evaluate({DW_OP_stack_value}), llvm::Failed());
+}
+
TEST(DWARFExpression, DW_OP_piece) {
EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const2u, 0x11, 0x22, DW_OP_piece, 2,
DW_OP_const2u, 0x33, 0x44, DW_OP_piece, 2}),
Index: lldb/source/Expression/DWARFExpression.cpp
===================================================================
--- lldb/source/Expression/DWARFExpression.cpp
+++ lldb/source/Expression/DWARFExpression.cpp
@@ -2318,6 +2318,12 @@
// rather is a constant value. The value from the top of the stack is the
// value to be used. This is the actual object value and not the location.
case DW_OP_stack_value:
+ if (stack.empty()) {
+ if (error_ptr)
+ error_ptr->SetErrorString(
+ "Expression stack needs at least 1 item for DW_OP_stack_value.");
+ return false;
+ }
stack.back().SetValueType(Value::eValueTypeScalar);
break;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77108.253895.patch
Type: text/x-patch
Size: 1301 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200331/d52e7027/attachment-0001.bin>
More information about the lldb-commits
mailing list