[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:16 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;
+            }
+            note() << "The length for this unit is too "
+                      "large for the .debug_info provided.\n";
+          });
     if (!ValidVersion)
-      note() << "The 16 bit unit header version is not valid.\n";
+      ErrorCategory.Report(
+          "Unit Header Length: 16 bit unit header version is not valid", [&]() {
+            if (!headerShown) {
+              error() << format("Units[%d] - start offset: 0x%08" PRIx64 " \n",
+                                UnitIndex, OffsetStart);
+              headerShown = true;
+            }
+            note() << "The 16 bit unit header version is not valid.\n";
+          });
     if (!ValidType)
-      note() << "The unit type encoding is not valid.\n";
+      ErrorCategory.Report(
+          "Unit Header Length: Unit type encoding is not valid", [&]() {
+            if (!headerShown) {
+              error() << format("Units[%d] - start offset: 0x%08" PRIx64 " \n",
+                                UnitIndex, OffsetStart);
+              headerShown = true;
+            }
----------------
clayborg wrote:

```
printHeaderOnce();
```

https://github.com/llvm/llvm-project/pull/79648


More information about the llvm-commits mailing list