Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DebugInfo] Correctly report header parsing errors from DWARFContext::fixupIndex #69505

Merged
merged 1 commit into from
Oct 19, 2023

Conversation

bulbazord
Copy link
Member

In ef762e5e7292, I shifted around where errors were reported when failing to parse and/or validate DWARFUnitHeaders. When we are doing so in DWARFContext::fixupIndex, the actual error message isn't prefixed with warning: like it would be elsewhere (because of the way logAllUnhandledErrors is implemented).

…:fixupIndex

In ef762e5e7292, I shifted around where errors were reported when
failing to parse and/or validate DWARFUnitHeaders. When we are doing so
in DWARFContext::fixupIndex, the actual error message isn't prefixed
with `warning:` like it would be elsewhere (because of the way
`logAllUnhandledErrors` is implemented).
@llvmbot
Copy link
Member

llvmbot commented Oct 18, 2023

@llvm/pr-subscribers-debuginfo

Author: Alex Langford (bulbazord)

Changes

In ef762e5e7292, I shifted around where errors were reported when failing to parse and/or validate DWARFUnitHeaders. When we are doing so in DWARFContext::fixupIndex, the actual error message isn't prefixed with warning: like it would be elsewhere (because of the way logAllUnhandledErrors is implemented).


Full diff: https://github.com/llvm/llvm-project/pull/69505.diff

2 Files Affected:

  • (modified) llvm/lib/DebugInfo/DWARF/DWARFContext.cpp (+4-6)
  • (modified) llvm/test/tools/llvm-dwp/X86/cu_tu_units_manual_v5_invalid.s (+2-2)
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 724f816ad094a75..57ca11a077a486a 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -91,10 +91,9 @@ void fixupIndexV4(DWARFContext &C, DWARFUnitIndex &Index) {
       DWARFUnitHeader Header;
       if (Error ExtractionErr = Header.extract(
               C, Data, &Offset, DWARFSectionKind::DW_SECT_INFO)) {
-        logAllUnhandledErrors(
+        C.getWarningHandler()(
             createError("Failed to parse CU header in DWP file: " +
-                        toString(std::move(ExtractionErr))),
-            errs());
+                        toString(std::move(ExtractionErr))));
         Map.clear();
         break;
       }
@@ -154,10 +153,9 @@ void fixupIndexV5(DWARFContext &C, DWARFUnitIndex &Index) {
       DWARFUnitHeader Header;
       if (Error ExtractionErr = Header.extract(
               C, Data, &Offset, DWARFSectionKind::DW_SECT_INFO)) {
-        logAllUnhandledErrors(
+        C.getWarningHandler()(
             createError("Failed to parse CU header in DWP file: " +
-                        toString(std::move(ExtractionErr))),
-            errs());
+                        toString(std::move(ExtractionErr))));
         break;
       }
       bool CU = Header.getUnitType() == DW_UT_split_compile;
diff --git a/llvm/test/tools/llvm-dwp/X86/cu_tu_units_manual_v5_invalid.s b/llvm/test/tools/llvm-dwp/X86/cu_tu_units_manual_v5_invalid.s
index d1ab9f75b74c8fa..1f63b2121797038 100644
--- a/llvm/test/tools/llvm-dwp/X86/cu_tu_units_manual_v5_invalid.s
+++ b/llvm/test/tools/llvm-dwp/X86/cu_tu_units_manual_v5_invalid.s
@@ -13,10 +13,10 @@
 # CHECK-NOT: .debug_info.dwo contents:
 
 # CHECK-DAG: .debug_cu_index contents:
-# CHECK: Failed to parse CU header in DWP file: DWARF unit at offset 0x00000000 has unsupported version 6, supported are 2-5
+# CHECK: warning: Failed to parse CU header in DWP file: DWARF unit at offset 0x00000000 has unsupported version 6, supported are 2-5
 
 # CHECK-DAG: .debug_tu_index contents:
-# CHECK: Failed to parse CU header in DWP file: DWARF unit at offset 0x00000000 has unsupported version 6, supported are 2-5
+# CHECK: warning: Failed to parse CU header in DWP file: DWARF unit at offset 0x00000000 has unsupported version 6, supported are 2-5
 
     .section	.debug_info.dwo,"e",@progbits
     .long	.Ldebug_info_dwo_end0-.Ldebug_info_dwo_start0 # Length of Unit

Copy link
Collaborator

@dwblaikie dwblaikie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, thanks!

Copy link
Contributor

@felipepiovezan felipepiovezan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@bulbazord bulbazord merged commit 0446c58 into llvm:main Oct 19, 2023
3 checks passed
@bulbazord bulbazord deleted the report-cu-dwp-parsing-errors branch October 19, 2023 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants