Skip to content

[lldb/DWARF] Add support for DW_OP_implicit_value #2021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
23 changes: 23 additions & 0 deletions lldb/source/Expression/DWARFExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2248,6 +2248,29 @@ bool DWARFExpression::Evaluate(
}
break;

// OPCODE: DW_OP_implicit_value
// OPERANDS: 2
// ULEB128 size of the value block in bytes
// uint8_t* block bytes encoding value in target's memory
// representation
// DESCRIPTION: Value is immediately stored in block in the debug info with
// the memory representation of the target.
case DW_OP_implicit_value: {
const uint32_t len = opcodes.GetULEB128(&offset);
const void *data = opcodes.GetData(&offset, len);

if (!data) {
LLDB_LOG(log, "Evaluate_DW_OP_implicit_value: could not be read data");
LLDB_ERRORF(error_ptr, "Could not evaluate %s.",
DW_OP_value_to_name(op));
return false;
}

Value result(data, len);
stack.push_back(result);
break;
}

// OPCODE: DW_OP_push_object_address
// OPERANDS: none
// DESCRIPTION: Pushes the address of the object currently being
Expand Down
8 changes: 8 additions & 0 deletions lldb/unittests/Expression/DWARFExpressionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,14 @@ TEST(DWARFExpression, DW_OP_piece) {
llvm::HasValue(GetScalar(16, 0xff00, true)));
}

TEST(DWARFExpression, DW_OP_implicit_value) {
unsigned char bytes = 4;

EXPECT_THAT_EXPECTED(
Evaluate({DW_OP_implicit_value, bytes, 0x11, 0x22, 0x33, 0x44}),
llvm::HasValue(GetScalar(8 * bytes, 0x44332211, true)));
}

TEST(DWARFExpression, DW_OP_unknown) {
EXPECT_THAT_EXPECTED(
Evaluate({0xff}),
Expand Down