Author: Med Ismail Bennani Date: 2020-10-22T18:02:44+02:00 New Revision: efe62b637d51f6d622589132075320dd4f687478
URL: https://github.com/llvm/llvm-project/commit/efe62b637d51f6d622589132075320dd4f687478 DIFF: https://github.com/llvm/llvm-project/commit/efe62b637d51f6d622589132075320dd4f687478.diff LOG: [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 <medismail.benn...@gmail.com> Added: Modified: lldb/source/Expression/DWARFExpression.cpp lldb/unittests/Expression/DWARFExpressionTest.cpp Removed: ################################################################################ diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp index 87e2c8243939..b42c9cfafb4f 100644 --- a/lldb/source/Expression/DWARFExpression.cpp +++ b/lldb/source/Expression/DWARFExpression.cpp @@ -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 diff --git a/lldb/unittests/Expression/DWARFExpressionTest.cpp b/lldb/unittests/Expression/DWARFExpressionTest.cpp index c02de402b4dd..1c762677f6fe 100644 --- a/lldb/unittests/Expression/DWARFExpressionTest.cpp +++ b/lldb/unittests/Expression/DWARFExpressionTest.cpp @@ -218,6 +218,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}), _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits