Skip to content

Commit efe62b6

Browse files
committed
[lldb/DWARF] Add support for DW_OP_implicit_value
This patch completes https://reviews.llvm.org/D83560. Now that the compiler can emit `DW_OP_implicit_value` into DWARF expressions, lldb needed to learn reading these opcodes for variable inspection and expression evaluation. This implicit location descriptor specifies an immediate value with two operands: the length (ULEB128) followed by a block representing the value in the target memory representation. rdar://67406091 Differential revision: https://reviews.llvm.org/D89842 Signed-off-by: Med Ismail Bennani <[email protected]>
1 parent a779a16 commit efe62b6

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
@@ -218,6 +218,14 @@ TEST(DWARFExpression, DW_OP_piece) {
218218
llvm::HasValue(GetScalar(16, 0xff00, true)));
219219
}
220220

221+
TEST(DWARFExpression, DW_OP_implicit_value) {
222+
unsigned char bytes = 4;
223+
224+
EXPECT_THAT_EXPECTED(
225+
Evaluate({DW_OP_implicit_value, bytes, 0x11, 0x22, 0x33, 0x44}),
226+
llvm::HasValue(GetScalar(8 * bytes, 0x44332211, true)));
227+
}
228+
221229
TEST(DWARFExpression, DW_OP_unknown) {
222230
EXPECT_THAT_EXPECTED(
223231
Evaluate({0xff}),

0 commit comments

Comments
 (0)