Skip to content

Commit cd56dfb

Browse files
authored
Merge pull request #2021 from medismailben/apple/stable/20200714
[lldb/DWARF] Add support for DW_OP_implicit_value
2 parents 751719a + 869ac11 commit cd56dfb

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

lldb/source/Expression/DWARFExpression.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,6 +2248,29 @@ bool DWARFExpression::Evaluate(
22482248
}
22492249
break;
22502250

2251+
// OPCODE: DW_OP_implicit_value
2252+
// OPERANDS: 2
2253+
// ULEB128 size of the value block in bytes
2254+
// uint8_t* block bytes encoding value in target's memory
2255+
// representation
2256+
// DESCRIPTION: Value is immediately stored in block in the debug info with
2257+
// the memory representation of the target.
2258+
case DW_OP_implicit_value: {
2259+
const uint32_t len = opcodes.GetULEB128(&offset);
2260+
const void *data = opcodes.GetData(&offset, len);
2261+
2262+
if (!data) {
2263+
LLDB_LOG(log, "Evaluate_DW_OP_implicit_value: could not be read data");
2264+
LLDB_ERRORF(error_ptr, "Could not evaluate %s.",
2265+
DW_OP_value_to_name(op));
2266+
return false;
2267+
}
2268+
2269+
Value result(data, len);
2270+
stack.push_back(result);
2271+
break;
2272+
}
2273+
22512274
// OPCODE: DW_OP_push_object_address
22522275
// OPERANDS: none
22532276
// DESCRIPTION: Pushes the address of the object currently being

lldb/unittests/Expression/DWARFExpressionTest.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,14 @@ TEST(DWARFExpression, DW_OP_piece) {
221221
llvm::HasValue(GetScalar(16, 0xff00, true)));
222222
}
223223

224+
TEST(DWARFExpression, DW_OP_implicit_value) {
225+
unsigned char bytes = 4;
226+
227+
EXPECT_THAT_EXPECTED(
228+
Evaluate({DW_OP_implicit_value, bytes, 0x11, 0x22, 0x33, 0x44}),
229+
llvm::HasValue(GetScalar(8 * bytes, 0x44332211, true)));
230+
}
231+
224232
TEST(DWARFExpression, DW_OP_unknown) {
225233
EXPECT_THAT_EXPECTED(
226234
Evaluate({0xff}),

0 commit comments

Comments
 (0)