================ @@ -81,27 +81,88 @@ void DWARFDebugInfo::ParseUnitsFor(DIERef::Section section) { : m_context.getOrLoadDebugInfoData(); lldb::offset_t offset = 0; while (data.ValidOffset(offset)) { - llvm::Expected<DWARFUnitSP> unit_sp = DWARFUnit::extract( + llvm::Expected<DWARFUnitSP> expected_unit_sp = DWARFUnit::extract( m_dwarf, m_units.size(), data, section, &offset); - if (!unit_sp) { + if (!expected_unit_sp) { // FIXME: Propagate this error up. - llvm::consumeError(unit_sp.takeError()); + llvm::consumeError(expected_unit_sp.takeError()); return; } + DWARFUnitSP unit_sp = *expected_unit_sp; + // If it didn't return an error, then it should be returning a valid Unit. - assert(*unit_sp); - m_units.push_back(*unit_sp); - offset = (*unit_sp)->GetNextUnitOffset(); + assert((bool)unit_sp); + + // Keep a map of DWO ID back to the skeleton units. Sometimes accelerator + // table lookups can cause the DWO files to be accessed before the skeleton + // compile unit is parsed, so we keep a map to allow us to match up the DWO + // file to the back to the skeleton compile units. + if (unit_sp->GetUnitType() == lldb_private::dwarf::DW_UT_skeleton) { + if (std::optional<uint64_t> unit_dwo_id = unit_sp->GetHeaderDWOId()) + m_dwarf5_dwo_id_to_skeleton_unit[*unit_dwo_id] = unit_sp.get(); + } - if (auto *type_unit = llvm::dyn_cast<DWARFTypeUnit>(unit_sp->get())) { + m_units.push_back(unit_sp); + offset = unit_sp->GetNextUnitOffset(); + + if (auto *type_unit = llvm::dyn_cast<DWARFTypeUnit>(unit_sp.get())) { m_type_hash_to_unit_index.emplace_back(type_unit->GetTypeHash(), - unit_sp.get()->GetID()); + unit_sp->GetID()); } } } +DWARFUnit *DWARFDebugInfo::GetSkeletonUnit(DWARFUnit *dwo_unit) { ---------------- clayborg wrote:
A NULL pointer already means it isn't availble. Not sure what making it optional would benefit? https://github.com/llvm/llvm-project/pull/79544 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits