diff options
Diffstat (limited to 'include/llvm/DebugInfo/DWARF/DWARFUnit.h')
| -rw-r--r-- | include/llvm/DebugInfo/DWARF/DWARFUnit.h | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/include/llvm/DebugInfo/DWARF/DWARFUnit.h b/include/llvm/DebugInfo/DWARF/DWARFUnit.h index 79c3ce1106d5c..f9f90db31890a 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFUnit.h +++ b/include/llvm/DebugInfo/DWARF/DWARFUnit.h @@ -1,9 +1,8 @@ //===- DWARFUnit.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -49,7 +48,7 @@ class DWARFUnitHeader { uint32_t Offset = 0; // Version, address size, and DWARF format. dwarf::FormParams FormParams; - uint32_t Length = 0; + uint64_t Length = 0; uint64_t AbbrOffset = 0; // For DWO units only. @@ -83,7 +82,7 @@ public: uint8_t getDwarfOffsetByteSize() const { return FormParams.getDwarfOffsetByteSize(); } - uint32_t getLength() const { return Length; } + uint64_t getLength() const { return Length; } uint64_t getAbbrOffset() const { return AbbrOffset; } Optional<uint64_t> getDWOId() const { return DWOId; } void setDWOId(uint64_t Id) { @@ -98,8 +97,11 @@ public: return UnitType == dwarf::DW_UT_type || UnitType == dwarf::DW_UT_split_type; } uint8_t getSize() const { return Size; } - // FIXME: Support DWARF64. - uint32_t getNextUnitOffset() const { return Offset + Length + 4; } + uint32_t getNextUnitOffset() const { + return Offset + Length + + (FormParams.Format == llvm::dwarf::DwarfFormat::DWARF64 ? 4 : 0) + + FormParams.getDwarfOffsetByteSize(); + } }; const DWARFUnitIndex &getDWARFUnitIndex(DWARFContext &Context, @@ -173,6 +175,7 @@ struct StrOffsetsContributionDescriptor { StrOffsetsContributionDescriptor(uint64_t Base, uint64_t Size, uint8_t Version, dwarf::DwarfFormat Format) : Base(Base), Size(Size), FormParams({Version, 0, Format}) {} + StrOffsetsContributionDescriptor() = default; uint8_t getVersion() const { return FormParams.Version; } dwarf::DwarfFormat getFormat() const { return FormParams.Format; } @@ -182,7 +185,7 @@ struct StrOffsetsContributionDescriptor { /// Determine whether a contribution to the string offsets table is /// consistent with the relevant section size and that its length is /// a multiple of the size of one of its entries. - Optional<StrOffsetsContributionDescriptor> + Expected<StrOffsetsContributionDescriptor> validateContributionSize(DWARFDataExtractor &DA); }; @@ -218,7 +221,7 @@ class DWARFUnit { Optional<DWARFDebugRnglistTable> RngListTable; mutable const DWARFAbbreviationDeclarationSet *Abbrevs; - llvm::Optional<SectionedAddress> BaseAddr; + llvm::Optional<object::SectionedAddress> BaseAddr; /// The compile unit debug information entry items. std::vector<DWARFDebugInfoEntry> DieArray; @@ -247,14 +250,14 @@ protected: /// Find the unit's contribution to the string offsets table and determine its /// length and form. The given offset is expected to be derived from the unit /// DIE's DW_AT_str_offsets_base attribute. - Optional<StrOffsetsContributionDescriptor> + Expected<Optional<StrOffsetsContributionDescriptor>> determineStringOffsetsTableContribution(DWARFDataExtractor &DA); /// Find the unit's contribution to the string offsets table and determine its /// length and form. The given offset is expected to be 0 in a dwo file or, /// in a dwp file, the start of the unit's contribution to the string offsets /// table section (as determined by the index table). - Optional<StrOffsetsContributionDescriptor> + Expected<Optional<StrOffsetsContributionDescriptor>> determineStringOffsetsTableContributionDWO(DWARFDataExtractor &DA); public: @@ -305,7 +308,8 @@ public: RangeSectionBase = Base; } - Optional<SectionedAddress> getAddrOffsetSectionItem(uint32_t Index) const; + Optional<object::SectionedAddress> + getAddrOffsetSectionItem(uint32_t Index) const; Optional<uint64_t> getStringOffsetSectionItem(uint32_t Index) const; DWARFDataExtractor getDebugInfoExtractor() const; @@ -376,7 +380,7 @@ public: llvm_unreachable("Invalid UnitType."); } - llvm::Optional<SectionedAddress> getBaseAddress(); + llvm::Optional<object::SectionedAddress> getBaseAddress(); DWARFDie getUnitDIE(bool ExtractUnitDIEOnly = true) { extractDIEsIfNeeded(ExtractUnitDIEOnly); @@ -385,6 +389,13 @@ public: return DWARFDie(this, &DieArray[0]); } + DWARFDie getNonSkeletonUnitDIE(bool ExtractUnitDIEOnly = true) { + parseDWO(); + if (DWO) + return DWO->getUnitDIE(ExtractUnitDIEOnly); + return getUnitDIE(ExtractUnitDIEOnly); + } + const char *getCompilationDir(); Optional<uint64_t> getDWOId() { extractDIEsIfNeeded(/*CUDieOnly*/ true); @@ -462,13 +473,12 @@ public: DWARFDie getDIEForOffset(uint32_t Offset) { extractDIEsIfNeeded(false); assert(!DieArray.empty()); - auto it = std::lower_bound( - DieArray.begin(), DieArray.end(), Offset, - [](const DWARFDebugInfoEntry &LHS, uint32_t Offset) { - return LHS.getOffset() < Offset; + auto It = + llvm::partition_point(DieArray, [=](const DWARFDebugInfoEntry &DIE) { + return DIE.getOffset() < Offset; }); - if (it != DieArray.end() && it->getOffset() == Offset) - return DWARFDie(this, &*it); + if (It != DieArray.end() && It->getOffset() == Offset) + return DWARFDie(this, &*It); return DWARFDie(); } |
