Index: include/llvm/DebugInfo/DWARF/DWARFVerifier.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFVerifier.h +++ include/llvm/DebugInfo/DWARF/DWARFVerifier.h @@ -58,7 +58,6 @@ uint32_t *Offset, unsigned UnitIndex, uint8_t &UnitType, bool &isUnitDWARF64); - bool verifyUnitContents(DWARFUnit Unit); /// Verifies the attribute's DWARF attribute and its value. /// Index: lib/DebugInfo/DWARF/DWARFVerifier.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFVerifier.cpp +++ lib/DebugInfo/DWARF/DWARFVerifier.cpp @@ -94,7 +94,15 @@ auto Die = Unit.getDIEAtIndex(I); if (Die.getTag() == DW_TAG_null) continue; + std::set AttributeSet; for (auto AttrValue : Die.attributes()) { + if (AttributeSet.find(AttrValue.Attr) != AttributeSet.end()) { + OS << format("Error: Die at offset 0x%08x ", Die.getOffset()); + OS << "contains multiple " << AttributeString(AttrValue.Attr) + << " attributes.\n"; + ++NumUnitErrors; + } else + AttributeSet.insert(AttrValue.Attr); NumUnitErrors += verifyDebugInfoAttribute(Die, AttrValue); NumUnitErrors += verifyDebugInfoForm(Die, AttrValue); } Index: test/tools/llvm-dwarfdump/X86/verify_debug_info.s =================================================================== --- test/tools/llvm-dwarfdump/X86/verify_debug_info.s +++ test/tools/llvm-dwarfdump/X86/verify_debug_info.s @@ -12,6 +12,7 @@ # CHECK-NEXT: DW_AT_comp_dir [DW_FORM_strp] ( .debug_str[0x0000003f] = "/Users/sgravani/Development/tests") # CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000) # CHECK-NEXT: DW_AT_high_pc [DW_FORM_data4] (0x00000016){{[[:space:]]}} +# CHECK-NEXT: Error: Die at offset 0x0000002b contains multiple DW_AT_low_pc attributes. # CHECK-NEXT: Units[2] - start offset: 0x00000068 # CHECK-NEXT: Error: The length for this unit is too large for the .debug_info provided. # CHECK-NEXT: Error: The unit type encoding is not valid. @@ -80,7 +81,7 @@ .byte 1 ## DW_CHILDREN_yes .byte 17 ## DW_AT_low_pc .byte 1 ## DW_FORM_addr - .byte 18 ## DW_AT_high_pc + .byte 17 ## DW_AT_high_pc -- Error: Die at offset 0x0000002b contains multiple DW_AT_low_pc attributes. .byte 6 ## DW_FORM_data4 .byte 64 ## DW_AT_frame_base .byte 24 ## DW_FORM_exprloc