diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h @@ -34,7 +34,7 @@ uint64_t getOffset() const { return Offset; } void dump(raw_ostream &OS) const; - bool extract(DataExtractor Data, uint64_t *OffsetPtr); + Error extract(DataExtractor Data, uint64_t *OffsetPtr); const DWARFAbbreviationDeclaration * getAbbreviationDeclaration(uint32_t AbbrCode) const; diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp @@ -25,21 +25,18 @@ Decls.clear(); } -bool DWARFAbbreviationDeclarationSet::extract(DataExtractor Data, - uint64_t *OffsetPtr) { +Error DWARFAbbreviationDeclarationSet::extract(DataExtractor Data, + uint64_t *OffsetPtr) { clear(); const uint64_t BeginOffset = *OffsetPtr; Offset = BeginOffset; DWARFAbbreviationDeclaration AbbrDecl; uint32_t PrevAbbrCode = 0; while (true) { - llvm::Expected ES = + Expected ES = AbbrDecl.extract(Data, OffsetPtr); - if (!ES) { - // FIXME: We should propagate the error upwards. - llvm::consumeError(ES.takeError()); - break; - } + if (!ES) + return ES.takeError(); if (*ES == DWARFAbbreviationDeclaration::ExtractState::Complete) break; @@ -53,7 +50,7 @@ PrevAbbrCode = AbbrDecl.getCode(); Decls.push_back(std::move(AbbrDecl)); } - return BeginOffset != *OffsetPtr; + return Error::success(); } void DWARFAbbreviationDeclarationSet::dump(raw_ostream &OS) const { @@ -127,8 +124,11 @@ ++I; uint64_t CUAbbrOffset = Offset; DWARFAbbreviationDeclarationSet AbbrDecls; - if (!AbbrDecls.extract(*Data, &Offset)) + if (Error Err = AbbrDecls.extract(*Data, &Offset)) { + // FIXME: We should propagate the error upwards. + consumeError(std::move(Err)); break; + } AbbrDeclSets.insert(I, std::make_pair(CUAbbrOffset, std::move(AbbrDecls))); } Data = std::nullopt; @@ -164,8 +164,11 @@ if (Data && CUAbbrOffset < Data->getData().size()) { uint64_t Offset = CUAbbrOffset; DWARFAbbreviationDeclarationSet AbbrDecls; - if (!AbbrDecls.extract(*Data, &Offset)) + if (Error Err = AbbrDecls.extract(*Data, &Offset)) { + // FIXME: We should propagate the error upwards. + consumeError(std::move(Err)); return nullptr; + } PrevAbbrOffsetPos = AbbrDeclSets.insert(std::make_pair(CUAbbrOffset, std::move(AbbrDecls))) .first; diff --git a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp --- a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp @@ -299,20 +299,27 @@ } unsigned DWARFVerifier::verifyAbbrevSection(const DWARFDebugAbbrev *Abbrev) { + if (!Abbrev) + return 0; + + const DWARFAbbreviationDeclarationSet *AbbrDecls = + Abbrev->getAbbreviationDeclarationSet(0); + // FIXME: If we failed to get a DWARFAbbreviationDeclarationSet, it's possible + // that there are errors. We need to propagate the error from + // getAbbreviationDeclarationSet. + if (!AbbrDecls) + return 0; + unsigned NumErrors = 0; - if (Abbrev) { - const DWARFAbbreviationDeclarationSet *AbbrDecls = - Abbrev->getAbbreviationDeclarationSet(0); - for (auto AbbrDecl : *AbbrDecls) { - SmallDenseSet AttributeSet; - for (auto Attribute : AbbrDecl.attributes()) { - auto Result = AttributeSet.insert(Attribute.Attr); - if (!Result.second) { - error() << "Abbreviation declaration contains multiple " - << AttributeString(Attribute.Attr) << " attributes.\n"; - AbbrDecl.dump(OS); - ++NumErrors; - } + for (auto AbbrDecl : *AbbrDecls) { + SmallDenseSet AttributeSet; + for (auto Attribute : AbbrDecl.attributes()) { + auto Result = AttributeSet.insert(Attribute.Attr); + if (!Result.second) { + error() << "Abbreviation declaration contains multiple " + << AttributeString(Attribute.Attr) << " attributes.\n"; + AbbrDecl.dump(OS); + ++NumErrors; } } } diff --git a/llvm/test/DebugInfo/ARM/dwarfdump-rela.yaml b/llvm/test/DebugInfo/ARM/dwarfdump-rela.yaml --- a/llvm/test/DebugInfo/ARM/dwarfdump-rela.yaml +++ b/llvm/test/DebugInfo/ARM/dwarfdump-rela.yaml @@ -24,7 +24,7 @@ Content: 17000000050001040000000001A000000000000000020000000000 - Name: .debug_abbrev Type: SHT_PROGBITS - Content: 011101030E49130000022400030E0000 + Content: 011101030E49130000022400030E000000 - Name: .debug_str Type: SHT_PROGBITS - Name: .rela.debug_info diff --git a/llvm/test/DebugInfo/X86/dwarfdump-header-64.s b/llvm/test/DebugInfo/X86/dwarfdump-header-64.s --- a/llvm/test/DebugInfo/X86/dwarfdump-header-64.s +++ b/llvm/test/DebugInfo/X86/dwarfdump-header-64.s @@ -41,6 +41,7 @@ .byte 0x17 # DW_FORM_sec_offset .byte 0x00 # EOM(1) .byte 0x00 # EOM(2) + .byte 0x00 # EOM(3) .ifdef ELF .section .debug_info,"",@progbits diff --git a/llvm/test/DebugInfo/X86/dwarfdump-rela-dwo.s b/llvm/test/DebugInfo/X86/dwarfdump-rela-dwo.s --- a/llvm/test/DebugInfo/X86/dwarfdump-rela-dwo.s +++ b/llvm/test/DebugInfo/X86/dwarfdump-rela-dwo.s @@ -31,6 +31,7 @@ .byte 0x25 # DW_FORM_strx1 .byte 0x00 # EOM(1) .byte 0x00 # EOM(2) + .byte 0x00 # EOM(3) .section .debug_info.dwo,"e",@progbits # CHECK-LABEL: .debug_info.dwo diff --git a/llvm/test/tools/dsymutil/Inputs/empty-CU.o b/llvm/test/tools/dsymutil/Inputs/empty-CU.o deleted file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@