[PATCH] D96826: [WIP] Add Skeleton CU to DWO CU during creation.

Alexander Yermolovich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 16 18:15:02 PST 2021


ayermolo created this revision.
Herald added subscribers: hoy, wenlei, hiraditya.
ayermolo requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Context: https://lists.llvm.org/pipermail/llvm-dev/2021-February/148521.html

Work in progress diff, to start a conversation how to fix address/location apis for debug fission.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96826

Files:
  llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
  llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp


Index: llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -544,6 +544,8 @@
   DWARFCompileUnit *DWOCU = DWOContext->getDWOCompileUnitForHash(*DWOId);
   if (!DWOCU)
     return false;
+  if(Error Err = DWOContext->addSkeletonCU(this))
+    return false;
   DWO = std::shared_ptr<DWARFCompileUnit>(std::move(DWOContext), DWOCU);
   // Share .debug_addr and .debug_ranges section with compile unit in .dwo
   if (AddrOffsetSectionBase)
Index: llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -2000,3 +2000,24 @@
   auto CUs = compile_units();
   return CUs.empty() ? 0 : (*CUs.begin())->getAddressByteSize();
 }
+
+Error DWARFContext::addSkeletonCU(DWARFUnit *Unit) {
+  if (this->DWOUnits.empty()) {
+    return createError("Not DWO Unit.",
+                          errorCodeToError(object_error::parse_failed));
+  }
+
+  auto &DCtx = Unit->getContext();
+  auto &DObj = DCtx.getDWARFObj();
+  auto *NUnit = NormalUnits.addUnit(std::make_unique<DWARFCompileUnit>(
+            DCtx, Unit->getInfoSection(), Unit->getHeader(), DCtx.getDebugAbbrev(), &DObj.getRangesSection(),
+            &DObj.getLocSection(), DObj.getStrSection(),
+            DObj.getStrOffsetsSection(), &DObj.getAddrSection(),
+            DObj.getLineSection(), DCtx.isLittleEndian(), false,
+            NormalUnits));
+
+  auto AddrOffsetSectionBase = Unit->getAddrOffsetSectionBase();
+  if (AddrOffsetSectionBase)
+    NUnit->setAddrOffsetSection(&DObj.getAddrSection(), *AddrOffsetSectionBase);
+  return Error::success();
+}
Index: llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
===================================================================
--- llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
+++ llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
@@ -249,7 +249,6 @@
   }
 
 protected:
-  const DWARFUnitHeader &getHeader() const { return Header; }
 
   /// Size in bytes of the parsed unit header.
   uint32_t getHeaderSize() const { return Header.getSize(); }
@@ -277,6 +276,7 @@
 
   virtual ~DWARFUnit();
 
+  const DWARFUnitHeader &getHeader() const { return Header; }
   bool isDWOUnit() const { return IsDWO; }
   DWARFContext& getContext() const { return Context; }
   const DWARFSection &getInfoSection() const { return InfoSection; }
Index: llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
===================================================================
--- llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
+++ llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
@@ -417,6 +417,9 @@
   ///       into "SectionedAddress Address"
   DWARFCompileUnit *getCompileUnitForAddress(uint64_t Address);
 
+  /// Add Skeleton CU for DWO CU.
+  Error addSkeletonCU(DWARFUnit *Unit);
+
 private:
   /// Parse a macro[.dwo] or macinfo[.dwo] section.
   std::unique_ptr<DWARFDebugMacro>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96826.324147.patch
Type: text/x-patch
Size: 3064 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210217/0219904d/attachment.bin>


More information about the llvm-commits mailing list