[llvm] [DebugInfo] Support to get TU for hash from .debug_types.dwo section in DWARF4. (PR #161067)

Liu Ke via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 27 00:36:40 PDT 2025


================
@@ -161,17 +161,24 @@ DWARFUnit *DWARFUnitVector::getUnitForOffset(uint64_t Offset) const {
   return nullptr;
 }
 
-DWARFUnit *
-DWARFUnitVector::getUnitForIndexEntry(const DWARFUnitIndex::Entry &E) {
-  const auto *CUOff = E.getContribution(DW_SECT_INFO);
+DWARFUnit *DWARFUnitVector::getUnitForIndexEntry(const DWARFUnitIndex::Entry &E,
+                                                 DWARFSectionKind Sec,
+                                                 const DWARFSection *Section) {
+  const auto *CUOff = E.getContribution(Sec);
   if (!CUOff)
     return nullptr;
 
   uint64_t Offset = CUOff->getOffset();
-  auto end = begin() + getNumInfoUnits();
+  auto begin = this->begin();
+  auto end = begin + getNumInfoUnits();
+
+  if (Sec == DW_SECT_EXT_TYPES) {
+    begin = end;
----------------
Sockke wrote:

No, it will return the number of CUs from the DWGUnits vector. For DWARF4, since TUs are stored after the CUs in the DWGUnits vector, we need to traverse the TUs starting from the end of the CUs.

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


More information about the llvm-commits mailing list