[llvm] Aggregate errors from llvm-dwarfutil --verify (PR #79648)
Greg Clayton via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 29 23:05:15 PST 2024
================
@@ -167,20 +167,61 @@ bool DWARFVerifier::verifyUnitHeader(const DWARFDataExtractor DebugInfoData,
if (!ValidLength || !ValidVersion || !ValidAddrSize || !ValidAbbrevOffset ||
!ValidType) {
Success = false;
- error() << format("Units[%d] - start offset: 0x%08" PRIx64 " \n", UnitIndex,
- OffsetStart);
+ bool headerShown = false;
if (!ValidLength)
- note() << "The length for this unit is too "
- "large for the .debug_info provided.\n";
+ ErrorCategory.Report(
+ "Unit Header Length: Unit too large for .debug_info provided", [&]() {
+ if (!headerShown) {
+ error() << format("Units[%d] - start offset: 0x%08" PRIx64 " \n",
+ UnitIndex, OffsetStart);
+ headerShown = true;
+ }
----------------
clayborg wrote:
Make this a lambda outside of each report that uses a local bool to control if it gets displayed?
```
bool headerShown = false;
auto printHeaderOnce = [&]() {
if (!headerShown) {
error() << format("Units[%d] - start offset: 0x%08" PRIx64 " \n", UnitIndex, OffsetStart);
headerShown = true;
}
};
```
Then this code becomes:
```
printHeaderOnce();
```
https://github.com/llvm/llvm-project/pull/79648
More information about the llvm-commits
mailing list