Index: include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h +++ include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h @@ -43,6 +43,7 @@ uint64_t Length; uint64_t getEndAddress() const { return Address + Length; } + void dump(raw_ostream &OS, uint32_t AddressSize) const; }; private: Index: include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h +++ include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h @@ -50,6 +50,8 @@ return LowPC <= RHS.HighPC && RHS.HighPC <= HighPC; return false; } + + void dump(raw_ostream &OS, uint32_t AddressSize) const; }; static inline bool operator<(const DWARFAddressRange &LHS, Index: lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp +++ lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp @@ -17,6 +17,13 @@ using namespace llvm; +void DWARFDebugArangeSet::Descriptor::dump(raw_ostream &OS, + uint32_t AddressSize) const { + OS << format("[0x%*.*" PRIx64 ", ", AddressSize * 2, AddressSize * 2, Address) + << format(" 0x%*.*" PRIx64 ")", AddressSize * 2, AddressSize * 2, + getEndAddress()); +} + void DWARFDebugArangeSet::clear() { Offset = -1U; std::memset(&HeaderData, 0, sizeof(Header)); @@ -98,10 +105,8 @@ << format("cu_offset = 0x%8.8x, addr_size = 0x%2.2x, seg_size = 0x%2.2x\n", HeaderData.CuOffset, HeaderData.AddrSize, HeaderData.SegSize); - const uint32_t hex_width = HeaderData.AddrSize * 2; for (const auto &Desc : ArangeDescriptors) { - OS << format("[0x%*.*" PRIx64 " -", hex_width, hex_width, Desc.Address) - << format(" 0x%*.*" PRIx64 ")\n", - hex_width, hex_width, Desc.getEndAddress()); + Desc.dump(OS, HeaderData.AddrSize); + OS << '\n'; } } Index: lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp +++ lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp @@ -17,9 +17,15 @@ using namespace llvm; +void DWARFAddressRange::dump(raw_ostream &OS, uint32_t AddressSize) const { + + OS << format("[0x%*.*" PRIx64 ", ", AddressSize * 2, AddressSize * 2, LowPC) + << format(" 0x%*.*" PRIx64 ")", AddressSize * 2, AddressSize * 2, HighPC); +} + 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); + R.dump(OS, /* AddressSize */ 8); + return OS; } void DWARFDebugRangeList::clear() { Index: lib/DebugInfo/DWARF/DWARFDie.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDie.cpp +++ lib/DebugInfo/DWARF/DWARFDie.cpp @@ -62,13 +62,11 @@ if (DumpOpts.Verbose) SectionNames = Obj.getSectionNames(); - for (size_t I = 0; I < Ranges.size(); ++I) { - const DWARFAddressRange &R = Ranges[I]; + for (const DWARFAddressRange &R : Ranges) { OS << '\n'; OS.indent(Indent); - OS << format("[0x%0*" PRIx64 " - 0x%0*" PRIx64 ")", AddressSize * 2, - R.LowPC, AddressSize * 2, R.HighPC); + R.dump(OS, AddressSize); if (SectionNames.empty() || R.SectionIndex == -1ULL) continue; Index: test/DebugInfo/X86/dwarfdump-ranges-baseaddr-exe.s =================================================================== --- test/DebugInfo/X86/dwarfdump-ranges-baseaddr-exe.s +++ test/DebugInfo/X86/dwarfdump-ranges-baseaddr-exe.s @@ -1,13 +1,13 @@ # RUN: llvm-dwarfdump -v %S/../Inputs/dwarfdump-ranges-baseaddr-exe.elf-x86-64 \ # RUN: | FileCheck %s -## Executable binary for test produced from object built in +## Executable binary for test produced from object built in ## dwarfdump-ranges-baseaddr.s testcase. # CHECK: .debug_info contents: # CHECK: 0x0000000b: DW_TAG_compile_unit [1] # CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000000400078) # CHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset] (0x00000000 -# CHECK-NEXT: [0x0000000000400078 - 0x0000000000400079) -# CHECK-NEXT: [0x000000000040007b - 0x000000000040007e) -# CHECK-NEXT: [0x000000000040007f - 0x0000000000400080)) +# CHECK-NEXT: [0x0000000000400078, 0x0000000000400079) +# CHECK-NEXT: [0x000000000040007b, 0x000000000040007e) +# CHECK-NEXT: [0x000000000040007f, 0x0000000000400080)) Index: test/DebugInfo/X86/dwarfdump-ranges-baseaddr.s =================================================================== --- test/DebugInfo/X86/dwarfdump-ranges-baseaddr.s +++ test/DebugInfo/X86/dwarfdump-ranges-baseaddr.s @@ -5,14 +5,14 @@ # CHECK: 0x0000000b: DW_TAG_compile_unit [1] # CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000) # CHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset] (0x00000000 -# CHECK-NEXT: [0x0000000000000000 - 0x0000000000000001) ".text" -# CHECK-NEXT: [0x0000000000000003 - 0x0000000000000006) ".text" -# CHECK-NEXT: [0x0000000000000001 - 0x0000000000000002) ".text.foo1") +# CHECK-NEXT: [0x0000000000000000, 0x0000000000000001) ".text" +# CHECK-NEXT: [0x0000000000000003, 0x0000000000000006) ".text" +# CHECK-NEXT: [0x0000000000000001, 0x0000000000000002) ".text.foo1") .text .globl foo .type foo,@function -foo: +foo: .Lfunc_begin0: nop .Ltmp0: @@ -27,7 +27,7 @@ .section .text.foo1,"ax",@progbits .Ltmp3: nop -.Ltmp4: +.Ltmp4: nop .Ltmp5: Index: test/DebugInfo/X86/dwarfdump-ranges-unrelocated.s =================================================================== --- test/DebugInfo/X86/dwarfdump-ranges-unrelocated.s +++ test/DebugInfo/X86/dwarfdump-ranges-unrelocated.s @@ -4,9 +4,9 @@ # CHECK: .debug_info contents: # CHECK: DW_TAG_compile_unit # CHECK: DW_AT_ranges [DW_FORM_sec_offset] (0x00000000 -# CHECK-NEXT: [0x0000000000000000 - 0x0000000000000001) ".text.foo1" -# CHECK-NEXT: [0x0000000000000000 - 0x0000000000000002) ".text.foo2" [4] -# CHECK-NEXT: [0x0000000000000000 - 0x0000000000000003) ".text.foo2" [5]) +# CHECK-NEXT: [0x0000000000000000, 0x0000000000000001) ".text.foo1" +# CHECK-NEXT: [0x0000000000000000, 0x0000000000000002) ".text.foo2" [4] +# CHECK-NEXT: [0x0000000000000000, 0x0000000000000003) ".text.foo2" [5]) # CHECK: .debug_ranges contents: # CHECK: 00000000 0000000000000000 0000000000000001 @@ -17,16 +17,16 @@ # RUN: llvm-dwarfdump %t | FileCheck %s --check-prefix=BRIEF # BRIEF: DW_TAG_compile_unit # BRIEF: DW_AT_ranges (0x00000000 -# BRIEF-NEXT: [0x0000000000000000 - 0x0000000000000001) -# BRIEF-NEXT: [0x0000000000000000 - 0x0000000000000002) -# BRIEF-NEXT: [0x0000000000000000 - 0x0000000000000003)) +# BRIEF-NEXT: [0x0000000000000000, 0x0000000000000001) +# BRIEF-NEXT: [0x0000000000000000, 0x0000000000000002) +# BRIEF-NEXT: [0x0000000000000000, 0x0000000000000003)) ## Asm code for testcase is a reduced and modified output from next ## invocation and source: # clang test.cpp -S -o test.s -gmlt -ffunction-sections # test.cpp: -# void foo1() { } -# void foo2() { } +# void foo1() { } +# void foo2() { } .section .text.foo1,"ax",@progbits .Lfunc_begin0: Index: test/DebugInfo/dwarfdump-ranges.test =================================================================== --- test/DebugInfo/dwarfdump-ranges.test +++ test/DebugInfo/dwarfdump-ranges.test @@ -4,14 +4,14 @@ CHECK: DW_TAG_compile_unit CHECK-NOT: TAG CHECK: DW_AT_ranges [DW_FORM_data4] (0x00000000 -CHECK-NEXT: [0x000000000000062c - 0x0000000000000637) -CHECK-NEXT: [0x0000000000000637 - 0x000000000000063d)) +CHECK-NEXT: [0x000000000000062c, 0x0000000000000637) +CHECK-NEXT: [0x0000000000000637, 0x000000000000063d)) CHECK: DW_TAG_compile_unit CHECK-NOT: TAG CHECK: DW_AT_ranges [DW_FORM_data4] (0x00000030 -CHECK-NEXT: [0x0000000000000640 - 0x000000000000064b) -CHECK-NEXT: [0x0000000000000637 - 0x000000000000063d)) +CHECK-NEXT: [0x0000000000000640, 0x000000000000064b) +CHECK-NEXT: [0x0000000000000637, 0x000000000000063d)) CHECK: .debug_ranges contents: Index: test/tools/dsymutil/X86/basic-linking-x86.test =================================================================== --- test/tools/dsymutil/X86/basic-linking-x86.test +++ test/tools/dsymutil/X86/basic-linking-x86.test @@ -144,13 +144,13 @@ CHECK:.debug_aranges contents: CHECK-NEXT:Address Range Header: length = 0x0000002c, version = 0x0002, cu_offset = 0x00000000, addr_size = 0x08, seg_size = 0x00 -CHECK-NEXT:[0x0000000100000ea0 - 0x0000000100000ec4) +CHECK-NEXT:[0x0000000100000ea0, 0x0000000100000ec4) CHECK-NEXT:Address Range Header: length = 0x0000003c, version = 0x0002, cu_offset = 0x00000081, addr_size = 0x08, seg_size = 0x00 -CHECK-NEXT:[0x0000000100000ed0 - 0x0000000100000f19) -CHECK-NEXT:[0x0000000100000f20 - 0x0000000100000f37) +CHECK-NEXT:[0x0000000100000ed0, 0x0000000100000f19) +CHECK-NEXT:[0x0000000100000f20, 0x0000000100000f37) CHECK-NEXT:Address Range Header: length = 0x0000003c, version = 0x0002, cu_offset = 0x00000126, addr_size = 0x08, seg_size = 0x00 -CHECK-NEXT:[0x0000000100000f40 - 0x0000000100000f84) -CHECK-NEXT:[0x0000000100000f90 - 0x0000000100000fa9) +CHECK-NEXT:[0x0000000100000f40, 0x0000000100000f84) +CHECK-NEXT:[0x0000000100000f90, 0x0000000100000fa9) CHECK: .debug_line contents: CHECK: Dir Mod Time File Len File Name Index: test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test =================================================================== --- test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test +++ test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test @@ -113,8 +113,8 @@ CHECK: DW_TAG_inlined_subroutine CHECK: DW_AT_abstract_origin (cu + 0x0044 "inc") CHECK: DW_AT_ranges (0x00000000 -CHECK: [0x0000000100000f94 - 0x0000000100000f9a) -CHECK: [0x0000000100000f9f - 0x0000000100000fa7)) +CHECK: [0x0000000100000f94, 0x0000000100000f9a) +CHECK: [0x0000000100000f9f, 0x0000000100000fa7)) CHECK: NULL CHECK: NULL @@ -131,11 +131,11 @@ CHECK: .debug_aranges contents: CHECK-NEXT: Address Range Header: length = 0x0000002c, version = 0x0002, cu_offset = 0x00000000, addr_size = 0x08, seg_size = 0x00 -CHECK-NEXT: [0x0000000100000f40 - 0x0000000100000f4b) +CHECK-NEXT: [0x0000000100000f40, 0x0000000100000f4b) CHECK-NEXT: Address Range Header: length = 0x0000002c, version = 0x0002, cu_offset = 0x00000077, addr_size = 0x08, seg_size = 0x00 -CHECK-NEXT: [0x0000000100000f50 - 0x0000000100000f87) +CHECK-NEXT: [0x0000000100000f50, 0x0000000100000f87) CHECK-NEXT: Address Range Header: length = 0x0000002c, version = 0x0002, cu_offset = 0x0000011b, addr_size = 0x08, seg_size = 0x00 -CHECK-NEXT: [0x0000000100000f90 - 0x0000000100000fb4) +CHECK-NEXT: [0x0000000100000f90, 0x0000000100000fb4) CHECK: .debug_line contents: CHECK: Dir Mod Time File Len File Name Index: test/tools/dsymutil/X86/basic-lto-linking-x86.test =================================================================== --- test/tools/dsymutil/X86/basic-lto-linking-x86.test +++ test/tools/dsymutil/X86/basic-lto-linking-x86.test @@ -123,8 +123,8 @@ CHECK: DW_TAG_inlined_subroutine CHECK: DW_AT_abstract_origin (cu + 0x009a "inc") CHECK: DW_AT_ranges (0x00000000 -CHECK: [0x0000000100000f94 - 0x0000000100000f9a) -CHECK: [0x0000000100000f9f - 0x0000000100000fa7)) +CHECK: [0x0000000100000f94, 0x0000000100000f9a) +CHECK: [0x0000000100000f9f, 0x0000000100000fa7)) CHECK: NULL CHECK: NULL CHECK: DW_TAG_subprogram @@ -142,11 +142,11 @@ CHECK: .debug_aranges contents: CHECK-NEXT: Address Range Header: length = 0x0000002c, version = 0x0002, cu_offset = 0x00000000, addr_size = 0x08, seg_size = 0x00 -CHECK-NEXT: [0x0000000100000f40 - 0x0000000100000f4b) +CHECK-NEXT: [0x0000000100000f40, 0x0000000100000f4b) CHECK-NEXT: Address Range Header: length = 0x0000002c, version = 0x0002, cu_offset = 0x00000081, addr_size = 0x08, seg_size = 0x00 -CHECK-NEXT: [0x0000000100000f50 - 0x0000000100000f89) +CHECK-NEXT: [0x0000000100000f50, 0x0000000100000f89) CHECK-NEXT: Address Range Header: length = 0x0000002c, version = 0x0002, cu_offset = 0x0000013a, addr_size = 0x08, seg_size = 0x00 -CHECK-NEXT: [0x0000000100000f90 - 0x0000000100000fb4) +CHECK-NEXT: [0x0000000100000f90, 0x0000000100000fb4) CHECK: .debug_line contents