[llvm] [DebugInfo] Separate error generation from reporting in DWARFHeaderUnit::extract (PR #68242)

Alex Langford via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 17 16:13:00 PDT 2023


================
@@ -0,0 +1,73 @@
+# This test checks that llvm-dwarfdump correctly reports errors when parsing
+# DWARF Unit Headers in DWP files
+
+# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o \
+# RUN:         -split-dwarf-file=%t.dwo -dwarf-version=5
+# RUN: llvm-dwp %t.dwo -o %t.dwp
+# RUN: llvm-dwarfdump -debug-info -debug-cu-index -debug-tu-index \
+# RUN:                -manaully-generate-unit-index %t.dwp 2>&1 | FileCheck %s
+
+## Note: In order to check whether the type unit index is generated
+## there is no need to add the missing DIEs for the structure type of the type unit.
+
+# 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
----------------
bulbazord wrote:

They're not emitted with `error: ` unfortunately. The raw output of `llvm-dwarfdump` is:
```
$PROJECTS/llvm-project/build/test/tools/llvm-dwp/X86/Output/cu_tu_units_manual_v5_invalid.s.tmp.dwp:     file format elf64-x86-64
warning: DWARF unit at offset 0x00000000 has unsupported version 6, supported are 2-5

.debug_cu_index contents:
Failed to parse CU header in DWP file: DWARF unit at offset 0x00000000 has unsupported version 6, supported are 2-5
version = 5, units = 1, slots = 2

Index Signature          INFO                                     ABBREV
----- ------------------ ---------------------------------------- ------------------------
    1 0x10001450c58e1dbe [0x0000000000000036, 0x000000000000004b) [0x00000000, 0x00000010)

.debug_tu_index contents:
Failed to parse CU header in DWP file: DWARF unit at offset 0x00000000 has unsupported version 6, supported are 2-5
version = 5, units = 2, slots = 4

Index Signature          INFO                                     ABBREV
----- ------------------ ---------------------------------------- ------------------------
    1 0x4e834ea939695c24 [0x0000000000000000, 0x000000000000001b) [0x00000000, 0x00000010)
    4 0x89a49a5d44b29ee7 [0x000000000000001b, 0x0000000000000036) [0x00000000, 0x00000010)
```

If you consider the output of the test I added but without my changes, you end up with:
```
.debug_cu_index contents:
warning: DWARF unit at offset 0x00000000 has unsupported version 6, supported are 2-5
Failed to parse unit header in DWP file
```

I think the lack of a warning in my test is definitely problematic, but that's because `fixupIndexV{4,5}` isn't reporting the error correctly. I'd like to address that in a follow-up.

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


More information about the llvm-commits mailing list