[lld] 1da62b5 - [DebugInfo] Print version in error message in decimal

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 12 06:49:45 PST 2020


Author: James Henderson
Date: 2020-02-12T14:49:22Z
New Revision: 1da62b51a5f00a4b84843f3ecc8a495de618afc8

URL: https://github.com/llvm/llvm-project/commit/1da62b51a5f00a4b84843f3ecc8a495de618afc8
DIFF: https://github.com/llvm/llvm-project/commit/1da62b51a5f00a4b84843f3ecc8a495de618afc8.diff

LOG: [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

Added: 
    

Modified: 
    lld/test/ELF/undef.s
    llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
    llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test
    llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp

Removed: 
    


################################################################################
diff  --git a/lld/test/ELF/undef.s b/lld/test/ELF/undef.s
index b8df0458539d..f2053433658d 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 d3d2c58d3395..2b4c492b4544 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 9eee365aaa1d..60a15b49496c 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 b0fdabb433f0..795b9b4436ed 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));
 }
 


        


More information about the llvm-commits mailing list