Skip to content

Commit 5269710

Browse files
author
Kevin Frei
committed
First chunk of PR feedback addressed
1 parent 5a7d23e commit 5269710

File tree

5 files changed

+72
-35
lines changed

5 files changed

+72
-35
lines changed

llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class OutputCategoryAggregator {
4040
: IncludeDetail(includeDetail) {}
4141
void EnableDetail() { IncludeDetail = true; }
4242
void DisableDetail() { IncludeDetail = false; }
43+
size_t GetNumCategories() const { return Aggregation.size(); }
4344
void Report(StringRef s, std::function<void()> detailCallback);
4445
void EnumerateResults(std::function<void(StringRef, unsigned)> handleCounts);
4546
};
@@ -365,7 +366,7 @@ class DWARFVerifier {
365366
void (DWARFObject::*)(function_ref<void(const DWARFSection &)>) const);
366367

367368
/// Emits any aggregate information collected, depending on the dump options
368-
void summarize(bool Success);
369+
void summarize();
369370
};
370371

371372
static inline bool operator<(const DWARFVerifier::DieRangeInfo &LHS,

llvm/lib/DebugInfo/DWARF/DWARFContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,7 @@ bool DWARFContext::verify(raw_ostream &OS, DIDumpOptions DumpOpts) {
14081408
if (DumpOpts.DumpType & DIDT_DebugStrOffsets)
14091409
Success &= verifier.handleDebugStrOffsets();
14101410
Success &= verifier.handleAccelTables();
1411-
verifier.summarize(Success);
1411+
verifier.summarize();
14121412
return Success;
14131413
}
14141414

llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp

Lines changed: 59 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -167,24 +167,61 @@ bool DWARFVerifier::verifyUnitHeader(const DWARFDataExtractor DebugInfoData,
167167
if (!ValidLength || !ValidVersion || !ValidAddrSize || !ValidAbbrevOffset ||
168168
!ValidType) {
169169
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+
});
188225
}
189226
*Offset = OffsetStart + Length + (isUnitDWARF64 ? 12 : 4);
190227
return Success;
@@ -1999,12 +2036,11 @@ void OutputCategoryAggregator::EnumerateResults(
19992036
}
20002037
}
20012038

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";
20052042
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";
20082044
});
20092045
}
20102046
}

llvm/test/tools/llvm-dwarfdump/X86/verify_file_encoding.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@
5151
# CHECK-NEXT: DW_AT_call_file [DW_FORM_sdata] (4)
5252
# CHECK-NEXT: DW_AT_call_line [DW_FORM_sdata] (5){{[[:space:]]}}
5353
# CHECK-NEXT: Verifying dwo Units...
54-
# CHECK-NEXT: error: Aggregated error category counts:
55-
# CHECK-NEXT: error: Error category 'Invalid encoding in DW_AT_decl_file' occurred 4 time(s).
56-
# CHECK-NEXT: error: Error category 'Invalid file index in DW_AT_call_line' occurred 1 time(s).
57-
# CHECK-NEXT: error: Error category 'Invalid file index in DW_AT_decl_line' occurred 1 time(s).
54+
# CHECK-NEXT: error: Aggregated error counts:
55+
# CHECK-NEXT: error: Invalid encoding in DW_AT_decl_file occurred 4 time(s).
56+
# CHECK-NEXT: error: Invalid file index in DW_AT_call_line occurred 1 time(s).
57+
# CHECK-NEXT: error: Invalid file index in DW_AT_decl_line occurred 1 time(s).
5858
--- !ELF
5959
FileHeader:
6060
Class: ELFCLASS64

llvm/test/tools/llvm-dwarfdump/X86/verify_split_cu.s

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
# CHECK: error: Unsupported DW_AT_location encoding: DW_FORM_data1
99
# FIXME: This should read "type unit" or just "unit" to be correct for this case/in general
1010
# CHECK: error: DIE has DW_AT_decl_file that references a file with index 1 and the compile unit has no line table
11-
# CHECK: error: Aggregated error category counts:
12-
# CHECK: error: Error category 'Compilation unit root DIE is not a unit DIE' occurred 1 time(s).
13-
# CHECK: error: Error category 'File index in DW_AT_decl_file reference CU with no line table' occurred 1 time(s).
14-
# CHECK: error: Error category 'Invalid DW_AT_location' occurred 1 time(s).
15-
# CHECK: error: Error category 'Mismatched unit type' occurred 1 time(s).
16-
# CHECK: Errors detected
11+
# CHECK: error: Aggregated error counts:
12+
# CHECK: error: Compilation unit root DIE is not a unit DIE occurred 1 time(s).
13+
# CHECK: error: File index in DW_AT_decl_file reference CU with no line table occurred 1 time(s).
14+
# CHECK: error: Invalid DW_AT_location occurred 1 time(s).
15+
# CHECK: error: Mismatched unit type occurred 1 time(s).
16+
# CHECK: Errors detected.
1717
.section .debug_info.dwo,"e",@progbits
1818
.long .Ldebug_info_dwo_end1-.Ldebug_info_dwo_start1 # Length of Unit
1919
.Ldebug_info_dwo_start1:

0 commit comments

Comments
 (0)