[Lldb-commits] [lldb] [LLDB][NFC] Added the interface DWARFExpression::Delegate to break dependencies and reduce lldb-server size (PR #131645)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 21 03:30:41 PDT 2025


================
@@ -696,6 +696,87 @@ llvm::StringRef DWARFUnit::PeekDIEName(dw_offset_t die_offset) {
   return llvm::StringRef();
 }
 
+llvm::Error DWARFUnit::GetDIEBitSizeAndSign(uint64_t die_offset,
+                                            uint64_t &bit_size, bool &sign) {
+  // Retrieve the type DIE that the value is being converted to. This
+  // offset is compile unit relative so we need to fix it up.
+  const uint64_t abs_die_offset = die_offset + GetOffset();
+  // FIXME: the constness has annoying ripple effects.
+  DWARFDIE die = GetDIE(abs_die_offset);
+  if (!die)
+    return llvm::createStringError("cannot resolve DW_OP_convert type DIE");
+  uint64_t encoding =
+      die.GetAttributeValueAsUnsigned(DW_AT_encoding, DW_ATE_hi_user);
+  bit_size = die.GetAttributeValueAsUnsigned(DW_AT_byte_size, 0) * 8;
+  if (!bit_size)
+    bit_size = die.GetAttributeValueAsUnsigned(DW_AT_bit_size, 0);
+  if (!bit_size)
+    return llvm::createStringError("unsupported type size in DW_OP_convert");
+  switch (encoding) {
+  case DW_ATE_signed:
+  case DW_ATE_signed_char:
+    sign = true;
+    break;
+  case DW_ATE_unsigned:
+  case DW_ATE_unsigned_char:
+    sign = false;
+    break;
+  default:
+    return llvm::createStringError("unsupported encoding in DW_OP_convert");
+  }
+  return llvm::Error::success();
+}
+
+lldb::offset_t
+DWARFUnit::GetVendorDWARFOpcodeSize(const DataExtractor &data,
+                                    const lldb::offset_t data_offset,
+                                    const uint8_t op) const {
+  return GetSymbolFileDWARF().GetVendorDWARFOpcodeSize(data, data_offset, op);
+}
+
+bool DWARFUnit::ParseVendorDWARFOpcode(uint8_t op, const DataExtractor &opcodes,
+                                       lldb::offset_t &offset,
+                                       std::vector<Value> &stack) const {
+  return GetSymbolFileDWARF().ParseVendorDWARFOpcode(op, opcodes, offset,
+                                                     stack);
+}
+
+bool DWARFUnit::ParseDWARFLocationList(
+    const DataExtractor &data, DWARFExpressionList *location_list) const {
+  location_list->Clear();
----------------
labath wrote:

Let's change this to a reference while we're here.

```suggestion
bool DWARFUnit::ParseDWARFLocationList(
    const DataExtractor &data, DWARFExpressionList &location_list) const {
  location_list.Clear();
```

https://github.com/llvm/llvm-project/pull/131645


More information about the lldb-commits mailing list