llvm.org GIT mirror llvm / 55a0ed2
[DebugInfo/DWARF] [1/4] De-templatize DWARFUnitSection. NFC This is patch 1 of 4 NFC refactorings to handle type units and compile units more consistently and with less concern about the object-file section that they came from. Patch 1 replaces the templated DWARFUnitSection with a non-templated version. That is, instead of being a SmallVector of pointers to a specific unit kind, it is not a SmallVector of pointers to the base class for both type and compile units. Virtual methods are magic. Differential Revision: https://reviews.llvm.org/D49741 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338628 91177308-0d34-0410-b5e6-96231b3b80d8 Paul Robinson 1 year, 2 months ago
10 changed file(s) with 183 addition(s) and 170 deletion(s). Raw diff Collapse all Expand all
2121 const DWARFDebugAbbrev *DA, const DWARFSection *RS,
2222 StringRef SS, const DWARFSection &SOS,
2323 const DWARFSection *AOS, const DWARFSection &LS, bool LE,
24 bool IsDWO, const DWARFUnitSectionBase &UnitSection)
24 bool IsDWO, const DWARFUnitSection &UnitSection)
2525 : DWARFUnit(Context, Section, Header, DA, RS, SS, SOS, AOS, LS, LE, IsDWO,
2626 UnitSection) {}
2727
28 // VTable anchor.
28 /// VTable anchor.
2929 ~DWARFCompileUnit() override;
30
31 void dump(raw_ostream &OS, DIDumpOptions DumpOpts);
32
33 static const DWARFSectionKind Section = DW_SECT_INFO;
30 /// Dump this compile unit to \p OS.
31 void dump(raw_ostream &OS, DIDumpOptions DumpOpts) override;
32 /// Enable LLVM-style RTTI.
33 static bool classof(const DWARFUnit *U) { return !U->isTypeUnit(); }
3434 };
3535
3636 } // end namespace llvm
5656 /// This data structure is the top level entity that deals with dwarf debug
5757 /// information parsing. The actual data is supplied through DWARFObj.
5858 class DWARFContext : public DIContext {
59 DWARFUnitSection CUs;
60 std::deque> TUs;
59 DWARFUnitSection CUs;
60 std::deque TUs;
6161 std::unique_ptr CUIndex;
6262 std::unique_ptr GdbIndex;
6363 std::unique_ptr TUIndex;
7474 std::unique_ptr AppleNamespaces;
7575 std::unique_ptr AppleObjC;
7676
77 DWARFUnitSection DWOCUs;
78 std::deque> DWOTUs;
77 DWARFUnitSection DWOCUs;
78 std::deque DWOTUs;
7979 std::unique_ptr AbbrevDWO;
8080 std::unique_ptr LocDWO;
8181
138138
139139 bool verify(raw_ostream &OS, DIDumpOptions DumpOpts = {}) override;
140140
141 using cu_iterator_range = DWARFUnitSection::iterator_range;
142 using tu_iterator_range = DWARFUnitSection::iterator_range;
141 using cu_iterator_range = DWARFUnitSection::iterator_range;
142 using tu_iterator_range = DWARFUnitSection::iterator_range;
143143 using tu_section_iterator_range = iterator_range;
144144
145145 /// Get compile units in this context.
190190 return DWOTUs.size();
191191 }
192192
193 /// Get the compile unit at the specified index for this compile unit.
194 DWARFCompileUnit *getCompileUnitAtIndex(unsigned index) {
193 /// Get the unit at the specified index.
194 DWARFUnit *getUnitAtIndex(unsigned index) {
195195 parseCompileUnits();
196196 return CUs[index].get();
197197 }
198198
199 /// Get the compile unit at the specified index for the DWO compile units.
200 DWARFCompileUnit *getDWOCompileUnitAtIndex(unsigned index) {
199 /// Get the unit at the specified index for the DWO units.
200 DWARFUnit *getDWOUnitAtIndex(unsigned index) {
201201 parseDWOCompileUnits();
202202 return DWOCUs[index].get();
203203 }
277277 /// Helper to allow for parsing of an entire .debug_line section in sequence.
278278 class SectionParser {
279279 public:
280 using cu_range = DWARFUnitSection::iterator_range;
281 using tu_range =
282 iterator_range>::iterator>;
280 using cu_range = DWARFUnitSection::iterator_range;
281 using tu_range = iterator_range::iterator>;
283282 using LineToUnitMap = std::map;
284283
285284 SectionParser(DWARFDataExtractor &Data, const DWARFContext &C, cu_range CUs,
2929 const DWARFDebugAbbrev *DA, const DWARFSection *RS,
3030 StringRef SS, const DWARFSection &SOS, const DWARFSection *AOS,
3131 const DWARFSection &LS, bool LE, bool IsDWO,
32 const DWARFUnitSectionBase &UnitSection)
32 const DWARFUnitSection &UnitSection)
3333 : DWARFUnit(Context, Section, Header, DA, RS, SS, SOS, AOS, LS, LE, IsDWO,
3434 UnitSection) {}
3535
3636 uint64_t getTypeHash() const { return getHeader().getTypeHash(); }
3737 uint32_t getTypeOffset() const { return getHeader().getTypeOffset(); }
3838
39 void dump(raw_ostream &OS, DIDumpOptions DumpOpts = {});
40 static const DWARFSectionKind Section = DW_SECT_TYPES;
39 void dump(raw_ostream &OS, DIDumpOptions DumpOpts = {}) override;
40 // Enable LLVM-style RTTI.
41 static bool classof(const DWARFUnit *U) { return U->isTypeUnit(); }
4142 };
4243
4344 } // end namespace llvm
100100 uint32_t getNextUnitOffset() const { return Offset + Length + 4; }
101101 };
102102
103 /// Base class for all DWARFUnitSection classes. This provides the
104 /// functionality common to all unit types.
105 class DWARFUnitSectionBase {
106 public:
107 /// Returns the Unit that contains the given section offset in the
108 /// same section this Unit originated from.
109 virtual DWARFUnit *getUnitForOffset(uint32_t Offset) const = 0;
110 virtual DWARFUnit *getUnitForIndexEntry(const DWARFUnitIndex::Entry &E) = 0;
111
112 void parse(DWARFContext &C, const DWARFSection &Section);
113 void parseDWO(DWARFContext &C, const DWARFSection &DWOSection,
114 bool Lazy = false);
115
116 protected:
117 ~DWARFUnitSectionBase() = default;
118
119 virtual void parseImpl(DWARFContext &Context, const DWARFObject &Obj,
120 const DWARFSection &Section,
121 const DWARFDebugAbbrev *DA, const DWARFSection *RS,
122 StringRef SS, const DWARFSection &SOS,
123 const DWARFSection *AOS, const DWARFSection &LS,
124 bool isLittleEndian, bool isDWO, bool Lazy) = 0;
125 };
126
127103 const DWARFUnitIndex &getDWARFUnitIndex(DWARFContext &Context,
128104 DWARFSectionKind Kind);
129105
130 /// Concrete instance of DWARFUnitSection, specialized for one Unit type.
131 template
132 class DWARFUnitSection final : public SmallVector, 1>,
133 public DWARFUnitSectionBase {
106 /// Describes one section's Units.
107 class DWARFUnitSection final : public SmallVector, 1> {
134108 bool Parsed = false;
135 std::functionUnitType>(uint32_t)> Parser;
109 std::functionDWARFUnit>(uint32_t)> Parser;
136110
137111 public:
138 using UnitVector = SmallVectorImplUnitType>>;
112 using UnitVector = SmallVectorImplDWARFUnit>>;
139113 using iterator = typename UnitVector::iterator;
140114 using iterator_range = llvm::iterator_range;
141115
142 UnitType *getUnitForOffset(uint32_t Offset) const override {
143 auto *CU = std::upper_bound(
144 this->begin(), this->end(), Offset,
145 [](uint32_t LHS, const std::unique_ptr &RHS) {
146 return LHS < RHS->getNextUnitOffset();
147 });
148 if (CU != this->end() && (*CU)->getOffset() <= Offset)
149 return CU->get();
150 return nullptr;
151 }
152 UnitType *getUnitForIndexEntry(const DWARFUnitIndex::Entry &E) override {
153 const auto *CUOff = E.getOffset(DW_SECT_INFO);
154 if (!CUOff)
155 return nullptr;
156
157 auto Offset = CUOff->Offset;
158
159 auto *CU = std::upper_bound(
160 this->begin(), this->end(), CUOff->Offset,
161 [](uint32_t LHS, const std::unique_ptr &RHS) {
162 return LHS < RHS->getNextUnitOffset();
163 });
164 if (CU != this->end() && (*CU)->getOffset() <= Offset)
165 return CU->get();
166
167 if (!Parser)
168 return nullptr;
169
170 auto U = Parser(Offset);
171 if (!U)
172 U = nullptr;
173
174 auto *NewCU = U.get();
175 this->insert(CU, std::move(U));
176 return NewCU;
177 }
178
116 DWARFUnit *getUnitForOffset(uint32_t Offset) const;
117 DWARFUnit *getUnitForIndexEntry(const DWARFUnitIndex::Entry &E);
118 void parse(DWARFContext &C, const DWARFSection &Section,
119 DWARFSectionKind SectionKind);
120 void parseDWO(DWARFContext &C, const DWARFSection &DWOSection,
121 DWARFSectionKind SectionKind, bool Lazy = false);
179122 private:
180123 void parseImpl(DWARFContext &Context, const DWARFObject &Obj,
181124 const DWARFSection &Section, const DWARFDebugAbbrev *DA,
182125 const DWARFSection *RS, StringRef SS, const DWARFSection &SOS,
183126 const DWARFSection *AOS, const DWARFSection &LS, bool LE,
184 bool IsDWO, bool Lazy) override {
185 if (Parsed)
186 return;
187 DWARFDataExtractor Data(Obj, Section, LE, 0);
188 if (!Parser) {
189 const DWARFUnitIndex *Index = nullptr;
190 if (IsDWO)
191 Index = &getDWARFUnitIndex(Context, UnitType::Section);
192 Parser = [=, &Context, &Section, &SOS,
193 &LS](uint32_t Offset) -> std::unique_ptr {
194 if (!Data.isValidOffset(Offset))
195 return nullptr;
196 DWARFUnitHeader Header;
197 if (!Header.extract(Context, Data, &Offset, UnitType::Section, Index))
198 return nullptr;
199 auto U = llvm::make_unique(
200 Context, Section, Header, DA, RS, SS, SOS, AOS, LS, LE, IsDWO,
201 *this);
202 return U;
203 };
204 }
205 if (Lazy)
206 return;
207 auto I = this->begin();
208 uint32_t Offset = 0;
209 while (Data.isValidOffset(Offset)) {
210 if (I != this->end() && (*I)->getOffset() == Offset) {
211 ++I;
212 continue;
213 }
214 auto U = Parser(Offset);
215 if (!U)
216 break;
217 Offset = U->getNextUnitOffset();
218 I = std::next(this->insert(I, std::move(U)));
219 }
220 Parsed = true;
221 }
127 bool IsDWO, bool Lazy, DWARFSectionKind SectionKind);
222128 };
223129
224130 /// Represents base address of the CU.
267173 uint32_t AddrOffsetSectionBase = 0;
268174 bool isLittleEndian;
269175 bool isDWO;
270 const DWARFUnitSectionBase &UnitSection;
176 const DWARFUnitSection &UnitSection;
271177
272178 /// Start, length, and DWARF format of the unit's contribution to the string
273179 /// offsets table (DWARF v5).
324230 const DWARFDebugAbbrev *DA, const DWARFSection *RS, StringRef SS,
325231 const DWARFSection &SOS, const DWARFSection *AOS,
326232 const DWARFSection &LS, bool LE, bool IsDWO,
327 const DWARFUnitSectionBase &UnitSection);
233 const DWARFUnitSection &UnitSection);
328234
329235 virtual ~DWARFUnit();
330236
341247 }
342248 uint32_t getLength() const { return Header.getLength(); }
343249 uint8_t getUnitType() const { return Header.getUnitType(); }
250 bool isTypeUnit() const { return Header.isTypeUnit(); }
344251 uint32_t getNextUnitOffset() const { return Header.getNextUnitOffset(); }
345252 const DWARFSection &getLineSection() const { return LineSection; }
346253 StringRef getStringSection() const { return StringSection; }
480387 SmallVectorImpl &InlinedChain);
481388
482389 /// getUnitSection - Return the DWARFUnitSection containing this unit.
483 const DWARFUnitSectionBase &getUnitSection() const { return UnitSection; }
390 const DWARFUnitSection &getUnitSection() const { return UnitSection; }
484391
485392 /// Returns the number of DIEs in the unit. Parses the unit
486393 /// if necessary.
540447 return die_iterator_range(DieArray.begin(), DieArray.end());
541448 }
542449
450 virtual void dump(raw_ostream &OS, DIDumpOptions DumpOpts) = 0;
543451 private:
544452 /// Size in bytes of the .debug_info data associated with this compile unit.
545453 size_t getDebugInfoSize() const {
583583 }
584584
585585 DWARFCompileUnit *DWARFContext::getDWOCompileUnitForHash(uint64_t Hash) {
586 DWOCUs.parseDWO(*this, DObj->getInfoDWOSection(), true);
586 DWOCUs.parseDWO(*this, DObj->getInfoDWOSection(), DW_SECT_INFO, true);
587587
588588 if (const auto &CUI = getCUIndex()) {
589589 if (const auto *R = CUI.getFromHash(Hash))
590 return DWOCUs.getUnitForIndexEntry(*R);
590 return dyn_cast_or_null(DWOCUs.getUnitForIndexEntry(*R));
591591 return nullptr;
592592 }
593593
606606 continue;
607607 }
608608 if (DWOCU->getDWOId() == Hash)
609 return DWOCU.get();
609 return dyn_cast(DWOCU.get());
610610 }
611611 return nullptr;
612612 }
689689 return Loc.get();
690690
691691 Loc.reset(new DWARFDebugLoc);
692 // Assume all compile units have the same address byte size.
692 // Assume all units have the same address byte size.
693693 if (getNumCompileUnits()) {
694694 DWARFDataExtractor LocData(*DObj, DObj->getLocSection(), isLittleEndian(),
695 getCompileUnitAtIndex(0)->getAddressByteSize());
695 getUnitAtIndex(0)->getAddressByteSize());
696696 Loc->parse(LocData);
697697 }
698698 return Loc.get();
706706 // Assume all compile units have the same address byte size.
707707 if (getNumCompileUnits()) {
708708 DataExtractor LocData(DObj->getLocDWOSection().Data, isLittleEndian(),
709 getCompileUnitAtIndex(0)->getAddressByteSize());
709 getUnitAtIndex(0)->getAddressByteSize());
710710 LocDWO->parse(LocData);
711711 }
712712 return LocDWO.get();
843843 }
844844
845845 void DWARFContext::parseCompileUnits() {
846 CUs.parse(*this, DObj->getInfoSection());
846 CUs.parse(*this, DObj->getInfoSection(), DW_SECT_INFO);
847847 }
848848
849849 void DWARFContext::parseTypeUnits() {
851851 return;
852852 DObj->forEachTypesSections([&](const DWARFSection &S) {
853853 TUs.emplace_back();
854 TUs.back().parse(*this, S);
854 TUs.back().parse(*this, S, DW_SECT_TYPES);
855855 });
856856 }
857857
858858 void DWARFContext::parseDWOCompileUnits() {
859 DWOCUs.parseDWO(*this, DObj->getInfoDWOSection());
859 DWOCUs.parseDWO(*this, DObj->getInfoDWOSection(), DW_SECT_INFO);
860860 }
861861
862862 void DWARFContext::parseDWOTypeUnits() {
864864 return;
865865 DObj->forEachTypesDWOSections([&](const DWARFSection &S) {
866866 DWOTUs.emplace_back();
867 DWOTUs.back().parseDWO(*this, S);
867 DWOTUs.back().parseDWO(*this, S, DW_SECT_TYPES);
868868 });
869869 }
870870
871871 DWARFCompileUnit *DWARFContext::getCompileUnitForOffset(uint32_t Offset) {
872872 parseCompileUnits();
873 return CUs.getUnitForOffset(Offset);
873 return dyn_cast_or_null(CUs.getUnitForOffset(Offset));
874874 }
875875
876876 DWARFCompileUnit *DWARFContext::getCompileUnitForAddress(uint64_t Address) {
1010 #include "llvm/ADT/SmallString.h"
1111 #include "llvm/ADT/StringRef.h"
1212 #include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
13 #include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
1314 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
1415 #include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
1516 #include "llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h"
1617 #include "llvm/DebugInfo/DWARF/DWARFDebugRnglists.h"
1718 #include "llvm/DebugInfo/DWARF/DWARFDie.h"
1819 #include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
20 #include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
1921 #include "llvm/Support/DataExtractor.h"
2022 #include "llvm/Support/Path.h"
2123 #include "llvm/Support/WithColor.h"
3032 using namespace llvm;
3133 using namespace dwarf;
3234
33 void DWARFUnitSectionBase::parse(DWARFContext &C, const DWARFSection &Section) {
35 void DWARFUnitSection::parse(DWARFContext &C, const DWARFSection &Section,
36 DWARFSectionKind SectionKind) {
3437 const DWARFObject &D = C.getDWARFObj();
3538 parseImpl(C, D, Section, C.getDebugAbbrev(), &D.getRangeSection(),
3639 D.getStringSection(), D.getStringOffsetSection(),
3740 &D.getAddrSection(), D.getLineSection(), D.isLittleEndian(), false,
38 false);
39 }
40
41 void DWARFUnitSectionBase::parseDWO(DWARFContext &C,
42 const DWARFSection &DWOSection, bool Lazy) {
41 false, SectionKind);
42 }
43
44 void DWARFUnitSection::parseDWO(DWARFContext &C,
45 const DWARFSection &DWOSection,
46 DWARFSectionKind SectionKind, bool Lazy) {
4347 const DWARFObject &D = C.getDWARFObj();
4448 parseImpl(C, D, DWOSection, C.getDebugAbbrevDWO(), &D.getRangeDWOSection(),
4549 D.getStringDWOSection(), D.getStringOffsetDWOSection(),
4650 &D.getAddrSection(), D.getLineDWOSection(), C.isLittleEndian(),
47 true, Lazy);
51 true, Lazy, SectionKind);
52 }
53
54 void DWARFUnitSection::parseImpl(DWARFContext &Context, const DWARFObject &Obj,
55 const DWARFSection &Section, const DWARFDebugAbbrev *DA,
56 const DWARFSection *RS, StringRef SS, const DWARFSection &SOS,
57 const DWARFSection *AOS, const DWARFSection &LS, bool LE,
58 bool IsDWO, bool Lazy, DWARFSectionKind SectionKind) {
59 if (Parsed)
60 return;
61 DWARFDataExtractor Data(Obj, Section, LE, 0);
62 // Lazy initialization of Parser, now that we have all section info.
63 if (!Parser) {
64 const DWARFUnitIndex *Index = nullptr;
65 if (IsDWO)
66 Index = &getDWARFUnitIndex(Context, SectionKind);
67 Parser = [=, &Context, &Section, &SOS,
68 &LS](uint32_t Offset) -> std::unique_ptr {
69 if (!Data.isValidOffset(Offset))
70 return nullptr;
71 DWARFUnitHeader Header;
72 if (!Header.extract(Context, Data, &Offset, SectionKind, Index))
73 return nullptr;
74 std::unique_ptr U;
75 if (Header.isTypeUnit())
76 U = llvm::make_unique(
77 Context, Section, Header, DA, RS, SS, SOS, AOS, LS, LE, IsDWO,
78 *this);
79 else
80 U = llvm::make_unique(
81 Context, Section, Header, DA, RS, SS, SOS, AOS, LS, LE, IsDWO,
82 *this);
83 return U;
84 };
85 }
86 if (Lazy)
87 return;
88 auto I = this->begin();
89 uint32_t Offset = 0;
90 while (Data.isValidOffset(Offset)) {
91 if (I != this->end() && (*I)->getOffset() == Offset) {
92 ++I;
93 continue;
94 }
95 auto U = Parser(Offset);
96 if (!U)
97 break;
98 Offset = U->getNextUnitOffset();
99 I = std::next(this->insert(I, std::move(U)));
100 }
101 Parsed = true;
102 }
103
104 DWARFUnit *DWARFUnitSection::getUnitForOffset(uint32_t Offset) const {
105 auto *CU = std::upper_bound(
106 this->begin(), this->end(), Offset,
107 [](uint32_t LHS, const std::unique_ptr &RHS) {
108 return LHS < RHS->getNextUnitOffset();
109 });
110 if (CU != this->end() && (*CU)->getOffset() <= Offset)
111 return CU->get();
112 return nullptr;
113 }
114
115 DWARFUnit *
116 DWARFUnitSection::getUnitForIndexEntry(const DWARFUnitIndex::Entry &E) {
117 const auto *CUOff = E.getOffset(DW_SECT_INFO);
118 if (!CUOff)
119 return nullptr;
120
121 auto Offset = CUOff->Offset;
122
123 auto *CU = std::upper_bound(
124 this->begin(), this->end(), CUOff->Offset,
125 [](uint32_t LHS, const std::unique_ptr &RHS) {
126 return LHS < RHS->getNextUnitOffset();
127 });
128 if (CU != this->end() && (*CU)->getOffset() <= Offset)
129 return CU->get();
130
131 if (!Parser)
132 return nullptr;
133
134 auto U = Parser(Offset);
135 if (!U)
136 U = nullptr;
137
138 auto *NewCU = U.get();
139 this->insert(CU, std::move(U));
140 return NewCU;
48141 }
49142
50143 DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section,
52145 const DWARFDebugAbbrev *DA, const DWARFSection *RS,
53146 StringRef SS, const DWARFSection &SOS,
54147 const DWARFSection *AOS, const DWARFSection &LS, bool LE,
55 bool IsDWO, const DWARFUnitSectionBase &UnitSection)
148 bool IsDWO, const DWARFUnitSection &UnitSection)
56149 : Context(DC), InfoSection(Section), Header(Header), Abbrev(DA),
57150 RangeSection(RS), LineSection(LS), StringSection(SS),
58151 StringOffsetSection(SOS), AddrOffsetSection(AOS), isLittleEndian(LE),
263263 bool isUnitDWARF64 = false;
264264 bool isHeaderChainValid = true;
265265 bool hasDIE = DebugInfoData.isValidOffset(Offset);
266 DWARFUnitSection TUSection{};
267 DWARFUnitSection CUSection{};
266 DWARFUnitSection UnitSection{};
268267 while (hasDIE) {
269268 OffsetStart = Offset;
270269 if (!verifyUnitHeader(DebugInfoData, &Offset, UnitIdx, UnitType,
283282 DCtx, DObj.getInfoSection(), Header, DCtx.getDebugAbbrev(),
284283 &DObj.getRangeSection(), DObj.getStringSection(),
285284 DObj.getStringOffsetSection(), &DObj.getAppleObjCSection(),
286 DObj.getLineSection(), DCtx.isLittleEndian(), false, TUSection));
285 DObj.getLineSection(), DCtx.isLittleEndian(), false, UnitSection));
287286 break;
288287 }
289288 case dwarf::DW_UT_skeleton:
297296 DCtx, DObj.getInfoSection(), Header, DCtx.getDebugAbbrev(),
298297 &DObj.getRangeSection(), DObj.getStringSection(),
299298 DObj.getStringOffsetSection(), &DObj.getAppleObjCSection(),
300 DObj.getLineSection(), DCtx.isLittleEndian(), false, CUSection));
299 DObj.getLineSection(), DCtx.isLittleEndian(), false, UnitSection));
301300 break;
302301 }
303302 default: { llvm_unreachable("Invalid UnitType."); }
13141313 if (NumErrors > 0)
13151314 return NumErrors;
13161315
1317 for (const std::unique_ptrCompileUnit> &CU : DCtx.compile_units()) {
1316 for (const std::unique_ptrUnit> &U : DCtx.compile_units()) {
13181317 if (const DWARFDebugNames::NameIndex *NI =
1319 AccelTable.getCUNameIndex(CU->getOffset())) {
1318 AccelTable.getCUNameIndex(U->getOffset())) {
1319 auto *CU = cast(U.get());
13201320 for (const DWARFDebugInfoEntry &Die : CU->dies())
1321 NumErrors += verifyNameIndexCompleteness(DWARFDie(CU.get(), &Die), *NI);
1321 NumErrors += verifyNameIndexCompleteness(DWARFDie(CU, &Die), *NI);
13221322 }
13231323 }
13241324 return NumErrors;
230230 std::unique_ptr DwarfContext = DWARFContext::create(**Obj);
231231 uint32_t NumCUs = DwarfContext->getNumCompileUnits();
232232 EXPECT_EQ(NumCUs, 1u);
233 DWARFCompileUnit *U = DwarfContext->getCompileUnitAtIndex(0);
233 DWARFCompileUnit *U =
234 cast(DwarfContext->getUnitAtIndex(0));
234235 auto DieDG = U->getUnitDIE(false);
235236 EXPECT_TRUE(DieDG.isValid());
236237
495496 // Verify the number of compile units is correct.
496497 uint32_t NumCUs = DwarfContext->getNumCompileUnits();
497498 EXPECT_EQ(NumCUs, 1u);
498 DWARFCompileUnit *U = DwarfContext->getCompileUnitAtIndex(0);
499 DWARFCompileUnit *U =
500 cast(DwarfContext->getUnitAtIndex(0));
499501
500502 // Get the compile unit DIE is valid.
501503 auto DieDG = U->getUnitDIE(false);
671673 // Verify the number of compile units is correct.
672674 uint32_t NumCUs = DwarfContext->getNumCompileUnits();
673675 EXPECT_EQ(NumCUs, 2u);
674 DWARFCompileUnit *U1 = DwarfContext->getCompileUnitAtIndex(0);
675 DWARFCompileUnit *U2 = DwarfContext->getCompileUnitAtIndex(1);
676 DWARFCompileUnit *U1 =
677 cast(DwarfContext->getUnitAtIndex(0));
678 DWARFCompileUnit *U2 =
679 cast(DwarfContext->getUnitAtIndex(1));
676680
677681 // Get the compile unit DIE is valid.
678682 auto Unit1DieDG = U1->getUnitDIE(false);
879883 // Verify the number of compile units is correct.
880884 uint32_t NumCUs = DwarfContext->getNumCompileUnits();
881885 EXPECT_EQ(NumCUs, 1u);
882 DWARFCompileUnit *U = DwarfContext->getCompileUnitAtIndex(0);
886 DWARFCompileUnit *U =
887 cast(DwarfContext->getUnitAtIndex(0));
883888
884889 // Get the compile unit DIE is valid.
885890 auto DieDG = U->getUnitDIE(false);
10541059 // Verify the number of compile units is correct.
10551060 uint32_t NumCUs = DwarfContext->getNumCompileUnits();
10561061 EXPECT_EQ(NumCUs, 1u);
1057 DWARFCompileUnit *U = DwarfContext->getCompileUnitAtIndex(0);
1062 DWARFCompileUnit *U =
1063 cast(DwarfContext->getUnitAtIndex(0));
10581064
10591065 // Get the compile unit DIE is valid.
10601066 auto CUDie = U->getUnitDIE(false);
12211227 // Verify the number of compile units is correct.
12221228 uint32_t NumCUs = DwarfContext->getNumCompileUnits();
12231229 EXPECT_EQ(NumCUs, 1u);
1224 DWARFCompileUnit *U = DwarfContext->getCompileUnitAtIndex(0);
1230 DWARFCompileUnit *U =
1231 cast(DwarfContext->getUnitAtIndex(0));
12251232
12261233 // Get the compile unit DIE is valid.
12271234 auto CUDie = U->getUnitDIE(false);
12831290 // Verify the number of compile units is correct.
12841291 uint32_t NumCUs = DwarfContext->getNumCompileUnits();
12851292 EXPECT_EQ(NumCUs, 1u);
1286 DWARFCompileUnit *U = DwarfContext->getCompileUnitAtIndex(0);
1293 DWARFCompileUnit *U =
1294 cast(DwarfContext->getUnitAtIndex(0));
12871295
12881296 // Get the compile unit DIE is valid.
12891297 auto CUDie = U->getUnitDIE(false);
13301338 // Verify the number of compile units is correct.
13311339 uint32_t NumCUs = DwarfContext->getNumCompileUnits();
13321340 EXPECT_EQ(NumCUs, 1u);
1333 DWARFCompileUnit *U = DwarfContext->getCompileUnitAtIndex(0);
1341 DWARFCompileUnit *U =
1342 cast(DwarfContext->getUnitAtIndex(0));
13341343
13351344 // Get the compile unit DIE is valid.
13361345 auto CUDie = U->getUnitDIE(false);
13981407 // Verify the number of compile units is correct.
13991408 uint32_t NumCUs = DwarfContext->getNumCompileUnits();
14001409 EXPECT_EQ(NumCUs, 1u);
1401 DWARFCompileUnit *U = DwarfContext->getCompileUnitAtIndex(0);
1410 DWARFCompileUnit *U =
1411 cast(DwarfContext->getUnitAtIndex(0));
14021412
14031413 // Get the compile unit DIE is valid.
14041414 auto CUDie = U->getUnitDIE(false);
16051615 // Verify the number of compile units is correct.
16061616 uint32_t NumCUs = DwarfContext->getNumCompileUnits();
16071617 EXPECT_EQ(NumCUs, 1u);
1608 DWARFCompileUnit *U = DwarfContext->getCompileUnitAtIndex(0);
1618 DWARFCompileUnit *U =
1619 cast(DwarfContext->getUnitAtIndex(0));
16091620
16101621 // Get the compile unit DIE is valid.
16111622 auto CUDie = U->getUnitDIE(false);
16641675 auto Obj = object::ObjectFile::createObjectFile(FileBuffer);
16651676 EXPECT_TRUE((bool)Obj);
16661677 std::unique_ptr DwarfContext = DWARFContext::create(**Obj);
1667 DWARFCompileUnit *U = DwarfContext->getCompileUnitAtIndex(0);
1678 DWARFCompileUnit *U =
1679 cast(DwarfContext->getUnitAtIndex(0));
16681680 EXPECT_TRUE((bool)U);
16691681
16701682 const auto *Abbrevs = U->getAbbreviations();
128128 Error Unrecoverable;
129129 std::function RecordUnrecoverable;
130130
131 SmallVector, 2> CUs;
132 std::deque> TUs;
131 SmallVector, 2> CUs;
132 std::deque TUs;
133133 };
134134
135135 // Fixtures must derive from "Test", but parameterised fixtures from