Author: Felipe de Azevedo Piovezan Date: 2023-07-19T09:15:48-04:00 New Revision: 00c60496775b611d92bae5a69d4e6794ecad4084
URL: https://github.com/llvm/llvm-project/commit/00c60496775b611d92bae5a69d4e6794ecad4084 DIFF: https://github.com/llvm/llvm-project/commit/00c60496775b611d92bae5a69d4e6794ecad4084.diff LOG: [lldb][NFC] Refactor test to enable subsequent reuse On a subsequent commit, I intend to update the expression and call the evaluate function more times. This refactors enables reusing some of the existing code for that. Differential Revision: https://reviews.llvm.org/D155197 Added: Modified: lldb/unittests/Expression/DWARFExpressionTest.cpp Removed: ################################################################################ diff --git a/lldb/unittests/Expression/DWARFExpressionTest.cpp b/lldb/unittests/Expression/DWARFExpressionTest.cpp index 7d153d7fbed881..e35f35b369ea1e 100644 --- a/lldb/unittests/Expression/DWARFExpressionTest.cpp +++ b/lldb/unittests/Expression/DWARFExpressionTest.cpp @@ -500,19 +500,26 @@ TEST_F(DWARFExpressionMockProcessTest, WASM_DW_OP_addr_index) { platform_sp, target_sp); ExecutionContext exe_ctx(target_sp, false); + + auto evaluate = [&](DWARFExpression &expr, Status &status, Value &result) { + DataExtractor extractor; + expr.GetExpressionData(extractor); + return DWARFExpression::Evaluate( + &exe_ctx, /*reg_ctx*/ nullptr, /*module_sp*/ {}, extractor, dwarf_cu, + lldb::eRegisterKindLLDB, + /*initial_value_ptr*/ nullptr, + /*object_address_ptr*/ nullptr, result, &status); + }; + // DW_OP_addrx takes a single leb128 operand, the index in the addr table: - uint8_t expr[] = {DW_OP_addrx, 0x01}; - DataExtractor extractor(expr, sizeof(expr), lldb::eByteOrderLittle, + uint8_t expr_data[] = {DW_OP_addrx, 0x01}; + DataExtractor extractor(expr_data, sizeof(expr_data), lldb::eByteOrderLittle, /*addr_size*/ 4); - Value result; - Status status; - ASSERT_TRUE(DWARFExpression::Evaluate( - &exe_ctx, /*reg_ctx*/ nullptr, /*module_sp*/ {}, extractor, dwarf_cu, - lldb::eRegisterKindLLDB, - /*initial_value_ptr*/ nullptr, - /*object_address_ptr*/ nullptr, result, &status)) - << status.ToError(); + DWARFExpression expr(extractor); + Status status; + Value result; + ASSERT_TRUE(evaluate(expr, status, result)) << status.ToError(); ASSERT_EQ(result.GetValueType(), Value::ValueType::LoadAddress); ASSERT_EQ(result.GetScalar().UInt(), 0x5678u); } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits