[Lldb-commits] [PATCH] D155197: [lldb][NFC] Refactor test to enable subsequent reuse

Felipe de Azevedo Piovezan via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Jul 19 06:16:41 PDT 2023


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);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155197.541985.patch
Type: text/x-patch
Size: 1717 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230719/38a86eed/attachment.bin>


More information about the lldb-commits mailing list