aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Henderson <james.henderson@sony.com>2020-02-11 14:11:01 +0000
committerJames Henderson <james.henderson@sony.com>2020-02-12 14:49:22 +0000
commit1da62b51a5f00a4b84843f3ecc8a495de618afc8 (patch)
tree904317af5cefe47d8e6b43d9eaae281479f59e97
parent61b35e4111160fe834a00c33d040e01150b576ac (diff)
downloadllvm-1da62b51a5f00a4b84843f3ecc8a495de618afc8.zip
llvm-1da62b51a5f00a4b84843f3ecc8a495de618afc8.tar.gz
llvm-1da62b51a5f00a4b84843f3ecc8a495de618afc8.tar.bz2
[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
-rw-r--r--lld/test/ELF/undef.s2
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp9
-rw-r--r--llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test4
-rw-r--r--llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp39
4 files changed, 26 insertions, 28 deletions
diff --git a/lld/test/ELF/undef.s b/lld/test/ELF/undef.s
index b8df045..f205343 100644
--- 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
index d3d2c58..2b4c492 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -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);
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test b/llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test
index 9eee365aa..60a15b4 100644
--- 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
index b0fdabb..795b9b4 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
@@ -339,37 +339,34 @@ TEST_F(DebugLineBasicFixture, ErrorForReservedLength) {
"unit length found of value 0xfffffff0");
}
-TEST_F(DebugLineBasicFixture, ErrorForLowVersion) {
- if (!setupGenerator())
- return;
-
- LineTable &LT = Gen->addLineTable();
- LT.setCustomPrologue(
- {{LineTable::Half, LineTable::Long}, {1, LineTable::Half}});
-
- generate();
+struct DebugLineUnsupportedVersionFixture : public TestWithParam<uint16_t>,
+ 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 &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));
}