@@ -167,24 +167,61 @@ bool DWARFVerifier::verifyUnitHeader(const DWARFDataExtractor DebugInfoData,
167
167
if (!ValidLength || !ValidVersion || !ValidAddrSize || !ValidAbbrevOffset ||
168
168
!ValidType) {
169
169
Success = false ;
170
- ErrorCategory.Report (" Invalid Length in Unit Header" , [&]() {
171
- error () << format (" Units[%d] - start offset: 0x%08" PRIx64 " \n " ,
172
- UnitIndex, OffsetStart);
173
- if (!ValidLength)
174
- note () << " The length for this unit is too "
175
- " large for the .debug_info provided.\n " ;
176
- if (!ValidVersion) {
177
- note () << " The 16 bit unit header version is not valid.\n " ;
178
- }
179
- if (!ValidType) {
180
- note () << " The unit type encoding is not valid.\n " ;
181
- }
182
- if (!ValidAbbrevOffset)
183
- note () << " The offset into the .debug_abbrev section is "
184
- " not valid.\n " ;
185
- if (!ValidAddrSize)
186
- note () << " The address size is unsupported.\n " ;
187
- });
170
+ bool headerShown = false ;
171
+ if (!ValidLength)
172
+ ErrorCategory.Report (
173
+ " Unit Header Length: Unit too large for .debug_info provided" , [&]() {
174
+ if (!headerShown) {
175
+ error () << format (" Units[%d] - start offset: 0x%08" PRIx64 " \n " ,
176
+ UnitIndex, OffsetStart);
177
+ headerShown = true ;
178
+ }
179
+ note () << " The length for this unit is too "
180
+ " large for the .debug_info provided.\n " ;
181
+ });
182
+ if (!ValidVersion)
183
+ ErrorCategory.Report (
184
+ " Unit Header Length: 16 bit unit header version is not valid" , [&]() {
185
+ if (!headerShown) {
186
+ error () << format (" Units[%d] - start offset: 0x%08" PRIx64 " \n " ,
187
+ UnitIndex, OffsetStart);
188
+ headerShown = true ;
189
+ }
190
+ note () << " The 16 bit unit header version is not valid.\n " ;
191
+ });
192
+ if (!ValidType)
193
+ ErrorCategory.Report (
194
+ " Unit Header Length: Unit type encoding is not valid" , [&]() {
195
+ if (!headerShown) {
196
+ error () << format (" Units[%d] - start offset: 0x%08" PRIx64 " \n " ,
197
+ UnitIndex, OffsetStart);
198
+ headerShown = true ;
199
+ }
200
+ note () << " The unit type encoding is not valid.\n " ;
201
+ });
202
+ if (!ValidAbbrevOffset)
203
+ ErrorCategory.Report (
204
+ " Unit Header Length: Offset into the .debug_abbrev section is not "
205
+ " valid" ,
206
+ [&]() {
207
+ if (!headerShown) {
208
+ error () << format (" Units[%d] - start offset: 0x%08" PRIx64 " \n " ,
209
+ UnitIndex, OffsetStart);
210
+ headerShown = true ;
211
+ }
212
+ note () << " The offset into the .debug_abbrev section is "
213
+ " not valid.\n " ;
214
+ });
215
+ if (!ValidAddrSize)
216
+ ErrorCategory.Report (
217
+ " Unit Header Length: Address size is unsupported" , [&]() {
218
+ if (!headerShown) {
219
+ error () << format (" Units[%d] - start offset: 0x%08" PRIx64 " \n " ,
220
+ UnitIndex, OffsetStart);
221
+ headerShown = true ;
222
+ }
223
+ note () << " The address size is unsupported.\n " ;
224
+ });
188
225
}
189
226
*Offset = OffsetStart + Length + (isUnitDWARF64 ? 12 : 4 );
190
227
return Success;
@@ -1999,12 +2036,11 @@ void OutputCategoryAggregator::EnumerateResults(
1999
2036
}
2000
2037
}
2001
2038
2002
- void DWARFVerifier::summarize (bool Success ) {
2003
- if (!Success && DumpOpts.ShowAggregateErrors ) {
2004
- error () << " Aggregated error category counts:\n " ;
2039
+ void DWARFVerifier::summarize () {
2040
+ if (ErrorCategory. GetNumCategories () && DumpOpts.ShowAggregateErrors ) {
2041
+ error () << " Aggregated error counts:\n " ;
2005
2042
ErrorCategory.EnumerateResults ([&](StringRef s, unsigned count) {
2006
- error () << " Error category '" << s << " ' occurred " << count
2007
- << " time(s).\n " ;
2043
+ error () << s << " occurred " << count << " time(s).\n " ;
2008
2044
});
2009
2045
}
2010
2046
}
0 commit comments