Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions lldb/source/Expression/DWARFExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,9 @@ static llvm::Error Evaluate_DW_OP_piece(EvalContext &eval_ctx,

static llvm::Error Evaluate_DW_OP_convert(EvalContext &eval_ctx,
uint64_t relative_die_offset) {
if (eval_ctx.stack.empty())
return llvm::createStringError("DW_OP_convert needs an argument");

uint64_t bit_size;
bool sign;
if (relative_die_offset == 0) {
Expand All @@ -1214,6 +1217,9 @@ static llvm::Error Evaluate_DW_OP_convert(EvalContext &eval_ctx,
if (!bit_size)
return llvm::createStringError("unspecified architecture");
} else {
if (!eval_ctx.dwarf_cu)
return llvm::createStringError(
"DW_OP_convert with a DIE offset requires a DWARF unit");
auto bit_size_sign_or_err =
eval_ctx.dwarf_cu->GetDIEBitSizeAndSign(relative_die_offset);
if (!bit_size_sign_or_err)
Expand Down
14 changes: 14 additions & 0 deletions lldb/unittests/Expression/DWARFExpressionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,20 @@ TEST(DWARFExpression, DW_OP_convert) {
EXPECT_THAT_ERROR(
t.Eval({DW_OP_const1s, 'X', DW_OP_convert, 0x1d}).takeError(),
llvm::Failed());

// A non-zero DIE offset with no DWARF unit must report an error rather than
// dereferencing a null Delegate (caught by lldb-dwarf-expression-fuzzer).
Comment thread
qiyao marked this conversation as resolved.
Outdated
EXPECT_THAT_ERROR(
Evaluate({DW_OP_const1s, 'X', DW_OP_convert, 0x01}, nullptr, nullptr)
.takeError(),
llvm::Failed());
Comment thread
qiyao marked this conversation as resolved.
Outdated

// DW_OP_convert with an empty stack must report an error rather than
// accessing the back of an empty stack (caught by
// lldb-dwarf-expression-fuzzer).
Comment thread
qiyao marked this conversation as resolved.
Outdated
EXPECT_THAT_ERROR(
Evaluate({DW_OP_convert, 0x00}, nullptr, nullptr).takeError(),
llvm::Failed());
Comment thread
qiyao marked this conversation as resolved.
Outdated
}

TEST(DWARFExpression, DW_OP_stack_value) {
Expand Down