This revision was automatically updated to reflect the committed changes. Closed by commit rG00c60496775b: [lldb][NFC] Refactor test to enable subsequent reuse (authored by fdeazeve).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D155197/new/ https://reviews.llvm.org/D155197 Files: lldb/unittests/Expression/DWARFExpressionTest.cpp Index: lldb/unittests/Expression/DWARFExpressionTest.cpp =================================================================== --- lldb/unittests/Expression/DWARFExpressionTest.cpp +++ lldb/unittests/Expression/DWARFExpressionTest.cpp @@ -500,19 +500,26 @@ 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); }
Index: lldb/unittests/Expression/DWARFExpressionTest.cpp =================================================================== --- lldb/unittests/Expression/DWARFExpressionTest.cpp +++ lldb/unittests/Expression/DWARFExpressionTest.cpp @@ -500,19 +500,26 @@ 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