]> granicus.if.org Git - llvm/commitdiff
[dwarfdump][NFC] Consistent printing of address ranges
authorJonas Devlieghere <jonas@devlieghere.com>
Fri, 29 Sep 2017 15:41:22 +0000 (15:41 +0000)
committerJonas Devlieghere <jonas@devlieghere.com>
Fri, 29 Sep 2017 15:41:22 +0000 (15:41 +0000)
This implement the insertion operator for DWARF address ranges so they
are consistently printed as [LowPC, HighPC).

While a dump method might have felt more consistent, it is used
exclusively for printing error messages in the verifier and never used
for actual dumping. Hence this approach is more intuitive and creates
less clutter at the call sites.

Differential revision: https://reviews.llvm.org/D38395

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314523 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h
lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp
lib/DebugInfo/DWARF/DWARFVerifier.cpp
test/tools/llvm-dwarfdump/X86/verify_die_ranges.s

index 0d97c2169e898baf74d9620407b7cd8e7472e3ba..f9ec96366a5382561bdcca77e8330cb703fc0f6e 100644 (file)
@@ -57,6 +57,8 @@ static inline bool operator<(const DWARFAddressRange &LHS,
   return std::tie(LHS.LowPC, LHS.HighPC) < std::tie(RHS.LowPC, RHS.HighPC);
 }
 
+raw_ostream &operator<<(raw_ostream &OS, const DWARFAddressRange &R);
+
 /// DWARFAddressRangesVector - represents a set of absolute address ranges.
 using DWARFAddressRangesVector = std::vector<DWARFAddressRange>;
 
index 62bd5af4e649924a3820e2e0edcce6db786408bf..f0b7ec2751de0d1b70623ab2a45f69949054d3bd 100644 (file)
 
 using namespace llvm;
 
+raw_ostream &llvm::operator<<(raw_ostream &OS, const DWARFAddressRange &R) {
+  return OS << format("[0x%16.16" PRIx64 ", 0x%16.16" PRIx64 ")", R.LowPC,
+                      R.HighPC);
+}
+
 void DWARFDebugRangeList::clear() {
   Offset = -1U;
   AddressSize = 0;
index 7f5ef1567ca7c1b1b494c8e52c0e673cd72107ed..27e6a05e6dd05f8805cec69715e418865d6bb844 100644 (file)
@@ -315,9 +315,7 @@ unsigned DWARFVerifier::verifyDieRanges(const DWARFDie &Die,
   for (auto Range : Ranges) {
     if (!Range.valid()) {
       ++NumErrors;
-      error() << format("Invalid address range [0x%08" PRIx64 " - 0x%08" PRIx64
-                        "].\n",
-                        Range.LowPC, Range.HighPC);
+      error() << "Invalid address range " << Range << "\n";
       continue;
     }
 
@@ -325,11 +323,8 @@ unsigned DWARFVerifier::verifyDieRanges(const DWARFDie &Die,
     const auto IntersectingRange = RI.insert(Range);
     if (IntersectingRange != RI.Ranges.end()) {
       ++NumErrors;
-      error() << format("DIE has overlapping address ranges: [0x%08" PRIx64
-                        " - 0x%08" PRIx64 "] and [0x%08" PRIx64
-                        " - 0x%08" PRIx64 "].\n",
-                        Range.LowPC, Range.HighPC, IntersectingRange->LowPC,
-                        IntersectingRange->HighPC);
+      error() << "DIE has overlapping address ranges: " << Range << " and "
+              << *IntersectingRange << "\n";
       break;
     }
   }
index 903f9e9ed022d738b4ef9dbf176ec4007a950984..540db462b13b7f7af5cd97bc74ad8f1476b115aa 100644 (file)
@@ -3,7 +3,7 @@
 # RUN: | FileCheck %s
 
 # CHECK: Verifying .debug_info Unit Header Chain...
-# CHECK-NEXT: error: Invalid address range [0x00000007 - 0x00000006].
+# CHECK-NEXT: error: Invalid address range [0x0000000000000007, 0x0000000000000006)
 
        .section        __TEXT,__text,regular,pure_instructions
        .macosx_version_min 10, 12