From 0e7ba06e82b441bcc868815c8050a32450d26fc3 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 22 Jul 2019 23:23:34 +0000 Subject: [DWARF] Add more error handling to debug line parser. This patch exnteds the error handling in the debug line parser to get rid of the existing MD5 assertion. I want to reuse the debug line parser from LLVM in LLDB where we cannot crash on invalid input. Differential revision: https://reviews.llvm.org/D64544 llvm-svn: 366762 --- llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'llvm/unittests/DebugInfo') diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp index ce7c252d83e..bf2dee4ce24 100644 --- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp +++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp @@ -120,6 +120,16 @@ struct CommonFixture { checkError(ExpectedMsg, ExpectedLineTable.takeError()); } + void checkGetOrParseLineTableEmitsError(ArrayRef ExpectedMsgs, + uint64_t Offset = 0) { + auto ExpectedLineTable = Line.getOrParseLineTable( + LineData, Offset, *Context, nullptr, RecordRecoverable); + EXPECT_FALSE(ExpectedLineTable); + EXPECT_FALSE(Recoverable); + + checkError(ExpectedMsgs, ExpectedLineTable.takeError()); + } + std::unique_ptr Gen; std::unique_ptr Context; DWARFDataExtractor LineData; @@ -344,8 +354,9 @@ TEST_F(DebugLineBasicFixture, ErrorForInvalidV5IncludeDirTable) { generate(); checkGetOrParseLineTableEmitsError( - "parsing line table prologue at 0x00000000 found an invalid directory or " - "file table description at 0x00000014"); + {"parsing line table prologue at 0x00000000 found an invalid directory " + "or file table description at 0x00000014", + "failed to parse entry content descriptions because no path was found"}); } TEST_P(DebugLineParameterisedFixture, ErrorForTooLargePrologueLength) { -- cgit v1.2.3