Lines Matching +full:unit +full:- +full:address

1 //===- DWARFUnit.cpp ------------------------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
78 -> std::unique_ptr<DWARFUnit> { in addUnitsImpl()
123 // but with lower offset-within-section. This keeps units in order in addUnitsImpl()
126 auto I = this->begin(); in addUnitsImpl()
129 if (I != this->end() && in addUnitsImpl()
130 (&(*I)->getInfoSection() != &Section || (*I)->getOffset() == Offset)) { in addUnitsImpl()
138 Offset = U->getNextUnitOffset(); in addUnitsImpl()
139 I = std::next(this->insert(I, std::move(U))); in addUnitsImpl()
143 DWARFUnit *DWARFUnitVector::addUnit(std::unique_ptr<DWARFUnit> Unit) { in addUnit() argument
144 auto I = llvm::upper_bound(*this, Unit, in addUnit()
147 return LHS->getOffset() < RHS->getOffset(); in addUnit()
149 return this->insert(I, std::move(Unit))->get(); in addUnit()
157 return LHS < RHS->getNextUnitOffset(); in getUnitForOffset()
159 if (CU != end && (*CU)->getOffset() <= Offset) in getUnitForOffset()
160 return CU->get(); in getUnitForOffset()
170 uint64_t Offset = CUOff->getOffset(); in getUnitForIndexEntry()
174 std::upper_bound(begin(), end, CUOff->getOffset(), in getUnitForIndexEntry()
176 return LHS < RHS->getNextUnitOffset(); in getUnitForIndexEntry()
178 if (CU != end && (*CU)->getOffset() <= Offset) in getUnitForIndexEntry()
179 return CU->get(); in getUnitForIndexEntry()
189 this->insert(CU, std::move(U)); in getUnitForIndexEntry()
218 // Surprising if a DWO file has more than one skeleton unit in it - this in getAddrOffsetSectionItem()
223 return (*R.begin())->getAddrOffsetSectionItem(Index); in getAddrOffsetSectionItem()
229 if (AddrOffsetSection->Data.size() < Offset + getAddressByteSize()) in getAddrOffsetSectionItem()
234 uint64_t Address = DA.getRelocatedAddress(&Offset, &Section); in getAddrOffsetSectionItem() local
235 return {{Address, Section}}; in getAddrOffsetSectionItem()
273 // Fake a unit type based on the section type. This isn't perfect, in extract()
291 "DWARF unit at 0x%8.8" PRIx64 " cannot be parsed:", Offset), in extract()
294 // Header fields all parsed, capture the size of this unit header. in extract()
295 assert(*offset_ptr - Offset <= 255 && "unexpected header size"); in extract()
296 Size = uint8_t(*offset_ptr - Offset); in extract()
299 if (!debug_info.isValidOffset(getNextUnitOffset() - 1)) in extract()
301 "DWARF unit from offset 0x%8.8" PRIx64 " incl. " in extract()
309 "DWARF unit at offset 0x%8.8" PRIx64 " " in extract()
310 "has unsupported version %" PRIu16 ", supported are 2-%u", in extract()
313 // Type offset is unit-relative; should be after the header and before in extract()
314 // the end of the current unit. in extract()
317 "DWARF type unit at offset " in extract()
326 "DWARF type unit from offset 0x%8.8" PRIx64 " incl. " in extract()
328 "relocated type_offset 0x%8.8" PRIx64 " pointing past the unit end", in extract()
333 "DWARF unit at offset 0x%8.8" PRIx64, Offset)) in extract()
347 "DWARF package unit at offset 0x%8.8" PRIx64 in applyIndexEntry()
348 " has a non-zero abbreviation offset", in applyIndexEntry()
351 auto *UnitContrib = IndexEntry->getContribution(); in applyIndexEntry()
354 "DWARF package unit at offset 0x%8.8" PRIx64 in applyIndexEntry()
359 if (UnitContrib->getLength() != IndexLength) in applyIndexEntry()
361 "DWARF package unit at offset 0x%8.8" PRIx64 in applyIndexEntry()
364 Offset, UnitContrib->getLength(), IndexLength); in applyIndexEntry()
366 auto *AbbrEntry = IndexEntry->getContribution(DW_SECT_ABBREV); in applyIndexEntry()
369 "DWARF package unit at offset 0x%8.8" PRIx64 in applyIndexEntry()
373 AbbrOffset = AbbrEntry->getOffset(); in applyIndexEntry()
379 // Require that compile unit is extracted. in extractRangeList()
397 DWO->clear(); in clear()
412 // next compilation unit header. in extractDIEsToVector()
418 assert(DebugInfoData.isValidOffset(NextCUOffset - 1)); in extractDIEsToVector()
458 // around 14-20 so let's pre-reserve the needed memory for in extractDIEsToVector()
471 if (AbbrDecl->hasChildren()) { in extractDIEsToVector()
474 Parents.push_back(Dies.size() - 1); in extractDIEsToVector()
478 // Stop if we have single compile unit die w/o children. in extractDIEsToVector()
489 // Stop when compile unit die is removed from the parents stack. in extractDIEsToVector()
529 // In general, in DWARF v5 and beyond we derive the start of the unit's in tryExtractDIEsIfNeeded()
530 // contribution to the string offsets table from the unit DIE's in tryExtractDIEsIfNeeded()
535 // which may differ from the unit's format. in tryExtractDIEsIfNeeded()
552 // describe address ranges. in tryExtractDIEsIfNeeded()
558 if (auto *Contrib = IndexEntry->getContribution(DW_SECT_RNGLISTS)) in tryExtractDIEsIfNeeded()
559 ContributionBaseOffset = Contrib->getOffset(); in tryExtractDIEsIfNeeded()
578 if (const auto *C = IndexEntry->getContribution( in tryExtractDIEsIfNeeded()
580 Data = Data.substr(C->getOffset(), C->getLength()); in tryExtractDIEsIfNeeded()
639 DWARFCompileUnit *DWOCU = DWOContext->getDWOCompileUnitForHash(*DWOId); in parseDWO()
643 DWO->setSkeletonUnit(this); in parseDWO()
644 // Share .debug_addr and .debug_ranges section with compile unit in .dwo in parseDWO()
646 DWO->setAddrOffsetSection(AddrOffsetSection, *AddrOffsetSectionBase); in parseDWO()
649 DWO->setRangesSection(RangeSection, DWORangesBase.value_or(0)); in parseDWO()
657 // shrink_to_fit() is a *non-binding* request to reduce capacity() to size(). in clearDIEs()
697 return createStringError(errc::invalid_argument, "No unit DIE"); in collectAddressRanges()
699 // First, check if unit DIE describes address ranges for the whole unit. in collectAddressRanges()
703 "decoding address ranges: %s", in collectAddressRanges()
737 // Ignore 0-sized ranges. in updateAddressDieMap()
741 if (B != AddrDieMap.begin() && R.LowPC < (--B)->second.first) { in updateAddressDieMap()
742 // The range is a sub-range of existing ranges, we need to split the in updateAddressDieMap()
744 if (R.HighPC < B->second.first) in updateAddressDieMap()
745 AddrDieMap[R.HighPC] = B->second; in updateAddressDieMap()
746 if (R.LowPC > B->first) in updateAddressDieMap()
747 AddrDieMap[B->first].first = R.LowPC; in updateAddressDieMap()
758 // sub-ranges. in updateAddressDieMap()
763 DWARFDie DWARFUnit::getSubroutineForAddress(uint64_t Address) { in getSubroutineForAddress() argument
767 auto R = AddrDieMap.upper_bound(Address); in getSubroutineForAddress()
770 // upper_bound's previous item contains Address. in getSubroutineForAddress()
771 --R; in getSubroutineForAddress()
772 if (Address >= R->second.first) in getSubroutineForAddress()
774 return R->second.second; in getSubroutineForAddress()
795 uint64_t Address = UINT64_MAX; in updateVariableDieMap() local
812 if (It->getCode() == dwarf::DW_OP_addr) { in updateVariableDieMap()
813 LocationAddr = It->getRawOperand(0); in updateVariableDieMap()
814 } else if (It->getCode() == dwarf::DW_OP_addrx) { in updateVariableDieMap()
815 uint64_t DebugAddrOffset = It->getRawOperand(0); in updateVariableDieMap()
817 LocationAddr = Pointer->Address; in updateVariableDieMap()
825 if (It->getCode() != dwarf::DW_OP_plus_uconst) in updateVariableDieMap()
828 LocationAddr += It->getRawOperand(0); in updateVariableDieMap()
835 Address = LocationAddr; in updateVariableDieMap()
841 // exact address. in updateVariableDieMap()
847 if (Address != UINT64_MAX) in updateVariableDieMap()
848 VariableDieMap[Address] = {Address + GVSize, Die}; in updateVariableDieMap()
851 DWARFDie DWARFUnit::getVariableForAddress(uint64_t Address) { in getVariableForAddress() argument
860 auto R = VariableDieMap.upper_bound(Address); in getVariableForAddress()
864 // upper_bound's previous item contains Address. in getVariableForAddress()
865 --R; in getVariableForAddress()
866 if (Address >= R->second.first) in getVariableForAddress()
868 return R->second.second; in getVariableForAddress()
872 DWARFUnit::getInlinedChainForAddress(uint64_t Address, in getInlinedChainForAddress() argument
877 // First, find the subroutine that contains the given address (the leaf in getInlinedChainForAddress()
880 (DWO ? *DWO : *this).getSubroutineForAddress(Address); in getInlinedChainForAddress()
914 if (std::optional<uint32_t> ParentIdx = Die->getParentIdx()) { in getParentEntry()
936 if (std::optional<uint32_t> SiblingIdx = Die->getSiblingIdx()) { in getSiblingEntry()
958 std::optional<uint32_t> ParentIdx = Die->getParentIdx(); in getPreviousSiblingEntry()
967 uint32_t PrevDieIdx = getDIEIndex(Die) - 1; in getPreviousSiblingEntry()
997 if (!Die->hasChildren()) in getFirstChildEntry()
1022 if (!Die->hasChildren()) in getLastChildEntry()
1025 if (std::optional<uint32_t> SiblingIdx = Die->getSiblingIdx()) { in getLastChildEntry()
1028 assert(DieArray[*SiblingIdx - 1].getTag() == dwarf::DW_TAG_null && in getLastChildEntry()
1030 return &DieArray[*SiblingIdx - 1]; in getLastChildEntry()
1033 // If SiblingIdx is set for non-root dies we could be sure that DWARF is in getLastChildEntry()
1044 // For the unit die we might take last item from DieArray. in getLastChildEntry()
1046 getDIEIndex(const_cast<DWARFUnit *>(this)->getUnitDIE()) && in getLastChildEntry()
1047 "Bad unit die"); in getLastChildEntry()
1057 Abbrev->getAbbreviationDeclarationSet(getAbbreviationsOffset()); in getAbbreviations()
1072 DWARFDie UnitDie = (SU ? SU : this)->getUnitDIE(); in getBaseAddress()
1093 // Look for a DWARF64-formatted contribution to the string offsets table
1101 …urn createStringError(errc::invalid_argument, "32 bit contribution referenced from a 64 bit unit"); in parseDWARF64StringOffsetsTableHeader()
1106 // The encoded length includes the 2-byte version field and the 2-byte in parseDWARF64StringOffsetsTableHeader()
1108 return StrOffsetsContributionDescriptor(Offset, Size - 4, Version, DWARF64); in parseDWARF64StringOffsetsTableHeader()
1111 // Look for a DWARF32-formatted contribution to the string offsets table
1124 // The encoded length includes the 2-byte version field and the 2-byte in parseDWARF32StringOffsetsTableHeader()
1126 return StrOffsetsContributionDescriptor(Offset, ContributionSize - 4, Version, in parseDWARF32StringOffsetsTableHeader()
1139 auto DescOrError = parseDWARF64StringOffsetsTableHeader(DA, Offset - 16); in parseDWARFStringOffsetsTableHeader()
1148 auto DescOrError = parseDWARF32StringOffsetsTableHeader(DA, Offset - 8); in parseDWARFStringOffsetsTableHeader()
1177 IndexEntry ? IndexEntry->getContribution(DW_SECT_STR_OFFSETS) : nullptr; in determineStringOffsetsTableContributionDWO()
1179 Offset = C->getOffset(); in determineStringOffsetsTableContributionDWO()
1195 Desc = StrOffsetsContributionDescriptor(C->getOffset(), C->getLength(), 4, in determineStringOffsetsTableContributionDWO()
1209 DataExtractor RangesData(RangeSection->Data, IsLittleEndian, in getRnglistOffset()
1221 LocTable->getData(), LocSectionBase, getFormat(), Index)) in getLoclistOffset()