[llvm] de96042 - [DebugInfo] Refine error messages in DWARFDebugAddr.

Igor Kudrin via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 11 22:36:24 PST 2020


Author: Igor Kudrin
Date: 2020-02-12T13:33:00+07:00
New Revision: de9604232a7c9e346faadf3708b61431bb441c1b

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

LOG: [DebugInfo] Refine error messages in DWARFDebugAddr.

As a preparation for the subsequent patches, this updates the wordings
of some error messages in DWARFDebugAddr.

Differential Revision: https://reviews.llvm.org/D74196

Added: 
    

Modified: 
    llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp
    llvm/test/tools/llvm-dwarfdump/X86/debug_addr_invalid_addr_size.s
    llvm/test/tools/llvm-dwarfdump/X86/debug_addr_small_length_field.s
    llvm/test/tools/llvm-dwarfdump/X86/debug_addr_too_small_for_section.s
    llvm/test/tools/llvm-dwarfdump/X86/debug_addr_unsupported_version.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp
index 72aadda8c600..eb7070f55ca6 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp
@@ -51,22 +51,23 @@ Error DWARFDebugAddrTable::extract(DWARFDataExtractor Data,
           HeaderOffset);
     }
     if (HeaderData.Length + sizeof(uint32_t) < sizeof(Header)) {
-      uint32_t TmpLength = getLength();
+      uint32_t TmpLength = HeaderData.Length;
       invalidateLength();
       return createStringError(errc::invalid_argument,
                          "address table at offset 0x%" PRIx64
-                         " has too small length (0x%" PRIx32
-                         ") to contain a complete header",
+                         " has a unit_length value of 0x%" PRIx32
+                         ", which is too small to contain a complete header",
                          HeaderOffset, TmpLength);
     }
     uint64_t End = HeaderOffset + getLength();
     if (!Data.isValidOffsetForDataOfSize(HeaderOffset, End - HeaderOffset)) {
-      uint32_t TmpLength = getLength();
+      uint32_t TmpLength = HeaderData.Length;
       invalidateLength();
-      return createStringError(errc::invalid_argument,
+      return createStringError(
+          errc::invalid_argument,
           "section is not large enough to contain an address table "
-          "of length 0x%" PRIx32 " at offset 0x%" PRIx64,
-          TmpLength, HeaderOffset);
+          "at offset 0x%" PRIx64 " with a unit_length value of 0x%" PRIx32,
+          HeaderOffset, TmpLength);
     }
 
     HeaderData.Version = Data.getU16(OffsetPtr);
@@ -87,9 +88,10 @@ Error DWARFDebugAddrTable::extract(DWARFDataExtractor Data,
   // implementations of .debug_addr table, which doesn't contain a header
   // and consists only of a series of addresses.
   if (HeaderData.Version > 5) {
-    return createStringError(errc::not_supported, "version %" PRIu16
-        " of .debug_addr section at offset 0x%" PRIx64 " is not supported",
-        HeaderData.Version, HeaderOffset);
+    return createStringError(errc::not_supported,
+                             "address table at offset 0x%" PRIx64
+                             " has unsupported version %" PRIu16,
+                             HeaderOffset, HeaderData.Version);
   }
   // FIXME: For now we just treat version mismatch as an error,
   // however the correct way to associate a .debug_addr table
@@ -105,7 +107,8 @@ Error DWARFDebugAddrTable::extract(DWARFDataExtractor Data,
   if (HeaderData.AddrSize != 4 && HeaderData.AddrSize != 8)
     return createStringError(errc::not_supported,
                        "address table at offset 0x%" PRIx64
-                       " has unsupported address size %" PRIu8,
+                       " has unsupported address size %" PRIu8
+                       " (4 and 8 are supported)",
                        HeaderOffset, HeaderData.AddrSize);
   if (HeaderData.AddrSize != AddrSize && AddrSize != 0)
     WarnCallback(createStringError(

diff  --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_invalid_addr_size.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_invalid_addr_size.s
index 1ba1afebf5da..0ad055b2753d 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_invalid_addr_size.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_invalid_addr_size.s
@@ -4,7 +4,7 @@
 
 # CHECK: .debug_addr contents:
 # CHECK-NOT: {{.}}
-# ERR: unsupported address size 3
+# ERR: unsupported address size 3 (4 and 8 are supported)
 # ERR-NOT: {{.}}
 
 # invalid addr size

diff  --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_small_length_field.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_small_length_field.s
index 50c865f207dc..3b12737ddf59 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_small_length_field.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_small_length_field.s
@@ -4,7 +4,7 @@
 
 # CHECK: .debug_addr contents:
 # CHECK-NOT: {{.}}
-# ERR: address table at offset 0x0 has too small length (0x5) to contain a complete header
+# ERR: address table at offset 0x0 has a unit_length value of 0x1, which is too small to contain a complete header
 # ERR-NOT: {{.}}
 
 # too small length value

diff  --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_too_small_for_section.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_too_small_for_section.s
index 98468fa36812..5bd90617e259 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_too_small_for_section.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_too_small_for_section.s
@@ -4,7 +4,7 @@
 
 # CHECK: .debug_addr contents:
 # CHECK-NOT: {{.}}
-# ERR: section is not large enough to contain an address table of length 0x10 at offset 0x0
+# ERR: section is not large enough to contain an address table at offset 0x0 with a unit_length value of 0xc
 # ERR-NOT: {{.}}
 
 # too small section to contain section of given length

diff  --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_unsupported_version.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_unsupported_version.s
index f30dd8f0b979..c2afea30e5a0 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_unsupported_version.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_unsupported_version.s
@@ -2,7 +2,7 @@
 # RUN: llvm-dwarfdump -debug-addr - 2> %t.err | FileCheck %s
 # RUN: FileCheck %s -input-file %t.err -check-prefix=ERR
 
-# ERR: version 6 of .debug_addr section at offset 0x0 is not supported
+# ERR: address table at offset 0x0 has unsupported version 6
 # ERR-NOT: {{.}}
 
 # CHECK: .debug_addr contents


        


More information about the llvm-commits mailing list