diff --git a/lld/test/ELF/undef.s b/lld/test/ELF/undef.s --- a/lld/test/ELF/undef.s +++ b/lld/test/ELF/undef.s @@ -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) 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 @@ -331,10 +331,11 @@ // 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); 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 @@ -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 diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp --- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp +++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp @@ -339,37 +339,34 @@ "unit length found of value 0xfffffff0"); } -TEST_F(DebugLineBasicFixture, ErrorForLowVersion) { - if (!setupGenerator()) - return; - - LineTable < = Gen->addLineTable(); - LT.setCustomPrologue( - {{LineTable::Half, LineTable::Long}, {1, LineTable::Half}}); - - generate(); +struct DebugLineUnsupportedVersionFixture : public TestWithParam, + public CommonFixture { + void SetUp() { Version = GetParam(); } - checkGetOrParseLineTableEmitsFatalError( - "parsing line table prologue at offset " - "0x00000000 found unsupported version " - "0x01"); -} + uint16_t Version; +}; -TEST_F(DebugLineBasicFixture, ErrorForHighVersion) { +TEST_P(DebugLineUnsupportedVersionFixture, ErrorForUnsupportedVersion) { if (!setupGenerator()) return; LineTable < = 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 @@ 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 @@ 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)); }