DWARFUnit.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- DWARFUnit.h ----------------------------------------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
  14. #define LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
  15. #include "llvm/ADT/Optional.h"
  16. #include "llvm/ADT/STLExtras.h"
  17. #include "llvm/ADT/SmallVector.h"
  18. #include "llvm/ADT/StringRef.h"
  19. #include "llvm/ADT/iterator_range.h"
  20. #include "llvm/BinaryFormat/Dwarf.h"
  21. #include "llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h"
  22. #include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
  23. #include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
  24. #include "llvm/DebugInfo/DWARF/DWARFDebugRnglists.h"
  25. #include "llvm/DebugInfo/DWARF/DWARFDie.h"
  26. #include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
  27. #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
  28. #include "llvm/DebugInfo/DWARF/DWARFSection.h"
  29. #include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
  30. #include "llvm/Support/DataExtractor.h"
  31. #include <algorithm>
  32. #include <cassert>
  33. #include <cstddef>
  34. #include <cstdint>
  35. #include <map>
  36. #include <memory>
  37. #include <utility>
  38. #include <vector>
  39. namespace llvm {
  40. class DWARFAbbreviationDeclarationSet;
  41. class DWARFContext;
  42. class DWARFDebugAbbrev;
  43. class DWARFUnit;
  44. /// Base class describing the header of any kind of "unit." Some information
  45. /// is specific to certain unit types. We separate this class out so we can
  46. /// parse the header before deciding what specific kind of unit to construct.
  47. class DWARFUnitHeader {
  48. // Offset within section.
  49. uint64_t Offset = 0;
  50. // Version, address size, and DWARF format.
  51. dwarf::FormParams FormParams;
  52. uint64_t Length = 0;
  53. uint64_t AbbrOffset = 0;
  54. // For DWO units only.
  55. const DWARFUnitIndex::Entry *IndexEntry = nullptr;
  56. // For type units only.
  57. uint64_t TypeHash = 0;
  58. uint64_t TypeOffset = 0;
  59. // For v5 split or skeleton compile units only.
  60. Optional<uint64_t> DWOId;
  61. // Unit type as parsed, or derived from the section kind.
  62. uint8_t UnitType = 0;
  63. // Size as parsed. uint8_t for compactness.
  64. uint8_t Size = 0;
  65. public:
  66. /// Parse a unit header from \p debug_info starting at \p offset_ptr.
  67. /// Note that \p SectionKind is used as a hint to guess the unit type
  68. /// for DWARF formats prior to DWARFv5. In DWARFv5 the unit type is
  69. /// explicitly defined in the header and the hint is ignored.
  70. bool extract(DWARFContext &Context, const DWARFDataExtractor &debug_info,
  71. uint64_t *offset_ptr, DWARFSectionKind SectionKind);
  72. // For units in DWARF Package File, remember the index entry and update
  73. // the abbreviation offset read by extract().
  74. bool applyIndexEntry(const DWARFUnitIndex::Entry *Entry);
  75. uint64_t getOffset() const { return Offset; }
  76. const dwarf::FormParams &getFormParams() const { return FormParams; }
  77. uint16_t getVersion() const { return FormParams.Version; }
  78. dwarf::DwarfFormat getFormat() const { return FormParams.Format; }
  79. uint8_t getAddressByteSize() const { return FormParams.AddrSize; }
  80. uint8_t getRefAddrByteSize() const { return FormParams.getRefAddrByteSize(); }
  81. uint8_t getDwarfOffsetByteSize() const {
  82. return FormParams.getDwarfOffsetByteSize();
  83. }
  84. uint64_t getLength() const { return Length; }
  85. uint64_t getAbbrOffset() const { return AbbrOffset; }
  86. Optional<uint64_t> getDWOId() const { return DWOId; }
  87. void setDWOId(uint64_t Id) {
  88. assert((!DWOId || *DWOId == Id) && "setting DWOId to a different value");
  89. DWOId = Id;
  90. }
  91. const DWARFUnitIndex::Entry *getIndexEntry() const { return IndexEntry; }
  92. uint64_t getTypeHash() const { return TypeHash; }
  93. uint64_t getTypeOffset() const { return TypeOffset; }
  94. uint8_t getUnitType() const { return UnitType; }
  95. bool isTypeUnit() const {
  96. return UnitType == dwarf::DW_UT_type || UnitType == dwarf::DW_UT_split_type;
  97. }
  98. uint8_t getSize() const { return Size; }
  99. uint8_t getUnitLengthFieldByteSize() const {
  100. return dwarf::getUnitLengthFieldByteSize(FormParams.Format);
  101. }
  102. uint64_t getNextUnitOffset() const {
  103. return Offset + Length + getUnitLengthFieldByteSize();
  104. }
  105. };
  106. const DWARFUnitIndex &getDWARFUnitIndex(DWARFContext &Context,
  107. DWARFSectionKind Kind);
  108. bool isCompileUnit(const std::unique_ptr<DWARFUnit> &U);
  109. /// Describe a collection of units. Intended to hold all units either from
  110. /// .debug_info and .debug_types, or from .debug_info.dwo and .debug_types.dwo.
  111. class DWARFUnitVector final : public SmallVector<std::unique_ptr<DWARFUnit>, 1> {
  112. std::function<std::unique_ptr<DWARFUnit>(uint64_t, DWARFSectionKind,
  113. const DWARFSection *,
  114. const DWARFUnitIndex::Entry *)>
  115. Parser;
  116. int NumInfoUnits = -1;
  117. public:
  118. using UnitVector = SmallVectorImpl<std::unique_ptr<DWARFUnit>>;
  119. using iterator = typename UnitVector::iterator;
  120. using iterator_range = llvm::iterator_range<typename UnitVector::iterator>;
  121. using compile_unit_range =
  122. decltype(make_filter_range(std::declval<iterator_range>(), isCompileUnit));
  123. DWARFUnit *getUnitForOffset(uint64_t Offset) const;
  124. DWARFUnit *getUnitForIndexEntry(const DWARFUnitIndex::Entry &E);
  125. /// Read units from a .debug_info or .debug_types section. Calls made
  126. /// before finishedInfoUnits() are assumed to be for .debug_info sections,
  127. /// calls after finishedInfoUnits() are for .debug_types sections. Caller
  128. /// must not mix calls to addUnitsForSection and addUnitsForDWOSection.
  129. void addUnitsForSection(DWARFContext &C, const DWARFSection &Section,
  130. DWARFSectionKind SectionKind);
  131. /// Read units from a .debug_info.dwo or .debug_types.dwo section. Calls
  132. /// made before finishedInfoUnits() are assumed to be for .debug_info.dwo
  133. /// sections, calls after finishedInfoUnits() are for .debug_types.dwo
  134. /// sections. Caller must not mix calls to addUnitsForSection and
  135. /// addUnitsForDWOSection.
  136. void addUnitsForDWOSection(DWARFContext &C, const DWARFSection &DWOSection,
  137. DWARFSectionKind SectionKind, bool Lazy = false);
  138. /// Add an existing DWARFUnit to this UnitVector. This is used by the DWARF
  139. /// verifier to process unit separately.
  140. DWARFUnit *addUnit(std::unique_ptr<DWARFUnit> Unit);
  141. /// Returns number of all units held by this instance.
  142. unsigned getNumUnits() const { return size(); }
  143. /// Returns number of units from all .debug_info[.dwo] sections.
  144. unsigned getNumInfoUnits() const {
  145. return NumInfoUnits == -1 ? size() : NumInfoUnits;
  146. }
  147. /// Returns number of units from all .debug_types[.dwo] sections.
  148. unsigned getNumTypesUnits() const { return size() - NumInfoUnits; }
  149. /// Indicate that parsing .debug_info[.dwo] is done, and remaining units
  150. /// will be from .debug_types[.dwo].
  151. void finishedInfoUnits() { NumInfoUnits = size(); }
  152. private:
  153. void addUnitsImpl(DWARFContext &Context, const DWARFObject &Obj,
  154. const DWARFSection &Section, const DWARFDebugAbbrev *DA,
  155. const DWARFSection *RS, const DWARFSection *LocSection,
  156. StringRef SS, const DWARFSection &SOS,
  157. const DWARFSection *AOS, const DWARFSection &LS, bool LE,
  158. bool IsDWO, bool Lazy, DWARFSectionKind SectionKind);
  159. };
  160. /// Represents base address of the CU.
  161. /// Represents a unit's contribution to the string offsets table.
  162. struct StrOffsetsContributionDescriptor {
  163. uint64_t Base = 0;
  164. /// The contribution size not including the header.
  165. uint64_t Size = 0;
  166. /// Format and version.
  167. dwarf::FormParams FormParams = {0, 0, dwarf::DwarfFormat::DWARF32};
  168. StrOffsetsContributionDescriptor(uint64_t Base, uint64_t Size,
  169. uint8_t Version, dwarf::DwarfFormat Format)
  170. : Base(Base), Size(Size), FormParams({Version, 0, Format}) {}
  171. StrOffsetsContributionDescriptor() = default;
  172. uint8_t getVersion() const { return FormParams.Version; }
  173. dwarf::DwarfFormat getFormat() const { return FormParams.Format; }
  174. uint8_t getDwarfOffsetByteSize() const {
  175. return FormParams.getDwarfOffsetByteSize();
  176. }
  177. /// Determine whether a contribution to the string offsets table is
  178. /// consistent with the relevant section size and that its length is
  179. /// a multiple of the size of one of its entries.
  180. Expected<StrOffsetsContributionDescriptor>
  181. validateContributionSize(DWARFDataExtractor &DA);
  182. };
  183. class DWARFUnit {
  184. DWARFContext &Context;
  185. /// Section containing this DWARFUnit.
  186. const DWARFSection &InfoSection;
  187. DWARFUnitHeader Header;
  188. const DWARFDebugAbbrev *Abbrev;
  189. const DWARFSection *RangeSection;
  190. uint64_t RangeSectionBase;
  191. uint64_t LocSectionBase;
  192. /// Location table of this unit.
  193. std::unique_ptr<DWARFLocationTable> LocTable;
  194. const DWARFSection &LineSection;
  195. StringRef StringSection;
  196. const DWARFSection &StringOffsetSection;
  197. const DWARFSection *AddrOffsetSection;
  198. Optional<uint64_t> AddrOffsetSectionBase;
  199. bool isLittleEndian;
  200. bool IsDWO;
  201. const DWARFUnitVector &UnitVector;
  202. /// Start, length, and DWARF format of the unit's contribution to the string
  203. /// offsets table (DWARF v5).
  204. Optional<StrOffsetsContributionDescriptor> StringOffsetsTableContribution;
  205. mutable const DWARFAbbreviationDeclarationSet *Abbrevs;
  206. llvm::Optional<object::SectionedAddress> BaseAddr;
  207. /// The compile unit debug information entry items.
  208. std::vector<DWARFDebugInfoEntry> DieArray;
  209. /// Map from range's start address to end address and corresponding DIE.
  210. /// IntervalMap does not support range removal, as a result, we use the
  211. /// std::map::upper_bound for address range lookup.
  212. std::map<uint64_t, std::pair<uint64_t, DWARFDie>> AddrDieMap;
  213. using die_iterator_range =
  214. iterator_range<std::vector<DWARFDebugInfoEntry>::iterator>;
  215. std::shared_ptr<DWARFUnit> DWO;
  216. uint32_t getDIEIndex(const DWARFDebugInfoEntry *Die) {
  217. auto First = DieArray.data();
  218. assert(Die >= First && Die < First + DieArray.size());
  219. return Die - First;
  220. }
  221. protected:
  222. const DWARFUnitHeader &getHeader() const { return Header; }
  223. /// Size in bytes of the parsed unit header.
  224. uint32_t getHeaderSize() const { return Header.getSize(); }
  225. /// Find the unit's contribution to the string offsets table and determine its
  226. /// length and form. The given offset is expected to be derived from the unit
  227. /// DIE's DW_AT_str_offsets_base attribute.
  228. Expected<Optional<StrOffsetsContributionDescriptor>>
  229. determineStringOffsetsTableContribution(DWARFDataExtractor &DA);
  230. /// Find the unit's contribution to the string offsets table and determine its
  231. /// length and form. The given offset is expected to be 0 in a dwo file or,
  232. /// in a dwp file, the start of the unit's contribution to the string offsets
  233. /// table section (as determined by the index table).
  234. Expected<Optional<StrOffsetsContributionDescriptor>>
  235. determineStringOffsetsTableContributionDWO(DWARFDataExtractor &DA);
  236. public:
  237. DWARFUnit(DWARFContext &Context, const DWARFSection &Section,
  238. const DWARFUnitHeader &Header, const DWARFDebugAbbrev *DA,
  239. const DWARFSection *RS, const DWARFSection *LocSection,
  240. StringRef SS, const DWARFSection &SOS, const DWARFSection *AOS,
  241. const DWARFSection &LS, bool LE, bool IsDWO,
  242. const DWARFUnitVector &UnitVector);
  243. virtual ~DWARFUnit();
  244. bool isDWOUnit() const { return IsDWO; }
  245. DWARFContext& getContext() const { return Context; }
  246. const DWARFSection &getInfoSection() const { return InfoSection; }
  247. uint64_t getOffset() const { return Header.getOffset(); }
  248. const dwarf::FormParams &getFormParams() const {
  249. return Header.getFormParams();
  250. }
  251. uint16_t getVersion() const { return Header.getVersion(); }
  252. uint8_t getAddressByteSize() const { return Header.getAddressByteSize(); }
  253. uint8_t getRefAddrByteSize() const { return Header.getRefAddrByteSize(); }
  254. uint8_t getDwarfOffsetByteSize() const {
  255. return Header.getDwarfOffsetByteSize();
  256. }
  257. uint64_t getLength() const { return Header.getLength(); }
  258. dwarf::DwarfFormat getFormat() const { return Header.getFormat(); }
  259. uint8_t getUnitType() const { return Header.getUnitType(); }
  260. bool isTypeUnit() const { return Header.isTypeUnit(); }
  261. uint64_t getAbbrOffset() const { return Header.getAbbrOffset(); }
  262. uint64_t getNextUnitOffset() const { return Header.getNextUnitOffset(); }
  263. const DWARFSection &getLineSection() const { return LineSection; }
  264. StringRef getStringSection() const { return StringSection; }
  265. const DWARFSection &getStringOffsetSection() const {
  266. return StringOffsetSection;
  267. }
  268. void setAddrOffsetSection(const DWARFSection *AOS, uint64_t Base) {
  269. AddrOffsetSection = AOS;
  270. AddrOffsetSectionBase = Base;
  271. }
  272. /// Recursively update address to Die map.
  273. void updateAddressDieMap(DWARFDie Die);
  274. void setRangesSection(const DWARFSection *RS, uint64_t Base) {
  275. RangeSection = RS;
  276. RangeSectionBase = Base;
  277. }
  278. uint64_t getLocSectionBase() const {
  279. return LocSectionBase;
  280. }
  281. Optional<object::SectionedAddress>
  282. getAddrOffsetSectionItem(uint32_t Index) const;
  283. Optional<uint64_t> getStringOffsetSectionItem(uint32_t Index) const;
  284. DWARFDataExtractor getDebugInfoExtractor() const;
  285. DataExtractor getStringExtractor() const {
  286. return DataExtractor(StringSection, false, 0);
  287. }
  288. const DWARFLocationTable &getLocationTable() { return *LocTable; }
  289. /// Extract the range list referenced by this compile unit from the
  290. /// .debug_ranges section. If the extraction is unsuccessful, an error
  291. /// is returned. Successful extraction requires that the compile unit
  292. /// has already been extracted.
  293. Error extractRangeList(uint64_t RangeListOffset,
  294. DWARFDebugRangeList &RangeList) const;
  295. void clear();
  296. const Optional<StrOffsetsContributionDescriptor> &
  297. getStringOffsetsTableContribution() const {
  298. return StringOffsetsTableContribution;
  299. }
  300. uint8_t getDwarfStringOffsetsByteSize() const {
  301. assert(StringOffsetsTableContribution);
  302. return StringOffsetsTableContribution->getDwarfOffsetByteSize();
  303. }
  304. uint64_t getStringOffsetsBase() const {
  305. assert(StringOffsetsTableContribution);
  306. return StringOffsetsTableContribution->Base;
  307. }
  308. const DWARFAbbreviationDeclarationSet *getAbbreviations() const;
  309. static bool isMatchingUnitTypeAndTag(uint8_t UnitType, dwarf::Tag Tag) {
  310. switch (UnitType) {
  311. case dwarf::DW_UT_compile:
  312. return Tag == dwarf::DW_TAG_compile_unit;
  313. case dwarf::DW_UT_type:
  314. return Tag == dwarf::DW_TAG_type_unit;
  315. case dwarf::DW_UT_partial:
  316. return Tag == dwarf::DW_TAG_partial_unit;
  317. case dwarf::DW_UT_skeleton:
  318. return Tag == dwarf::DW_TAG_skeleton_unit;
  319. case dwarf::DW_UT_split_compile:
  320. case dwarf::DW_UT_split_type:
  321. return dwarf::isUnitType(Tag);
  322. }
  323. return false;
  324. }
  325. llvm::Optional<object::SectionedAddress> getBaseAddress();
  326. DWARFDie getUnitDIE(bool ExtractUnitDIEOnly = true) {
  327. extractDIEsIfNeeded(ExtractUnitDIEOnly);
  328. if (DieArray.empty())
  329. return DWARFDie();
  330. return DWARFDie(this, &DieArray[0]);
  331. }
  332. DWARFDie getNonSkeletonUnitDIE(bool ExtractUnitDIEOnly = true) {
  333. parseDWO();
  334. if (DWO)
  335. return DWO->getUnitDIE(ExtractUnitDIEOnly);
  336. return getUnitDIE(ExtractUnitDIEOnly);
  337. }
  338. const char *getCompilationDir();
  339. Optional<uint64_t> getDWOId() {
  340. extractDIEsIfNeeded(/*CUDieOnly*/ true);
  341. return getHeader().getDWOId();
  342. }
  343. void setDWOId(uint64_t NewID) { Header.setDWOId(NewID); }
  344. /// Return a vector of address ranges resulting from a (possibly encoded)
  345. /// range list starting at a given offset in the appropriate ranges section.
  346. Expected<DWARFAddressRangesVector> findRnglistFromOffset(uint64_t Offset);
  347. /// Return a vector of address ranges retrieved from an encoded range
  348. /// list whose offset is found via a table lookup given an index (DWARF v5
  349. /// and later).
  350. Expected<DWARFAddressRangesVector> findRnglistFromIndex(uint32_t Index);
  351. /// Return a rangelist's offset based on an index. The index designates
  352. /// an entry in the rangelist table's offset array and is supplied by
  353. /// DW_FORM_rnglistx.
  354. Optional<uint64_t> getRnglistOffset(uint32_t Index);
  355. Optional<uint64_t> getLoclistOffset(uint32_t Index);
  356. Expected<DWARFAddressRangesVector> collectAddressRanges();
  357. Expected<DWARFLocationExpressionsVector>
  358. findLoclistFromOffset(uint64_t Offset);
  359. /// Returns subprogram DIE with address range encompassing the provided
  360. /// address. The pointer is alive as long as parsed compile unit DIEs are not
  361. /// cleared.
  362. DWARFDie getSubroutineForAddress(uint64_t Address);
  363. /// getInlinedChainForAddress - fetches inlined chain for a given address.
  364. /// Returns empty chain if there is no subprogram containing address. The
  365. /// chain is valid as long as parsed compile unit DIEs are not cleared.
  366. void getInlinedChainForAddress(uint64_t Address,
  367. SmallVectorImpl<DWARFDie> &InlinedChain);
  368. /// Return the DWARFUnitVector containing this unit.
  369. const DWARFUnitVector &getUnitVector() const { return UnitVector; }
  370. /// Returns the number of DIEs in the unit. Parses the unit
  371. /// if necessary.
  372. unsigned getNumDIEs() {
  373. extractDIEsIfNeeded(false);
  374. return DieArray.size();
  375. }
  376. /// Return the index of a DIE inside the unit's DIE vector.
  377. ///
  378. /// It is illegal to call this method with a DIE that hasn't be
  379. /// created by this unit. In other word, it's illegal to call this
  380. /// method on a DIE that isn't accessible by following
  381. /// children/sibling links starting from this unit's getUnitDIE().
  382. uint32_t getDIEIndex(const DWARFDie &D) {
  383. return getDIEIndex(D.getDebugInfoEntry());
  384. }
  385. /// Return the DIE object at the given index.
  386. DWARFDie getDIEAtIndex(unsigned Index) {
  387. assert(Index < DieArray.size());
  388. return DWARFDie(this, &DieArray[Index]);
  389. }
  390. DWARFDie getParent(const DWARFDebugInfoEntry *Die);
  391. DWARFDie getSibling(const DWARFDebugInfoEntry *Die);
  392. DWARFDie getPreviousSibling(const DWARFDebugInfoEntry *Die);
  393. DWARFDie getFirstChild(const DWARFDebugInfoEntry *Die);
  394. DWARFDie getLastChild(const DWARFDebugInfoEntry *Die);
  395. /// Return the DIE object for a given offset inside the
  396. /// unit's DIE vector.
  397. ///
  398. /// The unit needs to have its DIEs extracted for this method to work.
  399. DWARFDie getDIEForOffset(uint64_t Offset) {
  400. extractDIEsIfNeeded(false);
  401. auto It =
  402. llvm::partition_point(DieArray, [=](const DWARFDebugInfoEntry &DIE) {
  403. return DIE.getOffset() < Offset;
  404. });
  405. if (It != DieArray.end() && It->getOffset() == Offset)
  406. return DWARFDie(this, &*It);
  407. return DWARFDie();
  408. }
  409. uint32_t getLineTableOffset() const {
  410. if (auto IndexEntry = Header.getIndexEntry())
  411. if (const auto *Contrib = IndexEntry->getContribution(DW_SECT_LINE))
  412. return Contrib->Offset;
  413. return 0;
  414. }
  415. die_iterator_range dies() {
  416. extractDIEsIfNeeded(false);
  417. return die_iterator_range(DieArray.begin(), DieArray.end());
  418. }
  419. virtual void dump(raw_ostream &OS, DIDumpOptions DumpOpts) = 0;
  420. Error tryExtractDIEsIfNeeded(bool CUDieOnly);
  421. private:
  422. /// Size in bytes of the .debug_info data associated with this compile unit.
  423. size_t getDebugInfoSize() const {
  424. return Header.getLength() + Header.getUnitLengthFieldByteSize() -
  425. getHeaderSize();
  426. }
  427. /// extractDIEsIfNeeded - Parses a compile unit and indexes its DIEs if it
  428. /// hasn't already been done
  429. void extractDIEsIfNeeded(bool CUDieOnly);
  430. /// extractDIEsToVector - Appends all parsed DIEs to a vector.
  431. void extractDIEsToVector(bool AppendCUDie, bool AppendNonCUDIEs,
  432. std::vector<DWARFDebugInfoEntry> &DIEs) const;
  433. /// clearDIEs - Clear parsed DIEs to keep memory usage low.
  434. void clearDIEs(bool KeepCUDie);
  435. /// parseDWO - Parses .dwo file for current compile unit. Returns true if
  436. /// it was actually constructed.
  437. bool parseDWO();
  438. };
  439. inline bool isCompileUnit(const std::unique_ptr<DWARFUnit> &U) {
  440. return !U->isTypeUnit();
  441. }
  442. } // end namespace llvm
  443. #endif // LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
  444. #ifdef __GNUC__
  445. #pragma GCC diagnostic pop
  446. #endif