[DebugInfo] Print version in error message in decimal

Also remove some test duplication and add a test case that shows the
maximum version is rejected (this also shows that the value in the error
message is actually in decimal, and not just missing an 0x prefix).

Reviewed by: dblaikie

Differential Revision: https://reviews.llvm.org/D74403
This commit is contained in:
James Henderson 2020-02-11 14:11:01 +00:00
parent 61b35e4111
commit 1da62b51a5
4 changed files with 28 additions and 30 deletions

View File

@ -52,7 +52,7 @@
# is requested, even if that particular part of the line information is not currently required.
# Also show that the warnings are only printed once.
# CHECK: warning: parsing line table prologue at 0x00000000 should have ended at 0x00000038 but it ended at 0x00000037
# CHECK-NEXT: warning: parsing line table prologue at offset 0x0000005b found unsupported version 0x01
# CHECK-NEXT: warning: parsing line table prologue at offset 0x0000005b found unsupported version 1
# CHECK-NEXT: warning: last sequence in debug line table at offset 0x00000061 is not terminated
# CHECK: error: undefined symbol: zed6a
# CHECK-NEXT: >>> referenced by undef-bad-debug.s:11 (dir{{/|\\}}undef-bad-debug.s:11)

View File

@ -331,10 +331,11 @@ Error DWARFDebugLine::Prologue::parse(
// Treat this error as unrecoverable - we cannot be sure what any of
// the data represents including the length field, so cannot skip it or make
// any reasonable assumptions.
return createStringError(errc::not_supported,
"parsing line table prologue at offset 0x%8.8" PRIx64
" found unsupported version 0x%2.2" PRIx16,
PrologueOffset, getVersion());
return createStringError(
errc::not_supported,
"parsing line table prologue at offset 0x%8.8" PRIx64
" found unsupported version %" PRIu16,
PrologueOffset, getVersion());
if (getVersion() >= 5) {
FormParams.AddrSize = DebugLineData.getU8(OffsetPtr);

View File

@ -165,8 +165,8 @@
# RESERVED: warning: parsing line table prologue at offset 0x00000048 unsupported reserved unit length found of value 0xfffffffe
# ALL-NOT: warning:
# ALL: warning: parsing line table prologue at offset 0x00000048 found unsupported version 0x00
# ALL-NEXT: warning: parsing line table prologue at offset 0x0000004e found unsupported version 0x01
# ALL: warning: parsing line table prologue at offset 0x00000048 found unsupported version 0
# ALL-NEXT: warning: parsing line table prologue at offset 0x0000004e found unsupported version 1
# ALL-NEXT: warning: parsing line table prologue at 0x00000054 found an invalid directory or file table description at 0x00000073
# ALL-NEXT: warning: failed to parse entry content descriptions because no path was found
# ALL-NEXT: warning: parsing line table prologue at 0x00000081 should have ended at 0x000000b9 but it ended at 0x000000ba

View File

@ -339,37 +339,34 @@ TEST_F(DebugLineBasicFixture, ErrorForReservedLength) {
"unit length found of value 0xfffffff0");
}
TEST_F(DebugLineBasicFixture, ErrorForLowVersion) {
struct DebugLineUnsupportedVersionFixture : public TestWithParam<uint16_t>,
public CommonFixture {
void SetUp() { Version = GetParam(); }
uint16_t Version;
};
TEST_P(DebugLineUnsupportedVersionFixture, ErrorForUnsupportedVersion) {
if (!setupGenerator())
return;
LineTable &LT = Gen->addLineTable();
LT.setCustomPrologue(
{{LineTable::Half, LineTable::Long}, {1, LineTable::Half}});
generate();
checkGetOrParseLineTableEmitsFatalError(
"parsing line table prologue at offset "
"0x00000000 found unsupported version "
"0x01");
}
TEST_F(DebugLineBasicFixture, ErrorForHighVersion) {
if (!setupGenerator())
return;
LineTable &LT = Gen->addLineTable();
LT.setCustomPrologue(
{{LineTable::Half, LineTable::Long}, {6, LineTable::Half}});
{{LineTable::Half, LineTable::Long}, {Version, LineTable::Half}});
generate();
checkGetOrParseLineTableEmitsFatalError(
"parsing line table prologue at offset 0x00000000 found unsupported "
"version 0x06");
"version " +
std::to_string(Version));
}
INSTANTIATE_TEST_CASE_P(UnsupportedVersionTestParams,
DebugLineUnsupportedVersionFixture,
Values(/*1 below min */ 1, /* 1 above max */ 6,
/* Maximum possible */ 0xffff), );
TEST_F(DebugLineBasicFixture, ErrorForInvalidV5IncludeDirTable) {
if (!setupGenerator(5))
return;
@ -785,9 +782,9 @@ TEST_F(DebugLineBasicFixture, ParserReportsFirstErrorInEachTableWhenParsing) {
EXPECT_FALSE(Recoverable);
checkError({"parsing line table prologue at offset 0x00000000 found "
"unsupported version 0x00",
"unsupported version 0",
"parsing line table prologue at offset 0x00000006 found "
"unsupported version 0x01"},
"unsupported version 1"},
std::move(Unrecoverable));
}
@ -843,9 +840,9 @@ TEST_F(DebugLineBasicFixture,
EXPECT_FALSE(Recoverable);
checkError({"parsing line table prologue at offset 0x00000000 found "
"unsupported version 0x00",
"unsupported version 0",
"parsing line table prologue at offset 0x00000006 found "
"unsupported version 0x01"},
"unsupported version 1"},
std::move(Unrecoverable));
}