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