LCOV - code coverage report
Current view: top level - include/llvm/DebugInfo/DWARF - DWARFUnit.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 73 83 88.0 %
Date: 2018-05-20 00:06:23 Functions: 15 17 88.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- DWARFUnit.h ----------------------------------------------*- C++ -*-===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : 
      10             : #ifndef LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
      11             : #define LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
      12             : 
      13             : #include "llvm/ADT/Optional.h"
      14             : #include "llvm/ADT/STLExtras.h"
      15             : #include "llvm/ADT/SmallVector.h"
      16             : #include "llvm/ADT/StringRef.h"
      17             : #include "llvm/ADT/iterator_range.h"
      18             : #include "llvm/BinaryFormat/Dwarf.h"
      19             : #include "llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h"
      20             : #include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
      21             : #include "llvm/DebugInfo/DWARF/DWARFDie.h"
      22             : #include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
      23             : #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
      24             : #include "llvm/DebugInfo/DWARF/DWARFSection.h"
      25             : #include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
      26             : #include "llvm/Support/DataExtractor.h"
      27             : #include <algorithm>
      28             : #include <cassert>
      29             : #include <cstddef>
      30             : #include <cstdint>
      31             : #include <map>
      32             : #include <memory>
      33             : #include <utility>
      34             : #include <vector>
      35             : 
      36             : namespace llvm {
      37             : 
      38             : class DWARFAbbreviationDeclarationSet;
      39             : class DWARFContext;
      40             : class DWARFDebugAbbrev;
      41             : class DWARFUnit;
      42             : 
      43             : /// Base class describing the header of any kind of "unit."  Some information
      44             : /// is specific to certain unit types.  We separate this class out so we can
      45             : /// parse the header before deciding what specific kind of unit to construct.
      46        5029 : class DWARFUnitHeader {
      47             :   // Offset within section.
      48             :   uint32_t Offset = 0;
      49             :   // Version, address size, and DWARF format.
      50             :   dwarf::FormParams FormParams;
      51             :   uint32_t Length = 0;
      52             :   uint64_t AbbrOffset = 0;
      53             : 
      54             :   // For DWO units only.
      55             :   const DWARFUnitIndex::Entry *IndexEntry = nullptr;
      56             : 
      57             :   // For type units only.
      58             :   uint64_t TypeHash = 0;
      59             :   uint32_t TypeOffset = 0;
      60             : 
      61             :   // Unit type as parsed, or derived from the section kind.
      62             :   uint8_t UnitType = 0;
      63             : 
      64             : public:
      65             :   /// Parse a unit header from \p debug_info starting at \p offset_ptr.
      66             :   bool extract(DWARFContext &Context, const DWARFDataExtractor &debug_info,
      67             :                uint32_t *offset_ptr, DWARFSectionKind Kind = DW_SECT_INFO,
      68             :                const DWARFUnitIndex *Index = nullptr);
      69             :   uint32_t getOffset() const { return Offset; }
      70       88571 :   const dwarf::FormParams &getFormParams() const { return FormParams; }
      71             :   uint16_t getVersion() const { return FormParams.Version; }
      72             :   dwarf::DwarfFormat getFormat() const { return FormParams.Format; }
      73             :   uint8_t getAddressByteSize() const { return FormParams.AddrSize; }
      74             :   uint8_t getRefAddrByteSize() const { return FormParams.getRefAddrByteSize(); }
      75             :   uint8_t getDwarfOffsetByteSize() const {
      76       11901 :     return FormParams.getDwarfOffsetByteSize();
      77             :   }
      78             :   uint32_t getLength() const { return Length; }
      79             :   uint64_t getAbbrOffset() const { return AbbrOffset; }
      80             :   const DWARFUnitIndex::Entry *getIndexEntry() const { return IndexEntry; }
      81             :   uint64_t getTypeHash() const { return TypeHash; }
      82             :   uint32_t getTypeOffset() const { return TypeOffset; }
      83             :   uint8_t getUnitType() const { return UnitType; }
      84             :   bool isTypeUnit() const {
      85        5029 :     return UnitType == dwarf::DW_UT_type || UnitType == dwarf::DW_UT_split_type;
      86             :   }
      87             :   // FIXME: Support DWARF64.
      88       30186 :   uint32_t getNextUnitOffset() const { return Offset + Length + 4; }
      89             : };
      90             : 
      91             : /// Base class for all DWARFUnitSection classes. This provides the
      92             : /// functionality common to all unit types.
      93             : class DWARFUnitSectionBase {
      94             : public:
      95             :   /// Returns the Unit that contains the given section offset in the
      96             :   /// same section this Unit originated from.
      97             :   virtual DWARFUnit *getUnitForOffset(uint32_t Offset) const = 0;
      98             :   virtual DWARFUnit *getUnitForIndexEntry(const DWARFUnitIndex::Entry &E) = 0;
      99             : 
     100             :   void parse(DWARFContext &C, const DWARFSection &Section);
     101             :   void parseDWO(DWARFContext &C, const DWARFSection &DWOSection,
     102             :                 bool Lazy = false);
     103             : 
     104             : protected:
     105             :   ~DWARFUnitSectionBase() = default;
     106             : 
     107             :   virtual void parseImpl(DWARFContext &Context, const DWARFObject &Obj,
     108             :                          const DWARFSection &Section,
     109             :                          const DWARFDebugAbbrev *DA, const DWARFSection *RS,
     110             :                          StringRef SS, const DWARFSection &SOS,
     111             :                          const DWARFSection *AOS, const DWARFSection &LS,
     112             :                          bool isLittleEndian, bool isDWO, bool Lazy) = 0;
     113             : };
     114             : 
     115             : const DWARFUnitIndex &getDWARFUnitIndex(DWARFContext &Context,
     116             :                                         DWARFSectionKind Kind);
     117             : 
     118             : /// Concrete instance of DWARFUnitSection, specialized for one Unit type.
     119             : template<typename UnitType>
     120        8915 : class DWARFUnitSection final : public SmallVector<std::unique_ptr<UnitType>, 1>,
     121             :                                public DWARFUnitSectionBase {
     122             :   bool Parsed = false;
     123             :   std::function<std::unique_ptr<UnitType>(uint32_t)> Parser;
     124             : 
     125             : public:
     126             :   using UnitVector = SmallVectorImpl<std::unique_ptr<UnitType>>;
     127             :   using iterator = typename UnitVector::iterator;
     128             :   using iterator_range = llvm::iterator_range<typename UnitVector::iterator>;
     129             : 
     130        6219 :   UnitType *getUnitForOffset(uint32_t Offset) const override {
     131             :     auto *CU = std::upper_bound(
     132             :         this->begin(), this->end(), Offset,
     133             :         [](uint32_t LHS, const std::unique_ptr<UnitType> &RHS) {
     134             :           return LHS < RHS->getNextUnitOffset();
     135             :         });
     136       11834 :     if (CU != this->end() && (*CU)->getOffset() <= Offset)
     137             :       return CU->get();
     138             :     return nullptr;
     139             :   }
     140           4 :   UnitType *getUnitForIndexEntry(const DWARFUnitIndex::Entry &E) override {
     141           4 :     const auto *CUOff = E.getOffset(DW_SECT_INFO);
     142           4 :     if (!CUOff)
     143             :       return nullptr;
     144             : 
     145           4 :     auto Offset = CUOff->Offset;
     146             : 
     147             :     auto *CU = std::upper_bound(
     148             :         this->begin(), this->end(), CUOff->Offset,
     149             :         [](uint32_t LHS, const std::unique_ptr<UnitType> &RHS) {
     150             :           return LHS < RHS->getNextUnitOffset();
     151             :         });
     152           4 :     if (CU != this->end() && (*CU)->getOffset() <= Offset)
     153             :       return CU->get();
     154             : 
     155           4 :     if (!Parser)
     156             :       return nullptr;
     157             : 
     158             :     auto U = Parser(Offset);
     159           4 :     if (!U)
     160             :       U = nullptr;
     161             : 
     162             :     auto *NewCU = U.get();
     163           4 :     this->insert(CU, std::move(U));
     164             :     return NewCU;
     165             :   }
     166             : 
     167             : private:
     168        4709 :   void parseImpl(DWARFContext &Context, const DWARFObject &Obj,
     169             :                  const DWARFSection &Section, const DWARFDebugAbbrev *DA,
     170             :                  const DWARFSection *RS, StringRef SS, const DWARFSection &SOS,
     171             :                  const DWARFSection *AOS, const DWARFSection &LS, bool LE,
     172             :                  bool IsDWO, bool Lazy) override {
     173        4709 :     if (Parsed)
     174             :       return;
     175             :     DWARFDataExtractor Data(Obj, Section, LE, 0);
     176        2087 :     if (!Parser) {
     177             :       const DWARFUnitIndex *Index = nullptr;
     178        2072 :       if (IsDWO)
     179         700 :         Index = &getDWARFUnitIndex(Context, UnitType::Section);
     180        2072 :       Parser = [=, &Context, &Section, &SOS,
     181       19772 :                 &LS](uint32_t Offset) -> std::unique_ptr<UnitType> {
     182        9910 :         if (!Data.isValidOffset(Offset))
     183             :           return nullptr;
     184             :         DWARFUnitHeader Header;
     185        9910 :         if (!Header.extract(Context, Data, &Offset, UnitType::Section, Index))
     186             :           return nullptr;
     187        9862 :         auto U = llvm::make_unique<UnitType>(
     188             :             Context, Section, Header, DA, RS, SS, SOS, AOS, LS, LE, IsDWO,
     189        4931 :             *this);
     190             :         return U;
     191             :       };
     192             :     }
     193        2087 :     if (Lazy)
     194             :       return;
     195             :     auto I = this->begin();
     196             :     uint32_t Offset = 0;
     197        6995 :     while (Data.isValidOffset(Offset)) {
     198        4951 :       if (I != this->end() && (*I)->getOffset() == Offset) {
     199           0 :         ++I;
     200           0 :         continue;
     201             :       }
     202             :       auto U = Parser(Offset);
     203        4951 :       if (!U)
     204             :         break;
     205             :       Offset = U->getNextUnitOffset();
     206        4927 :       I = std::next(this->insert(I, std::move(U)));
     207             :     }
     208        2068 :     Parsed = true;
     209             :   }
     210             : };
     211             : 
     212             : /// Represents base address of the CU.
     213             : struct BaseAddress {
     214             :   uint64_t Address;
     215             :   uint64_t SectionIndex;
     216             : };
     217             : 
     218             : /// Represents a unit's contribution to the string offsets table.
     219             : struct StrOffsetsContributionDescriptor {
     220             :   uint64_t Base = 0;
     221             :   /// The contribution size not including the header.
     222             :   uint64_t Size = 0;
     223             :   /// Format and version.
     224             :   dwarf::FormParams FormParams = {0, 0, dwarf::DwarfFormat::DWARF32};
     225             : 
     226             :   StrOffsetsContributionDescriptor(uint64_t Base, uint64_t Size,
     227             :                                    uint8_t Version, dwarf::DwarfFormat Format)
     228             :       : Base(Base), Size(Size), FormParams({Version, 0, Format}) {}
     229             : 
     230             :   uint8_t getVersion() const { return FormParams.Version; }
     231             :   dwarf::DwarfFormat getFormat() const { return FormParams.Format; }
     232             :   uint8_t getDwarfOffsetByteSize() const {
     233        1152 :     return FormParams.getDwarfOffsetByteSize();
     234             :   }
     235             :   /// Determine whether a contribution to the string offsets table is
     236             :   /// consistent with the relevant section size and that its length is
     237             :   /// a multiple of the size of one of its entries.
     238             :   Optional<StrOffsetsContributionDescriptor>
     239             :   validateContributionSize(DWARFDataExtractor &DA);
     240             : };
     241             : 
     242       10452 : class DWARFUnit {
     243             :   DWARFContext &Context;
     244             :   /// Section containing this DWARFUnit.
     245             :   const DWARFSection &InfoSection;
     246             : 
     247             :   DWARFUnitHeader Header;
     248             :   const DWARFDebugAbbrev *Abbrev;
     249             :   const DWARFSection *RangeSection;
     250             :   uint32_t RangeSectionBase;
     251             :   const DWARFSection &LineSection;
     252             :   StringRef StringSection;
     253             :   const DWARFSection &StringOffsetSection;
     254             :   const DWARFSection *AddrOffsetSection;
     255             :   uint32_t AddrOffsetSectionBase = 0;
     256             :   bool isLittleEndian;
     257             :   bool isDWO;
     258             :   const DWARFUnitSectionBase &UnitSection;
     259             : 
     260             :   /// Start, length, and DWARF format of the unit's contribution to the string
     261             :   /// offsets table (DWARF v5).
     262             :   Optional<StrOffsetsContributionDescriptor> StringOffsetsTableContribution;
     263             : 
     264             :   mutable const DWARFAbbreviationDeclarationSet *Abbrevs;
     265             :   llvm::Optional<BaseAddress> BaseAddr;
     266             :   /// The compile unit debug information entry items.
     267             :   std::vector<DWARFDebugInfoEntry> DieArray;
     268             : 
     269             :   /// Map from range's start address to end address and corresponding DIE.
     270             :   /// IntervalMap does not support range removal, as a result, we use the
     271             :   /// std::map::upper_bound for address range lookup.
     272             :   std::map<uint64_t, std::pair<uint64_t, DWARFDie>> AddrDieMap;
     273             : 
     274             :   using die_iterator_range =
     275             :       iterator_range<std::vector<DWARFDebugInfoEntry>::iterator>;
     276             : 
     277             :   std::shared_ptr<DWARFUnit> DWO;
     278             : 
     279             :   uint32_t getDIEIndex(const DWARFDebugInfoEntry *Die) {
     280       45401 :     auto First = DieArray.data();
     281             :     assert(Die >= First && Die < First + DieArray.size());
     282       45401 :     return Die - First;
     283             :   }
     284             : 
     285             : protected:
     286             :   const DWARFUnitHeader &getHeader() const { return Header; }
     287             : 
     288             :   /// Size in bytes of the unit header.
     289       13218 :   virtual uint32_t getHeaderSize() const { return getVersion() <= 4 ? 11 : 12; }
     290             : 
     291             :   /// Find the unit's contribution to the string offsets table and determine its
     292             :   /// length and form. The given offset is expected to be derived from the unit
     293             :   /// DIE's DW_AT_str_offsets_base attribute.
     294             :   Optional<StrOffsetsContributionDescriptor>
     295             :   determineStringOffsetsTableContribution(DWARFDataExtractor &DA,
     296             :                                           uint64_t Offset);
     297             : 
     298             :   /// Find the unit's contribution to the string offsets table and determine its
     299             :   /// length and form. The given offset is expected to be 0 in a dwo file or,
     300             :   /// in a dwp file, the start of the unit's contribution to the string offsets
     301             :   /// table section (as determined by the index table).
     302             :   Optional<StrOffsetsContributionDescriptor>
     303             :   determineStringOffsetsTableContributionDWO(DWARFDataExtractor &DA,
     304             :                                              uint64_t Offset);
     305             : 
     306             : public:
     307             :   DWARFUnit(DWARFContext &Context, const DWARFSection &Section,
     308             :             const DWARFUnitHeader &Header,
     309             :             const DWARFDebugAbbrev *DA, const DWARFSection *RS, StringRef SS,
     310             :             const DWARFSection &SOS, const DWARFSection *AOS,
     311             :             const DWARFSection &LS, bool LE, bool IsDWO,
     312             :             const DWARFUnitSectionBase &UnitSection);
     313             : 
     314             :   virtual ~DWARFUnit();
     315             : 
     316             :   DWARFContext& getContext() const { return Context; }
     317       25061 :   uint32_t getOffset() const { return Header.getOffset(); }
     318             :   const dwarf::FormParams &getFormParams() const {
     319             :     return Header.getFormParams();
     320             :   }
     321       14649 :   uint16_t getVersion() const { return Header.getVersion(); }
     322       84505 :   uint8_t getAddressByteSize() const { return Header.getAddressByteSize(); }
     323             :   uint8_t getRefAddrByteSize() const { return Header.getRefAddrByteSize(); }
     324             :   uint8_t getDwarfOffsetByteSize() const {
     325             :     return Header.getDwarfOffsetByteSize();
     326             :   }
     327         698 :   uint32_t getLength() const { return Header.getLength(); }
     328          54 :   uint8_t getUnitType() const { return Header.getUnitType(); }
     329       25157 :   uint32_t getNextUnitOffset() const { return Header.getNextUnitOffset(); }
     330             :   const DWARFSection &getLineSection() const { return LineSection; }
     331             :   StringRef getStringSection() const { return StringSection; }
     332             :   const DWARFSection &getStringOffsetSection() const {
     333             :     return StringOffsetSection;
     334             :   }
     335             : 
     336             :   void setAddrOffsetSection(const DWARFSection *AOS, uint32_t Base) {
     337          19 :     AddrOffsetSection = AOS;
     338          19 :     AddrOffsetSectionBase = Base;
     339             :   }
     340             : 
     341             :   /// Recursively update address to Die map.
     342             :   void updateAddressDieMap(DWARFDie Die);
     343             : 
     344             :   void setRangesSection(const DWARFSection *RS, uint32_t Base) {
     345          19 :     RangeSection = RS;
     346          19 :     RangeSectionBase = Base;
     347             :   }
     348             : 
     349             :   bool getAddrOffsetSectionItem(uint32_t Index, uint64_t &Result) const;
     350             :   bool getStringOffsetSectionItem(uint32_t Index, uint64_t &Result) const;
     351             : 
     352             :   DWARFDataExtractor getDebugInfoExtractor() const;
     353             : 
     354             :   DataExtractor getStringExtractor() const {
     355             :     return DataExtractor(StringSection, false, 0);
     356             :   }
     357             : 
     358             :   /// extractRangeList - extracts the range list referenced by this compile
     359             :   /// unit from .debug_ranges section. Returns true on success.
     360             :   /// Requires that compile unit is already extracted.
     361             :   bool extractRangeList(uint32_t RangeListOffset,
     362             :                         DWARFDebugRangeList &RangeList) const;
     363             :   void clear();
     364             : 
     365             :   const Optional<StrOffsetsContributionDescriptor> &
     366             :   getStringOffsetsTableContribution() const {
     367          45 :     return StringOffsetsTableContribution;
     368             :   }
     369             : 
     370             :   uint8_t getDwarfStringOffsetsByteSize() const {
     371             :     assert(StringOffsetsTableContribution);
     372             :     return StringOffsetsTableContribution->getDwarfOffsetByteSize();
     373             :   }
     374             : 
     375             :   uint64_t getStringOffsetsBase() const {
     376             :     assert(StringOffsetsTableContribution);
     377        1079 :     return StringOffsetsTableContribution->Base;
     378             :   }
     379             : 
     380             :   const DWARFAbbreviationDeclarationSet *getAbbreviations() const;
     381             : 
     382           4 :   static bool isMatchingUnitTypeAndTag(uint8_t UnitType, dwarf::Tag Tag) {
     383           4 :     switch (UnitType) {
     384           4 :     case dwarf::DW_UT_compile:
     385           4 :       return Tag == dwarf::DW_TAG_compile_unit;
     386           0 :     case dwarf::DW_UT_type:
     387           0 :       return Tag == dwarf::DW_TAG_type_unit;
     388           0 :     case dwarf::DW_UT_partial:
     389           0 :       return Tag == dwarf::DW_TAG_partial_unit;
     390           0 :     case dwarf::DW_UT_skeleton:
     391           0 :       return Tag == dwarf::DW_TAG_skeleton_unit;
     392           0 :     case dwarf::DW_UT_split_compile:
     393             :     case dwarf::DW_UT_split_type:
     394             :       return dwarf::isUnitType(Tag);
     395             :     }
     396             :     return false;
     397             :   }
     398             : 
     399             :   /// Return the number of bytes for the header of a unit of
     400             :   /// UnitType type.
     401             :   ///
     402             :   /// This function must be called with a valid unit type which in
     403             :   /// DWARF5 is defined as one of the following six types.
     404             :   static uint32_t getDWARF5HeaderSize(uint8_t UnitType) {
     405             :     switch (UnitType) {
     406             :     case dwarf::DW_UT_compile:
     407             :     case dwarf::DW_UT_partial:
     408             :       return 12;
     409             :     case dwarf::DW_UT_skeleton:
     410             :     case dwarf::DW_UT_split_compile:
     411             :       return 20;
     412             :     case dwarf::DW_UT_type:
     413             :     case dwarf::DW_UT_split_type:
     414             :       return 24;
     415             :     }
     416             :     llvm_unreachable("Invalid UnitType.");
     417             :   }
     418             : 
     419             :   llvm::Optional<BaseAddress> getBaseAddress() const { return BaseAddr; }
     420             : 
     421             :   void setBaseAddress(BaseAddress BaseAddr) { this->BaseAddr = BaseAddr; }
     422             : 
     423        3819 :   DWARFDie getUnitDIE(bool ExtractUnitDIEOnly = true) {
     424       18313 :     extractDIEsIfNeeded(ExtractUnitDIEOnly);
     425       18313 :     if (DieArray.empty())
     426           0 :       return DWARFDie();
     427        3819 :     return DWARFDie(this, &DieArray[0]);
     428             :   }
     429             : 
     430             :   const char *getCompilationDir();
     431             :   Optional<uint64_t> getDWOId();
     432             : 
     433             :   void collectAddressRanges(DWARFAddressRangesVector &CURanges);
     434             : 
     435             :   /// Returns subprogram DIE with address range encompassing the provided
     436             :   /// address. The pointer is alive as long as parsed compile unit DIEs are not
     437             :   /// cleared.
     438             :   DWARFDie getSubroutineForAddress(uint64_t Address);
     439             : 
     440             :   /// getInlinedChainForAddress - fetches inlined chain for a given address.
     441             :   /// Returns empty chain if there is no subprogram containing address. The
     442             :   /// chain is valid as long as parsed compile unit DIEs are not cleared.
     443             :   void getInlinedChainForAddress(uint64_t Address,
     444             :                                  SmallVectorImpl<DWARFDie> &InlinedChain);
     445             : 
     446             :   /// getUnitSection - Return the DWARFUnitSection containing this unit.
     447             :   const DWARFUnitSectionBase &getUnitSection() const { return UnitSection; }
     448             : 
     449             :   /// Returns the number of DIEs in the unit. Parses the unit
     450             :   /// if necessary.
     451             :   unsigned getNumDIEs() {
     452        1743 :     extractDIEsIfNeeded(false);
     453        3279 :     return DieArray.size();
     454             :   }
     455             : 
     456             :   /// Return the index of a DIE inside the unit's DIE vector.
     457             :   ///
     458             :   /// It is illegal to call this method with a DIE that hasn't be
     459             :   /// created by this unit. In other word, it's illegal to call this
     460             :   /// method on a DIE that isn't accessible by following
     461             :   /// children/sibling links starting from this unit's getUnitDIE().
     462             :   uint32_t getDIEIndex(const DWARFDie &D) {
     463        6551 :     return getDIEIndex(D.getDebugInfoEntry());
     464             :   }
     465             : 
     466             :   /// Return the DIE object at the given index.
     467             :   DWARFDie getDIEAtIndex(unsigned Index) {
     468             :     assert(Index < DieArray.size());
     469        2464 :     return DWARFDie(this, &DieArray[Index]);
     470             :   }
     471             : 
     472             :   DWARFDie getParent(const DWARFDebugInfoEntry *Die);
     473             :   DWARFDie getSibling(const DWARFDebugInfoEntry *Die);
     474             :   DWARFDie getFirstChild(const DWARFDebugInfoEntry *Die);
     475             : 
     476             :   /// Return the DIE object for a given offset inside the
     477             :   /// unit's DIE vector.
     478             :   ///
     479             :   /// The unit needs to have its DIEs extracted for this method to work.
     480        6867 :   DWARFDie getDIEForOffset(uint32_t Offset) {
     481        6867 :     extractDIEsIfNeeded(false);
     482             :     assert(!DieArray.empty());
     483             :     auto it = std::lower_bound(
     484             :         DieArray.begin(), DieArray.end(), Offset,
     485             :         [](const DWARFDebugInfoEntry &LHS, uint32_t Offset) {
     486       29161 :           return LHS.getOffset() < Offset;
     487             :         });
     488        6867 :     if (it != DieArray.end() && it->getOffset() == Offset)
     489        6864 :       return DWARFDie(this, &*it);
     490           3 :     return DWARFDie();
     491             :   }
     492             : 
     493             :   uint32_t getLineTableOffset() const {
     494        3487 :     if (auto IndexEntry = Header.getIndexEntry())
     495          10 :       if (const auto *Contrib = IndexEntry->getOffset(DW_SECT_LINE))
     496          10 :         return Contrib->Offset;
     497             :     return 0;
     498             :   }
     499             : 
     500             :   die_iterator_range dies() {
     501         315 :     extractDIEsIfNeeded(false);
     502             :     return die_iterator_range(DieArray.begin(), DieArray.end());
     503             :   }
     504             : 
     505             : private:
     506             :   /// Size in bytes of the .debug_info data associated with this compile unit.
     507             :   size_t getDebugInfoSize() const {
     508        2107 :     return Header.getLength() + 4 - getHeaderSize();
     509             :   }
     510             : 
     511             :   /// extractDIEsIfNeeded - Parses a compile unit and indexes its DIEs if it
     512             :   /// hasn't already been done. Returns the number of DIEs parsed at this call.
     513             :   size_t extractDIEsIfNeeded(bool CUDieOnly);
     514             : 
     515             :   /// extractDIEsToVector - Appends all parsed DIEs to a vector.
     516             :   void extractDIEsToVector(bool AppendCUDie, bool AppendNonCUDIEs,
     517             :                            std::vector<DWARFDebugInfoEntry> &DIEs) const;
     518             : 
     519             :   /// clearDIEs - Clear parsed DIEs to keep memory usage low.
     520             :   void clearDIEs(bool KeepCUDie);
     521             : 
     522             :   /// parseDWO - Parses .dwo file for current compile unit. Returns true if
     523             :   /// it was actually constructed.
     524             :   bool parseDWO();
     525             : };
     526             : 
     527             : } // end namespace llvm
     528             : 
     529             : #endif // LLVM_DEBUGINFO_DWARF_DWARFUNIT_H

Generated by: LCOV version 1.13