diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h @@ -273,10 +273,11 @@ void clear(); /// Parse prologue and all rows. - Error parse(DWARFDataExtractor &DebugLineData, uint64_t *OffsetPtr, - const DWARFContext &Ctx, const DWARFUnit *U, - function_ref RecoverableErrorHandler, - raw_ostream *OS = nullptr, bool Verbose = false); + void parse(DWARFDataExtractor &DebugLineData, uint64_t *OffsetPtr, + const DWARFContext &Ctx, const DWARFUnit *U, + function_ref RecoverableErrorHandler, + function_ref UnrecoverableErrorHandler, + raw_ostream *OS = nullptr, bool Verbose = false); using RowVector = std::vector; using RowIter = RowVector::const_iterator; diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -566,8 +566,15 @@ LineTableMap.insert(LineTableMapTy::value_type(Offset, LineTable())); LineTable *LT = &Pos.first->second; if (Pos.second) { - if (Error Err = - LT->parse(DebugLineData, &Offset, Ctx, U, RecoverableErrorHandler)) + Error Err = Error::success(); + LT->parse(DebugLineData, &Offset, Ctx, U, RecoverableErrorHandler, + [&Err](Error NewErr) { + // Only one unrecoverable error should be reported per call to + // parse. + cantFail(std::move(Err)); + Err = std::move(NewErr); + }); + if (Err) return std::move(Err); return LT; } @@ -687,10 +694,11 @@ return {AddrAdvanceResult.AddrDelta, LineOffset}; } -Error DWARFDebugLine::LineTable::parse( +void DWARFDebugLine::LineTable::parse( DWARFDataExtractor &DebugLineData, uint64_t *OffsetPtr, const DWARFContext &Ctx, const DWARFUnit *U, - function_ref RecoverableErrorHandler, raw_ostream *OS, + function_ref RecoverableErrorHandler, + function_ref UnrecoverableErrorHandler, raw_ostream *OS, bool Verbose) { assert((OS || !Verbose) && "cannot have verbose output without stream"); const uint64_t DebugLineOffset = *OffsetPtr; @@ -707,14 +715,10 @@ } if (PrologueErr) { - // Ensure there is a blank line after the prologue to clearly delineate it - // from later dumps. + UnrecoverableErrorHandler(std::move(PrologueErr)); if (OS) *OS << "\n"; - // FIXME: Rather than return this error, we should handle it here in a - // callback, so that the error will (if printed) be placed before the new - // line above. - return PrologueErr; + return; } uint64_t ProgramLength = Prologue.TotalLength + Prologue.sizeofTotalLength(); @@ -1110,8 +1114,6 @@ // later dumps. if (OS) *OS << "\n"; - - return Error::success(); } uint32_t DWARFDebugLine::LineTable::findRowInSeq( @@ -1358,9 +1360,8 @@ DWARFUnit *U = prepareToParse(Offset); uint64_t OldOffset = Offset; LineTable LT; - if (Error Err = LT.parse(DebugLineData, &Offset, Context, U, - RecoverableErrorHandler, OS, Verbose)) - UnrecoverableErrorHandler(std::move(Err)); + LT.parse(DebugLineData, &Offset, Context, U, RecoverableErrorHandler, + UnrecoverableErrorHandler, OS, Verbose); moveToNextTable(OldOffset, LT.Prologue); return LT; } diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test b/llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test --- a/llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test +++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test @@ -67,8 +67,8 @@ # NONFATAL-NEXT: total_length: 0x00000002 # NONFATAL-NEXT: format: DWARF32 # NONFATAL-NEXT: version: 0 -# NONFATAL-EMPTY: # SOME-ERR-NEXT: warning: parsing line table prologue at offset 0x00000048: unsupported version 0 +# NONFATAL-EMPTY: ## Version 1 table. # NONFATAL: debug_line[0x0000004e] @@ -76,8 +76,8 @@ # NONFATAL-NEXT: total_length: 0x00000002 # NONFATAL-NEXT: format: DWARF32 # NONFATAL-NEXT: version: 1 -# NONFATAL-EMPTY: # SOME-ERR-NEXT: warning: parsing line table prologue at offset 0x0000004e: unsupported version 1 +# NONFATAL-EMPTY: ## Malformed directory format with no path component. # NONFATAL: debug_line[0x00000054]