diff options
author | James Henderson <james.henderson@sony.com> | 2020-01-03 15:19:27 +0000 |
---|---|---|
committer | James Henderson <james.henderson@sony.com> | 2020-01-28 11:29:50 +0000 |
commit | b94191fecdbadc18b342a27df1109754edcb8c4b (patch) | |
tree | 5777179f0da22b861c8f0bf051e13a1be3dd449b /llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp | |
parent | dea11473db38d03cbfd77f0d46e92dceb202a24a (diff) | |
download | llvm-b94191fecdbadc18b342a27df1109754edcb8c4b.zip llvm-b94191fecdbadc18b342a27df1109754edcb8c4b.tar.gz llvm-b94191fecdbadc18b342a27df1109754edcb8c4b.tar.bz2 |
[DebugInfo] Make most debug line prologue errors non-fatal to parsing
Many of the debug line prologue errors are not inherently fatal. In most
cases, we can make reasonable assumptions and carry on. This patch does
exactly that. In the case of length problems, the approach of "the
claimed length is correct" is taken to be consistent with other
instances such as the SectionParser, which ignores the read length.
Reviewed by: dblaikie
Differential Revision: https://reviews.llvm.org/D72158
Diffstat (limited to 'llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp')
-rw-r--r-- | llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp | 56 |
1 files changed, 44 insertions, 12 deletions
diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp index 731afaf..89c28bc 100644 --- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp +++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp @@ -359,10 +359,15 @@ TEST_F(DebugLineBasicFixture, ErrorForInvalidV5IncludeDirTable) { generate();
- checkGetOrParseLineTableEmitsFatalError(
+ auto ExpectedLineTable = Line.getOrParseLineTable(LineData, 0, *Context,
+ nullptr, RecordRecoverable);
+ EXPECT_THAT_EXPECTED(ExpectedLineTable, Succeeded());
+
+ checkError(
{"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"});
+ "failed to parse entry content descriptions because no path was found"},
+ std::move(Recoverable));
}
TEST_P(DebugLineParameterisedFixture, ErrorForTooLargePrologueLength) {
@@ -379,14 +384,24 @@ TEST_P(DebugLineParameterisedFixture, ErrorForTooLargePrologueLength) { generate();
+ auto ExpectedLineTable = Line.getOrParseLineTable(LineData, 0, *Context,
+ nullptr, RecordRecoverable);
+ ASSERT_THAT_EXPECTED(ExpectedLineTable, Succeeded());
+ DWARFDebugLine::LineTable Result(**ExpectedLineTable);
+ // Undo the earlier modification so that it can be compared against a
+ // "default" prologue.
+ --Result.Prologue.PrologueLength;
+ checkDefaultPrologue(Version, Format, Result.Prologue, 0);
+
uint64_t ExpectedEnd =
Prologue.TotalLength + 1 + Prologue.sizeofTotalLength();
- checkGetOrParseLineTableEmitsFatalError(
+ checkError(
(Twine("parsing line table prologue at 0x00000000 should have ended at "
"0x000000") +
Twine::utohexstr(ExpectedEnd) + " but it ended at 0x000000" +
Twine::utohexstr(ExpectedEnd - 1))
- .str());
+ .str(),
+ std::move(Recoverable));
}
TEST_P(DebugLineParameterisedFixture, ErrorForTooShortPrologueLength) {
@@ -408,16 +423,29 @@ TEST_P(DebugLineParameterisedFixture, ErrorForTooShortPrologueLength) { generate();
+ auto ExpectedLineTable = Line.getOrParseLineTable(LineData, 0, *Context,
+ nullptr, RecordRecoverable);
+ ASSERT_THAT_EXPECTED(ExpectedLineTable, Succeeded());
+ DWARFDebugLine::LineTable Result(**ExpectedLineTable);
+ // Undo the earlier modification so that it can be compared against a
+ // "default" prologue.
+ if (Version < 5)
+ Result.Prologue.PrologueLength += 2;
+ else
+ Result.Prologue.PrologueLength += 1;
+ checkDefaultPrologue(Version, Format, Result.Prologue, 0);
+
uint64_t ExpectedEnd =
Prologue.TotalLength - 1 + Prologue.sizeofTotalLength();
if (Version < 5)
--ExpectedEnd;
- checkGetOrParseLineTableEmitsFatalError(
+ checkError(
(Twine("parsing line table prologue at 0x00000000 should have ended at "
"0x000000") +
Twine::utohexstr(ExpectedEnd) + " but it ended at 0x000000" +
Twine::utohexstr(ExpectedEnd + 1))
- .str());
+ .str(),
+ std::move(Recoverable));
}
INSTANTIATE_TEST_CASE_P(
@@ -636,14 +664,15 @@ TEST_F(DebugLineBasicFixture, ParserSkipsCorrectly) { EXPECT_EQ(Parser.getOffset(), 0u);
ASSERT_FALSE(Parser.done());
- Parser.skip(RecordUnrecoverable);
+ Parser.skip(RecordRecoverable, RecordUnrecoverable);
EXPECT_EQ(Parser.getOffset(), 62u);
ASSERT_FALSE(Parser.done());
- Parser.skip(RecordUnrecoverable);
+ Parser.skip(RecordRecoverable, RecordUnrecoverable);
EXPECT_EQ(Parser.getOffset(), 136u);
EXPECT_TRUE(Parser.done());
+ EXPECT_FALSE(Recoverable);
EXPECT_FALSE(Unrecoverable);
}
@@ -688,10 +717,11 @@ TEST_F(DebugLineBasicFixture, ParserMovesToEndForBadLengthWhenSkipping) { generate();
DWARFDebugLine::SectionParser Parser(LineData, *Context, CUs, TUs);
- Parser.skip(RecordUnrecoverable);
+ Parser.skip(RecordRecoverable, RecordUnrecoverable);
EXPECT_EQ(Parser.getOffset(), 4u);
EXPECT_TRUE(Parser.done());
+ EXPECT_FALSE(Recoverable);
checkError("parsing line table prologue at offset 0x00000000 unsupported "
"reserved unit length found of value 0xfffffff0",
@@ -767,11 +797,12 @@ TEST_F(DebugLineBasicFixture, generate();
DWARFDebugLine::SectionParser Parser(LineData, *Context, CUs, TUs);
- Parser.skip(RecordUnrecoverable);
+ Parser.skip(RecordRecoverable, RecordUnrecoverable);
ASSERT_FALSE(Parser.done());
- Parser.skip(RecordUnrecoverable);
+ Parser.skip(RecordRecoverable, RecordUnrecoverable);
EXPECT_TRUE(Parser.done());
+ EXPECT_FALSE(Recoverable);
checkError({"parsing line table prologue at offset 0x00000000 found "
"unsupported version 0x00",
@@ -789,9 +820,10 @@ TEST_F(DebugLineBasicFixture, ParserIgnoresNonPrologueErrorsWhenSkipping) { generate();
DWARFDebugLine::SectionParser Parser(LineData, *Context, CUs, TUs);
- Parser.skip(RecordUnrecoverable);
+ Parser.skip(RecordRecoverable, RecordUnrecoverable);
EXPECT_TRUE(Parser.done());
+ EXPECT_FALSE(Recoverable);
EXPECT_FALSE(Unrecoverable);
}
|