Index: llvm/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h =================================================================== --- llvm/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h +++ llvm/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h @@ -25,6 +25,8 @@ /// The total length of the entries for that set, not including the length /// field itself. uint64_t Length; + /// The DWARF format of the set. + dwarf::DwarfFormat Format; /// The offset from the beginning of the .debug_info section of the /// compilation unit entry referenced by the table. uint64_t CuOffset; Index: llvm/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h =================================================================== --- llvm/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h +++ llvm/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h @@ -44,6 +44,9 @@ /// field itself. uint64_t Length; + /// The DWARF format of the set. + dwarf::DwarfFormat Format; + /// This number is specific to the name lookup table and is independent of /// the DWARF version number. uint16_t Version; Index: llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h =================================================================== --- llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h +++ llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h @@ -291,6 +291,7 @@ return Header.getDwarfOffsetByteSize(); } uint64_t getLength() const { return Header.getLength(); } + dwarf::DwarfFormat getFormat() const { return Header.getFormat(); } uint8_t getUnitType() const { return Header.getUnitType(); } bool isTypeUnit() const { return Header.isTypeUnit(); } uint64_t getNextUnitOffset() const { return Header.getNextUnitOffset(); } Index: llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp =================================================================== --- llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp +++ llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp @@ -365,6 +365,8 @@ void DWARFDebugNames::Header::dump(ScopedPrinter &W) const { DictScope HeaderScope(W, "Header"); W.printHex("Length", UnitLength); + if (Format == dwarf::DWARF64) + W.printString("Format", "DWARF64"); W.printNumber("Version", Version); W.printNumber("CU count", CompUnitCount); W.printNumber("Local TU count", LocalTypeUnitCount); Index: llvm/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp =================================================================== --- llvm/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp +++ llvm/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp @@ -16,8 +16,10 @@ void DWARFCompileUnit::dump(raw_ostream &OS, DIDumpOptions DumpOpts) { OS << format("0x%08" PRIx64, getOffset()) << ": Compile Unit:" - << " length = " << format("0x%08" PRIx64, getLength()) - << " version = " << format("0x%04x", getVersion()); + << " length = " << format("0x%08" PRIx64, getLength()); + if (getFormat() == dwarf::DWARF64) + OS << " format = DWARF64"; + OS << " version = " << format("0x%04x", getVersion()); if (getVersion() >= 5) OS << " unit_type = " << dwarf::UnitTypeString(getUnitType()); OS << " abbr_offset = " Index: llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp =================================================================== --- llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp +++ llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp @@ -138,11 +138,14 @@ if (DumpOpts.Verbose) OS << format("0x%8.8" PRIx64 ": ", Offset); if (Length) { - int LengthFieldWidth = (Format == dwarf::DwarfFormat::DWARF64) ? 16 : 8; - OS << format("Address table header: length = 0x%0*" PRIx64 - ", version = 0x%4.4" PRIx16 ", addr_size = 0x%2.2" PRIx8 + OS << "Address table header: "; + if (Format == dwarf::DwarfFormat::DWARF64) + OS << format("length = 0x%016" PRIx64 ", format = DWARF64", Length); + else + OS << format("length = 0x%08" PRIx64, Length); + OS << format(", version = 0x%4.4" PRIx16 ", addr_size = 0x%2.2" PRIx8 ", seg_size = 0x%2.2" PRIx8 "\n", - LengthFieldWidth, Length, Version, AddrSize, SegSize); + Version, AddrSize, SegSize); } if (Addrs.size() > 0) { Index: llvm/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp =================================================================== --- llvm/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp +++ llvm/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp @@ -60,12 +60,12 @@ // the segment selectors are omitted from all tuples, including // the terminating tuple. - dwarf::DwarfFormat format; Error Err = Error::success(); - std::tie(HeaderData.Length, format) = data.getInitialLength(offset_ptr, &Err); + std::tie(HeaderData.Length, HeaderData.Format) = + data.getInitialLength(offset_ptr, &Err); HeaderData.Version = data.getU16(offset_ptr, &Err); - HeaderData.CuOffset = - data.getUnsigned(offset_ptr, dwarf::getDwarfOffsetByteSize(format), &Err); + HeaderData.CuOffset = data.getUnsigned( + offset_ptr, dwarf::getDwarfOffsetByteSize(HeaderData.Format), &Err); HeaderData.AddrSize = data.getU8(offset_ptr, &Err); HeaderData.SegSize = data.getU8(offset_ptr, &Err); if (Err) { @@ -77,7 +77,7 @@ // Perform basic validation of the header fields. uint64_t full_length = - dwarf::getUnitLengthFieldByteSize(format) + HeaderData.Length; + dwarf::getUnitLengthFieldByteSize(HeaderData.Format) + HeaderData.Length; if (!data.isValidOffsetForDataOfSize(Offset, full_length)) return createStringError(errc::invalid_argument, "the length of address range table at offset " @@ -158,8 +158,10 @@ void DWARFDebugArangeSet::dump(raw_ostream &OS) const { OS << "Address Range Header: " - << format("length = 0x%8.8" PRIx64 ", ", HeaderData.Length) - << format("version = 0x%4.4x, ", HeaderData.Version) + << format("length = 0x%8.8" PRIx64 ", ", HeaderData.Length); + if (HeaderData.Format == dwarf::DWARF64) + OS << "format = DWARF64, "; + OS << format("version = 0x%4.4x, ", HeaderData.Version) << format("cu_offset = 0x%8.8" PRIx64 ", ", HeaderData.CuOffset) << format("addr_size = 0x%2.2x, ", HeaderData.AddrSize) << format("seg_size = 0x%2.2x\n", HeaderData.SegSize); Index: llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp =================================================================== --- llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp +++ llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp @@ -303,6 +303,8 @@ << format(" %0*" PRIx64, IsDWARF64 && !IsEH ? 16 : 8, getCIEId(IsDWARF64, IsEH)) << " CIE\n"; + if (IsDWARF64) + OS << " Format: DWARF64\n"; OS << format(" Version: %d\n", Version); OS << " Augmentation: \"" << Augmentation << "\"\n"; if (Version >= 4) { @@ -337,6 +339,8 @@ OS << ""; OS << format(" pc=%08" PRIx64 "...%08" PRIx64 "\n", InitialLocation, InitialLocation + AddressRange); + if (IsDWARF64) + OS << " Format: DWARF64\n"; if (LSDAAddress) OS << format(" LSDA Address: %016" PRIx64 "\n", *LSDAAddress); CFIs.dump(OS, MRI, IsEH); Index: llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp =================================================================== --- llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -107,8 +107,10 @@ if (!totalLengthIsValid()) return; OS << "Line table prologue:\n" - << format(" total_length: 0x%8.8" PRIx64 "\n", TotalLength) - << format(" version: %u\n", getVersion()); + << format(" total_length: 0x%8.8" PRIx64 "\n", TotalLength); + if (isDWARF64()) + OS << " format: DWARF64\n"; + OS << format(" version: %u\n", getVersion()); if (!versionIsSupported(getVersion())) return; if (getVersion() >= 5) Index: llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp =================================================================== --- llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp +++ llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp @@ -28,9 +28,9 @@ Sets.push_back({}); Set &SetData = Sets.back(); - dwarf::DwarfFormat Format; - std::tie(SetData.Length, Format) = PubNames.getInitialLength(&Offset); - const unsigned OffsetSize = dwarf::getDwarfOffsetByteSize(Format); + std::tie(SetData.Length, SetData.Format) = + PubNames.getInitialLength(&Offset); + const unsigned OffsetSize = dwarf::getDwarfOffsetByteSize(SetData.Format); SetData.Version = PubNames.getU16(&Offset); SetData.Offset = PubNames.getRelocatedValue(OffsetSize, &Offset); @@ -51,6 +51,8 @@ void DWARFDebugPubTable::dump(raw_ostream &OS) const { for (const Set &S : Sets) { OS << "length = " << format("0x%08" PRIx64, S.Length); + if (S.Format == dwarf::DWARF64) + OS << " format = DWARF64"; OS << " version = " << format("0x%04x", S.Version); OS << " unit_offset = " << format("0x%08" PRIx64, S.Offset); OS << " unit_size = " << format("0x%08" PRIx64, S.Size) << '\n'; Index: llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp =================================================================== --- llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp +++ llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp @@ -79,13 +79,15 @@ void DWARFListTableHeader::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const { if (DumpOpts.Verbose) OS << format("0x%8.8" PRIx64 ": ", HeaderOffset); - OS << format( - "%s list header: length = 0x%8.8" PRIx64 ", version = 0x%4.4" PRIx16 ", " - "addr_size = 0x%2.2" PRIx8 ", seg_size = 0x%2.2" PRIx8 - ", offset_entry_count = " - "0x%8.8" PRIx32 "\n", - ListTypeString.data(), HeaderData.Length, HeaderData.Version, - HeaderData.AddrSize, HeaderData.SegSize, HeaderData.OffsetEntryCount); + OS << format("%s list header: length = 0x%8.8" PRIx64, ListTypeString.data(), + HeaderData.Length); + if (Format == dwarf::DWARF64) + OS << ", format = DWARF64"; + OS << format(", version = 0x%4.4" PRIx16 ", addr_size = 0x%2.2" PRIx8 + ", seg_size = 0x%2.2" PRIx8 + ", offset_entry_count = 0x%8.8" PRIx32 "\n", + HeaderData.Version, HeaderData.AddrSize, HeaderData.SegSize, + HeaderData.OffsetEntryCount); if (HeaderData.OffsetEntryCount > 0) { OS << "offsets: ["; Index: llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp =================================================================== --- llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp +++ llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp @@ -29,8 +29,10 @@ } OS << format("0x%08" PRIx64, getOffset()) << ": Type Unit:" - << " length = " << format("0x%08" PRIx64, getLength()) - << " version = " << format("0x%04x", getVersion()); + << " length = " << format("0x%08" PRIx64, getLength()); + if (getFormat() == dwarf::DWARF64) + OS << " format = DWARF64"; + OS << " version = " << format("0x%04x", getVersion()); if (getVersion() >= 5) OS << " unit_type = " << dwarf::UnitTypeString(getUnitType()); OS << " abbr_offset = " Index: llvm/test/DebugInfo/X86/debug-frame-dwarf64.s =================================================================== --- /dev/null +++ llvm/test/DebugInfo/X86/debug-frame-dwarf64.s @@ -0,0 +1,33 @@ +# RUN: llvm-mc -triple x86_64 %s -filetype=obj -o - | \ +# RUN: llvm-dwarfdump -debug-frame - | \ +# RUN: FileCheck %s + +# CHECK: .debug_frame contents: +# CHECK: CIE +# CHECK-NEXT: Format: DWARF64 +# CHECK: FDE +# CHECK-NEXT: Format: DWARF64 + + .section .debug_frame, "", @progbits +.LCIE: + .long 0xffffffff # DWARF64 mark + .quad .LCIEend-.LCIEid # Length +.LCIEid: + .quad 0xffffffffffffffff # CIE id + .byte 4 # Version + .asciz "" # Augmentation + .byte 8 # Address size + .byte 0 # Segment selector size + .uleb128 1 # Code alignment factor + .sleb128 -8 # Data alignment factor + .uleb128 16 # Return address register + .byte 0 # DW_CFA_nop +.LCIEend: +.LFDE: + .long 0xffffffff # DWARF64 mark + .quad .LFDEend-.LFDEcieptr # Length +.LFDEcieptr: + .quad .LCIE-.debug_frame # CIE pointer + .quad 0x00112233 # Initial location + .quad 0x00010000 # Address range +.LFDEend: Index: llvm/test/DebugInfo/X86/dwarfdump-debug-aranges.s =================================================================== --- llvm/test/DebugInfo/X86/dwarfdump-debug-aranges.s +++ llvm/test/DebugInfo/X86/dwarfdump-debug-aranges.s @@ -67,7 +67,7 @@ ## Case 4: Check that 64-bit DWARF format is supported. .long 0xffffffff # DWARF64 mark .quad .L4end - .L4version # Length -# CHECK: Address Range Header: length = 0x0000001c, +# CHECK: Address Range Header: length = 0x0000001c, format = DWARF64, .L4version: .short 2 # Version .quad 0x1234567899aabbcc # Debug Info Offset Index: llvm/test/DebugInfo/X86/dwarfdump-debug-names.s =================================================================== --- llvm/test/DebugInfo/X86/dwarfdump-debug-names.s +++ llvm/test/DebugInfo/X86/dwarfdump-debug-names.s @@ -215,6 +215,7 @@ # CHECK-NEXT: Name Index @ 0xac { # CHECK-NEXT: Header { # CHECK-NEXT: Length: 0x68 +# CHECK-NEXT: Format: DWARF64 # CHECK-NEXT: Version: 5 # CHECK-NEXT: CU count: 1 # CHECK-NEXT: Local TU count: 1 Index: llvm/test/DebugInfo/X86/dwarfdump-debug-pubnames.s =================================================================== --- llvm/test/DebugInfo/X86/dwarfdump-debug-pubnames.s +++ llvm/test/DebugInfo/X86/dwarfdump-debug-pubnames.s @@ -4,6 +4,7 @@ # CHECK: .debug_pubnames contents: # CHECK-NEXT: length = 0x00000032 +# CHECK-SAME: format = DWARF64 # CHECK-SAME: version = 0x0002 # CHECK-SAME: unit_offset = 0x1122334455667788 # CHECK-SAME: unit_size = 0x1100220033004400 Index: llvm/test/DebugInfo/X86/dwarfdump-rnglists-dwarf64.s =================================================================== --- llvm/test/DebugInfo/X86/dwarfdump-rnglists-dwarf64.s +++ llvm/test/DebugInfo/X86/dwarfdump-rnglists-dwarf64.s @@ -3,6 +3,8 @@ # RUN: FileCheck %s --input-file %t.err --check-prefix=ERR # RUN: not llvm-dwarfdump -lookup 10 %t.o 2> %t2.err # RUN: FileCheck %s --input-file %t2.err --check-prefix=ERR +# RUN: llvm-dwarfdump -debug-rnglists %t.o | \ +# RUN: FileCheck %s --check-prefix=RNGLISTS # Test object to verify dwarfdump handles v5 range lists in 64-bit DWARF format. # This is similar to 'dwarfdump-rnglists.s', which uses 32-bit DWARF format. @@ -207,6 +209,43 @@ # CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000025 # CHECK-NEXT: [0x0000002a, 0x00000034)) +# RNGLISTS: .debug_rnglists contents: +# RNGLISTS: range list header: +# RNGLISTS-SAME: length = 0x00000031, +# RNGLISTS-SAME: format = DWARF64, +# RNGLISTS-SAME: version = 0x0005, +# RNGLISTS-SAME: addr_size = 0x04, +# RNGLISTS-SAME: seg_size = 0x00, +# RNGLISTS-SAME: offset_entry_count = 0x00000002 +# RNGLISTS-NEXT: offsets: [ +# RNGLISTS-NEXT: 0x00000010 +# RNGLISTS-NEXT: 0x00000020 +# RNGLISTS-NEXT: ] +# RNGLISTS-NEXT: ranges: +# RNGLISTS-NEXT: [0x00000014, 0x0000001e) +# RNGLISTS-NEXT: [0x0000002a, 0x00000034) +# RNGLISTS-NEXT: +# RNGLISTS-NEXT: [0x0000002a, 0x00000034) +# RNGLISTS-NEXT: + +# RNGLISTS: .debug_rnglists.dwo contents: +# RNGLISTS: range list header: +# RNGLISTS-SAME: length = 0x00000022, +# RNGLISTS-SAME: format = DWARF64, +# RNGLISTS-SAME: version = 0x0005, +# RNGLISTS-SAME: addr_size = 0x04, +# RNGLISTS-SAME: seg_size = 0x00, +# RNGLISTS-SAME: offset_entry_count = 0x00000002 +# RNGLISTS-NEXT: offsets: [ +# RNGLISTS-NEXT: 0x00000010 +# RNGLISTS-NEXT: 0x00000011 +# RNGLISTS-NEXT: ] +# RNGLISTS-NEXT: ranges: +# RNGLISTS-NEXT: +# RNGLISTS-NEXT: [0x0000002a, 0x00000034) +# RNGLISTS-NEXT: + + #ERR: error: parsing a range list table: did not detect a valid list table with base = 0x8 #ERR: error: decoding address ranges: missing or invalid range list table #ERR: error: decoding address ranges: invalid range list offset 0xfa0 Index: llvm/test/DebugInfo/dwarfdump-64-bit-dwarf.test =================================================================== --- llvm/test/DebugInfo/dwarfdump-64-bit-dwarf.test +++ llvm/test/DebugInfo/dwarfdump-64-bit-dwarf.test @@ -1,10 +1,11 @@ RUN: llvm-dwarfdump %p/Inputs/dwarfdump.elf-mips64-64-bit-dwarf \ -RUN: --debug-line | FileCheck %s +RUN: --debug-line | FileCheck %s # FIXME: llvm-dwarfdump's support for 64-bit dwarf is currently limited to # .debug_line. CHECK: total_length: 0x00000212 +CHECK: format: DWARF64 CHECK: version: 2 CHECK:prologue_length: 0x000001ab CHECK:min_inst_length: 1 @@ -15,6 +16,7 @@ CHECK: is_stmt end_sequence CHECK: total_length: 0x0000007c +CHECK: format: DWARF64 CHECK: version: 2 CHECK:prologue_length: 0x00000048 CHECK:min_inst_length: 1 @@ -25,6 +27,7 @@ CHECK: is_stmt end_sequence CHECK: total_length: 0x00000094 +CHECK: format: DWARF64 CHECK: version: 2 CHECK:prologue_length: 0x00000044 CHECK:min_inst_length: 1 @@ -35,6 +38,7 @@ CHECK: is_stmt end_sequence CHECK: total_length: 0x0000007c +CHECK: format: DWARF64 CHECK: version: 2 CHECK:prologue_length: 0x00000048 CHECK:min_inst_length: 1 Index: llvm/test/tools/llvm-dwarfdump/X86/debug_addr_dwarf64.s =================================================================== --- llvm/test/tools/llvm-dwarfdump/X86/debug_addr_dwarf64.s +++ llvm/test/tools/llvm-dwarfdump/X86/debug_addr_dwarf64.s @@ -5,6 +5,7 @@ # CHECK: .debug_addr contents: # CHECK-NEXT: Address table header: # CHECK-SAME: length = 0x000000000000000c, +# CHECK-SAME: format = DWARF64, # CHECK-SAME: version = 0x0005, # CHECK-SAME: addr_size = 0x04, # CHECK-SAME: seg_size = 0x00 Index: llvm/test/tools/llvm-dwarfdump/X86/debug_info_min_dwarf64.s =================================================================== --- llvm/test/tools/llvm-dwarfdump/X86/debug_info_min_dwarf64.s +++ llvm/test/tools/llvm-dwarfdump/X86/debug_info_min_dwarf64.s @@ -18,7 +18,7 @@ DI_4_64_start: .long 0xffffffff # DWARF64 mark .quad DI_4_64_end - DI_4_64_version # Length of Unit -# CHECK-SAME: length = 0x0000000f +# CHECK-SAME: length = 0x0000000f format = DWARF64 DI_4_64_version: .short 4 # DWARF version number # CHECK-SAME: version = 0x0004 Index: llvm/test/tools/llvm-dwarfdump/X86/debug_line_dwarf64_large_table.s =================================================================== --- llvm/test/tools/llvm-dwarfdump/X86/debug_line_dwarf64_large_table.s +++ llvm/test/tools/llvm-dwarfdump/X86/debug_line_dwarf64_large_table.s @@ -9,6 +9,7 @@ # CHECK-NEXT: warning: line table program with offset 0x00000000 has length 0xfffffffc but only 0x0000003a bytes are available # CHECK-NEXT: Line table prologue: # CHECK-NEXT: total_length: 0xfffffff0 +# CHECK-NEXT: format: DWARF64 # CHECK-NEXT: version: 4 # CHECK-NEXT: prologue_length: 0x00000016 Index: llvm/test/tools/llvm-dwarfdump/X86/typeunit-v4-dwarf64.s =================================================================== --- llvm/test/tools/llvm-dwarfdump/X86/typeunit-v4-dwarf64.s +++ llvm/test/tools/llvm-dwarfdump/X86/typeunit-v4-dwarf64.s @@ -25,7 +25,7 @@ TU_4_64_start: .long 0xffffffff # DWARF64 mark .quad TU_4_64_end-TU_4_64_version # Length of Unit -# CHECK-SAME: length = 0x00000021 +# CHECK-SAME: length = 0x00000021 format = DWARF64 TU_4_64_version: .short 4 # DWARF version number # CHECK-SAME: version = 0x0004 Index: llvm/test/tools/llvm-dwarfdump/X86/typeunit-v5-dwarf64.s =================================================================== --- llvm/test/tools/llvm-dwarfdump/X86/typeunit-v5-dwarf64.s +++ llvm/test/tools/llvm-dwarfdump/X86/typeunit-v5-dwarf64.s @@ -25,7 +25,7 @@ TU_5_64_start: .long 0xffffffff # DWARF64 mark .quad TU_5_64_end-TU_5_64_version # Length of Unit -# CHECK-SAME: length = 0x00000022 +# CHECK-SAME: length = 0x00000022 format = DWARF64 TU_5_64_version: .short 5 # DWARF version number # CHECK-SAME: version = 0x0005