[llvm] r314523 - [dwarfdump][NFC] Consistent printing of address ranges

Jonas Devlieghere via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 29 08:41:22 PDT 2017


Author: jdevlieghere
Date: Fri Sep 29 08:41:22 2017
New Revision: 314523

URL: http://llvm.org/viewvc/llvm-project?rev=314523&view=rev
Log:
[dwarfdump][NFC] Consistent printing of address ranges

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

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

Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h?rev=314523&r1=314522&r2=314523&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h Fri Sep 29 08:41:22 2017
@@ -57,6 +57,8 @@ static inline bool operator<(const DWARF
   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>;
 

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp?rev=314523&r1=314522&r2=314523&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp Fri Sep 29 08:41:22 2017
@@ -17,6 +17,11 @@
 
 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;

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp?rev=314523&r1=314522&r2=314523&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp Fri Sep 29 08:41:22 2017
@@ -315,9 +315,7 @@ unsigned DWARFVerifier::verifyDieRanges(
   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 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;
     }
   }

Modified: llvm/trunk/test/tools/llvm-dwarfdump/X86/verify_die_ranges.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/X86/verify_die_ranges.s?rev=314523&r1=314522&r2=314523&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/X86/verify_die_ranges.s (original)
+++ llvm/trunk/test/tools/llvm-dwarfdump/X86/verify_die_ranges.s Fri Sep 29 08:41:22 2017
@@ -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




More information about the llvm-commits mailing list