================
@@ -21,6 +27,49 @@ using namespace lldb_private;
 using namespace lldb_private::plugin::dwarf;
 using namespace llvm::dwarf;
 
+static std::optional<uint64_t>
+EvaluateUnsignedArrayProperty(const DWARFFormValue &form_value,
+                              const DWARFDIE &parent_die,
+                              const ExecutionContext *exe_ctx) {
+  // Array properties may be encoded directly as constants.
+  if (std::optional<uint64_t> value = form_value.getAsUnsignedConstant())
+    return value;
+  if (std::optional<int64_t> value = form_value.getAsSignedConstant())
+    if (*value >= 0)
+      return *value;
+
+  // Otherwise, evaluate expression blocks in the current execution context.
+  // Without a context there is no frame/register state to use for operations
+  // such as DW_OP_fbreg.
+  if (!DWARFFormValue::IsBlockForm(form_value.Form()) || !exe_ctx)
+    return std::nullopt;
+
+  DWARFUnit *unit = parent_die.GetCU();
+  SymbolFileDWARF *dwarf = parent_die.GetDWARF();
+  if (!unit || !dwarf || !dwarf->GetObjectFile())
+    return std::nullopt;
+
+  lldb::RegisterContextSP reg_ctx_sp;
+  if (lldb::StackFrameSP frame_sp = exe_ctx->GetFrameSP())
+    reg_ctx_sp = frame_sp->GetRegisterContext();
+
+  DataExtractor data(form_value.BlockData(), form_value.Unsigned(),
+                     unit->GetByteOrder(), unit->GetAddressByteSize());
+  ExecutionContext exe_ctx_copy(*exe_ctx);
+
+  // Evaluate the DWARF expression to obtain the dynamic property value.
+  llvm::Expected<Value> result = DWARFExpression::Evaluate(
+      &exe_ctx_copy, reg_ctx_sp.get(), dwarf->GetObjectFile()->GetModule(),
+      data, unit, eRegisterKindDWARF,
+      /*initial_value_ptr=*/nullptr, /*object_address_ptr=*/nullptr);
+  if (!result) {
+    llvm::consumeError(result.takeError());
----------------
Michael137 wrote:

lets `LLDB_LOG_ERROR` instead of dropping it

https://github.com/llvm/llvm-project/pull/204119
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to