@@ -44,76 +44,69 @@ void DWARFUnitVector::addUnitsForSection(DWARFContext &C,
44
44
DWARFSectionKind SectionKind) {
45
45
const DWARFObject &D = C.getDWARFObj ();
46
46
addUnitsImpl (C, D, Section, C.getDebugAbbrev (), &D.getRangesSection (),
47
- &D.getLocSection (), D.getStrSection (),
48
- D.getStrOffsetsSection (), &D.getAddrSection (),
49
- D.getLineSection (), D.isLittleEndian (), false , false ,
50
- SectionKind);
47
+ &D.getLocSection (), D.getStrSection (), D.getStrOffsetsSection (),
48
+ &D.getAddrSection (), D.getLineSection (), D.isLittleEndian (),
49
+ false , SectionKind);
51
50
}
52
51
53
52
void DWARFUnitVector::addUnitsForDWOSection (DWARFContext &C,
54
53
const DWARFSection &DWOSection,
55
- DWARFSectionKind SectionKind,
56
- bool Lazy) {
54
+ DWARFSectionKind SectionKind) {
57
55
const DWARFObject &D = C.getDWARFObj ();
58
- addUnitsImpl (C, D, DWOSection, C.getDebugAbbrevDWO (), &D. getRangesDWOSection (),
59
- &D.getLocDWOSection (), D. getStrDWOSection (),
60
- D.getStrOffsetsDWOSection (), &D. getAddrSection (),
61
- D. getLineDWOSection (), C.isLittleEndian (), true , Lazy ,
62
- SectionKind);
56
+ addUnitsImpl (C, D, DWOSection, C.getDebugAbbrevDWO (),
57
+ &D.getRangesDWOSection (), &D. getLocDWOSection (),
58
+ D.getStrDWOSection (), D. getStrOffsetsDWOSection (),
59
+ &D. getAddrSection (), D. getLineDWOSection (), C.isLittleEndian (),
60
+ true , SectionKind);
63
61
}
64
62
65
63
void DWARFUnitVector::addUnitsImpl (
66
64
DWARFContext &Context, const DWARFObject &Obj, const DWARFSection &Section,
67
65
const DWARFDebugAbbrev *DA, const DWARFSection *RS,
68
66
const DWARFSection *LocSection, StringRef SS, const DWARFSection &SOS,
69
67
const DWARFSection *AOS, const DWARFSection &LS, bool LE, bool IsDWO,
70
- bool Lazy, DWARFSectionKind SectionKind) {
68
+ DWARFSectionKind SectionKind) {
71
69
DWARFDataExtractor Data (Obj, Section, LE, 0 );
72
- // Lazy initialization of Parser, now that we have all section info.
73
- if (!Parser) {
74
- Parser = [=, &Context, &Obj, &Section, &SOS,
75
- &LS](uint64_t Offset, DWARFSectionKind SectionKind,
76
- const DWARFSection *CurSection,
77
- const DWARFUnitIndex::Entry *IndexEntry)
78
- -> std::unique_ptr<DWARFUnit> {
79
- const DWARFSection &InfoSection = CurSection ? *CurSection : Section;
80
- DWARFDataExtractor Data (Obj, InfoSection, LE, 0 );
81
- if (!Data.isValidOffset (Offset))
82
- return nullptr ;
83
- DWARFUnitHeader Header;
84
- if (Error ExtractErr =
85
- Header.extract (Context, Data, &Offset, SectionKind)) {
86
- Context.getWarningHandler ()(std::move (ExtractErr));
87
- return nullptr ;
88
- }
89
- if (!IndexEntry && IsDWO) {
90
- const DWARFUnitIndex &Index = getDWARFUnitIndex (
91
- Context, Header.isTypeUnit () ? DW_SECT_EXT_TYPES : DW_SECT_INFO);
92
- if (Index) {
93
- if (Header.isTypeUnit ())
94
- IndexEntry = Index.getFromHash (Header.getTypeHash ());
95
- else if (auto DWOId = Header.getDWOId ())
96
- IndexEntry = Index.getFromHash (*DWOId);
97
- }
98
- if (!IndexEntry)
99
- IndexEntry = Index.getFromOffset (Header.getOffset ());
70
+ auto Parser = [=, &Context, &Obj, &Section, &SOS,
71
+ &LS](uint64_t Offset, DWARFSectionKind SectionKind,
72
+ const DWARFSection *CurSection,
73
+ const DWARFUnitIndex::Entry *IndexEntry)
74
+ -> std::unique_ptr<DWARFUnit> {
75
+ const DWARFSection &InfoSection = CurSection ? *CurSection : Section;
76
+ DWARFDataExtractor Data (Obj, InfoSection, LE, 0 );
77
+ if (!Data.isValidOffset (Offset))
78
+ return nullptr ;
79
+ DWARFUnitHeader Header;
80
+ if (Error ExtractErr =
81
+ Header.extract (Context, Data, &Offset, SectionKind)) {
82
+ Context.getWarningHandler ()(std::move (ExtractErr));
83
+ return nullptr ;
84
+ }
85
+ if (!IndexEntry && IsDWO) {
86
+ const DWARFUnitIndex &Index = getDWARFUnitIndex (
87
+ Context, Header.isTypeUnit () ? DW_SECT_EXT_TYPES : DW_SECT_INFO);
88
+ if (Index) {
89
+ if (Header.isTypeUnit ())
90
+ IndexEntry = Index.getFromHash (Header.getTypeHash ());
91
+ else if (auto DWOId = Header.getDWOId ())
92
+ IndexEntry = Index.getFromHash (*DWOId);
100
93
}
101
- if (IndexEntry && !Header.applyIndexEntry (IndexEntry))
102
- return nullptr ;
103
- std::unique_ptr<DWARFUnit> U;
104
- if (Header.isTypeUnit ())
105
- U = std::make_unique<DWARFTypeUnit>(Context, InfoSection, Header, DA,
94
+ if (!IndexEntry)
95
+ IndexEntry = Index.getFromOffset (Header.getOffset ());
96
+ }
97
+ if (IndexEntry && !Header.applyIndexEntry (IndexEntry))
98
+ return nullptr ;
99
+ std::unique_ptr<DWARFUnit> U;
100
+ if (Header.isTypeUnit ())
101
+ U = std::make_unique<DWARFTypeUnit>(Context, InfoSection, Header, DA, RS,
102
+ LocSection, SS, SOS, AOS, LS, LE,
103
+ IsDWO, *this );
104
+ else
105
+ U = std::make_unique<DWARFCompileUnit>(Context, InfoSection, Header, DA,
106
106
RS, LocSection, SS, SOS, AOS, LS,
107
107
LE, IsDWO, *this );
108
- else
109
- U = std::make_unique<DWARFCompileUnit>(Context, InfoSection, Header,
110
- DA, RS, LocSection, SS, SOS,
111
- AOS, LS, LE, IsDWO, *this );
112
- return U;
113
- };
114
- }
115
- if (Lazy)
116
- return ;
108
+ return U;
109
+ };
117
110
// Find a reasonable insertion point within the vector. We skip over
118
111
// (a) units from a different section, (b) units from the same section
119
112
// but with lower offset-within-section. This keeps units in order
@@ -136,15 +129,6 @@ void DWARFUnitVector::addUnitsImpl(
136
129
}
137
130
}
138
131
139
- DWARFUnit *DWARFUnitVector::addUnit (std::unique_ptr<DWARFUnit> Unit) {
140
- auto I = llvm::upper_bound (*this , Unit,
141
- [](const std::unique_ptr<DWARFUnit> &LHS,
142
- const std::unique_ptr<DWARFUnit> &RHS) {
143
- return LHS->getOffset () < RHS->getOffset ();
144
- });
145
- return this ->insert (I, std::move (Unit))->get ();
146
- }
147
-
148
132
DWARFUnit *DWARFUnitVector::getUnitForOffset (uint64_t Offset) const {
149
133
auto end = begin () + getNumInfoUnits ();
150
134
auto *CU =
@@ -158,7 +142,7 @@ DWARFUnit *DWARFUnitVector::getUnitForOffset(uint64_t Offset) const {
158
142
}
159
143
160
144
DWARFUnit *
161
- DWARFUnitVector::getUnitForIndexEntry (const DWARFUnitIndex::Entry &E) {
145
+ DWARFUnitVector::getUnitForIndexEntry (const DWARFUnitIndex::Entry &E) const {
162
146
const auto *CUOff = E.getContribution (DW_SECT_INFO);
163
147
if (!CUOff)
164
148
return nullptr ;
@@ -174,17 +158,7 @@ DWARFUnitVector::getUnitForIndexEntry(const DWARFUnitIndex::Entry &E) {
174
158
if (CU != end && (*CU)->getOffset () <= Offset)
175
159
return CU->get ();
176
160
177
- if (!Parser)
178
- return nullptr ;
179
-
180
- auto U = Parser (Offset, DW_SECT_INFO, nullptr , &E);
181
- if (!U)
182
- return nullptr ;
183
-
184
- auto *NewCU = U.get ();
185
- this ->insert (CU, std::move (U));
186
- ++NumInfoUnits;
187
- return NewCU;
161
+ return nullptr ;
188
162
}
189
163
190
164
DWARFUnit::DWARFUnit (DWARFContext &DC, const DWARFSection &Section,
0 commit comments