From 4933ab2ccb3a10a89ffe88e4d25e38544791caf8 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Tue, 2 Jun 2020 16:00:44 +0700 Subject: [PATCH] [DebugInfo] Report the format of call frame information entries [6/10] Differential Revision: https://reviews.llvm.org/D80523 --- lld/test/ELF/eh-frame-hdr-augmentation.s | 2 ++ llvm/include/llvm/BinaryFormat/Dwarf.h | 1 + llvm/lib/BinaryFormat/Dwarf.cpp | 4 ++++ llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp | 8 +++++--- llvm/test/DebugInfo/X86/debug-frame-dwarf64.s | 2 ++ llvm/test/MC/Mips/eh-frame.s | 4 ++++ llvm/test/tools/dsymutil/X86/frame-2.test | 3 +++ .../tools/llvm-dwarfdump/X86/debug_frame_GNU_args_size.s | 1 + .../test/tools/llvm-dwarfdump/X86/debug_frame_offset.test | 2 ++ .../llvm-dwarfdump/X86/eh-frame-return-address-reg.s | 1 + 10 files changed, 25 insertions(+), 3 deletions(-) diff --git a/lld/test/ELF/eh-frame-hdr-augmentation.s b/lld/test/ELF/eh-frame-hdr-augmentation.s index 6a9a9e64c8d8..dbec54a1a8a2 100644 --- a/lld/test/ELF/eh-frame-hdr-augmentation.s +++ b/lld/test/ELF/eh-frame-hdr-augmentation.s @@ -6,6 +6,7 @@ // CHECK: .eh_frame contents: // CHECK: 00000000 0000001c 00000000 CIE +// CHECK-NEXT: Format: DWARF32 // CHECK-NEXT: Version: 1 // CHECK-NEXT: Augmentation: "zPLR" // CHECK-NEXT: Code alignment factor: 1 @@ -20,6 +21,7 @@ // CHECK-NEXT: DW_CFA_nop: // CHECK: 00000020 00000014 00000024 FDE cie=00000000 pc=00001014...00001014 +// CHECK-NEXT: Format: DWARF32 // CHECK-NEXT: LSDA Address: 000000000000100b // CHECK-NEXT: DW_CFA_nop: // CHECK-NEXT: DW_CFA_nop: diff --git a/llvm/include/llvm/BinaryFormat/Dwarf.h b/llvm/include/llvm/BinaryFormat/Dwarf.h index 1caf4d9291e3..00e580bbe450 100644 --- a/llvm/include/llvm/BinaryFormat/Dwarf.h +++ b/llvm/include/llvm/BinaryFormat/Dwarf.h @@ -482,6 +482,7 @@ StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind); StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage); StringRef IndexString(unsigned Idx); StringRef FormatString(DwarfFormat Format); +StringRef FormatString(bool IsDWARF64); /// @} /// \defgroup DwarfConstantsParsing Dwarf constants parsing functions diff --git a/llvm/lib/BinaryFormat/Dwarf.cpp b/llvm/lib/BinaryFormat/Dwarf.cpp index 08ecd77966c3..971b850a09cc 100644 --- a/llvm/lib/BinaryFormat/Dwarf.cpp +++ b/llvm/lib/BinaryFormat/Dwarf.cpp @@ -780,6 +780,10 @@ StringRef llvm::dwarf::FormatString(DwarfFormat Format) { return StringRef(); } +StringRef llvm::dwarf::FormatString(bool IsDWARF64) { + return FormatString(IsDWARF64 ? DWARF64 : DWARF32); +} + constexpr char llvm::dwarf::EnumTraits::Type[]; constexpr char llvm::dwarf::EnumTraits
::Type[]; constexpr char llvm::dwarf::EnumTraits::Type[]; diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp index fe24f3942ffb..159bde9adf16 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp @@ -314,9 +314,10 @@ void CIE::dump(raw_ostream &OS, const MCRegisterInfo *MRI, bool IsEH) const { << format(" %0*" PRIx64, IsDWARF64 ? 16 : 8, Length) << format(" %0*" PRIx64, IsDWARF64 && !IsEH ? 16 : 8, getCIEId(IsDWARF64, IsEH)) - << " CIE\n"; - OS << format(" Version: %d\n", Version); - OS << " Augmentation: \"" << Augmentation << "\"\n"; + << " CIE\n" + << " Format: " << FormatString(IsDWARF64) << "\n" + << format(" Version: %d\n", Version) + << " Augmentation: \"" << Augmentation << "\"\n"; if (Version >= 4) { OS << format(" Address size: %u\n", (uint32_t)AddressSize); OS << format(" Segment desc size: %u\n", @@ -349,6 +350,7 @@ void FDE::dump(raw_ostream &OS, const MCRegisterInfo *MRI, bool IsEH) const { OS << ""; OS << format(" pc=%08" PRIx64 "...%08" PRIx64 "\n", InitialLocation, InitialLocation + AddressRange); + OS << " Format: " << FormatString(IsDWARF64) << "\n"; if (LSDAAddress) OS << format(" LSDA Address: %016" PRIx64 "\n", *LSDAAddress); CFIs.dump(OS, MRI, IsEH); diff --git a/llvm/test/DebugInfo/X86/debug-frame-dwarf64.s b/llvm/test/DebugInfo/X86/debug-frame-dwarf64.s index e9820c58c46f..9253cede16a4 100644 --- a/llvm/test/DebugInfo/X86/debug-frame-dwarf64.s +++ b/llvm/test/DebugInfo/X86/debug-frame-dwarf64.s @@ -3,6 +3,7 @@ # RUN: FileCheck %s # CHECK: 00000000 0000000000000010 ffffffffffffffff CIE +# CHECK-NEXT: Format: DWARF64 # CHECK-NEXT: Version: 4 # CHECK-NEXT: Augmentation: "" # CHECK-NEXT: Address size: 8 @@ -14,6 +15,7 @@ # CHECK-NEXT: DW_CFA_nop: # CHECK: 0000001c 0000000000000018 0000000000000000 FDE cie=00000000 pc=00112233...00122233 +# CHECK-NEXT: Format: DWARF64 .section .debug_frame, "", @progbits .LCIE: diff --git a/llvm/test/MC/Mips/eh-frame.s b/llvm/test/MC/Mips/eh-frame.s index 1de56b66ddb7..5be0d709a896 100644 --- a/llvm/test/MC/Mips/eh-frame.s +++ b/llvm/test/MC/Mips/eh-frame.s @@ -55,6 +55,7 @@ func: // RELOCS-NEXT: } // DWARF32: 00000000 00000010 00000000 CIE +// DWARF32-NEXT: Format: DWARF32 // DWARF32-NEXT: Version: 1 // DWARF32-NEXT: Augmentation: "zR" // DWARF32-NEXT: Code alignment factor: 1 @@ -68,12 +69,14 @@ func: // DWARF32-NEXT: DW_CFA_def_cfa_register: reg29 // // DWARF32: 00000014 00000010 00000018 FDE cie=00000000 pc=00000000...00000000 +// DWARF32-NEXT: Format: DWARF32 // DWARF32-NEXT: DW_CFA_nop: // DWARF32-NEXT: DW_CFA_nop: // DWARF32-NEXT: DW_CFA_nop: // DWARF64: 00000000 00000010 00000000 CIE +// DWARF64-NEXT: Format: DWARF32 // DWARF64-NEXT: Version: 1 // DWARF64-NEXT: Augmentation: "zR" // DWARF64-NEXT: Code alignment factor: 1 @@ -91,6 +94,7 @@ func: // // DWARF64_ABS: 00000014 00000018 00000018 FDE cie=00000000 pc=00000000...00000000 // DWARF64_PIC: 00000014 00000010 00000018 FDE cie=00000000 pc=00000000...00000000 +// DWARF64-NEXT: Format: DWARF32 // DWARF64-NEXT: DW_CFA_nop: // DWARF64-NEXT: DW_CFA_nop: // DWARF64-NEXT: DW_CFA_nop: diff --git a/llvm/test/tools/dsymutil/X86/frame-2.test b/llvm/test/tools/dsymutil/X86/frame-2.test index ab47e573cc45..235d2ca18ca1 100644 --- a/llvm/test/tools/dsymutil/X86/frame-2.test +++ b/llvm/test/tools/dsymutil/X86/frame-2.test @@ -27,6 +27,7 @@ objects: # CHECK: .debug_frame contents: # CHECK: 00000000 {{[0-9a-f]*}} ffffffff CIE +# CHECK-NEXT: Format: DWARF32 # CHECK-NEXT: Version:{{.*}}1 # CHECK-NOT: FDE # CHECK: FDE cie=00000000 pc=00001000...00001 @@ -34,11 +35,13 @@ objects: # CHECK: FDE cie=00000000 pc=00002000...00002 # CHECK-NOT: FDE # CHECK: [[CIEDW4:[0-9a-f]*]] 00000010 ffffffff CIE +# CHECK-NEXT: Format: DWARF32 # CHECK-NEXT: Version:{{.*}}4 # CHECK-NOT: FDE # CHECK: FDE cie=[[CIEDW4]] pc=00003000...00003 # CHECK-NOT: FDE # CHECK: [[CIEDW2:[0-9a-f]*]] {{[0-9a-f]*}} ffffffff CIE +# CHECK-NEXT: Format: DWARF32 # CHECK-NEXT: Version:{{.*}}1 # CHECK-NOT: FDE # CHECK: FDE cie=[[CIEDW2]] pc=00004000...00004 diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_frame_GNU_args_size.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_frame_GNU_args_size.s index 0adf5e5d37d1..f31b938cc04a 100644 --- a/llvm/test/tools/llvm-dwarfdump/X86/debug_frame_GNU_args_size.s +++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_frame_GNU_args_size.s @@ -3,6 +3,7 @@ # CHECK: .eh_frame contents: # CHECK: 00000018 00000010 0000001c FDE cie=00000000 pc=00000000...00000000 +# CHECK-NEXT: Format: DWARF32 # CHECK-NEXT: DW_CFA_GNU_args_size: +16 # CHECK-NEXT: DW_CFA_nop: diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_frame_offset.test b/llvm/test/tools/llvm-dwarfdump/X86/debug_frame_offset.test index 269ef47f9756..598f80379c38 100644 --- a/llvm/test/tools/llvm-dwarfdump/X86/debug_frame_offset.test +++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_frame_offset.test @@ -2,6 +2,7 @@ RUN: llc -filetype=obj %p/../../dsymutil/Inputs/frame-dw2.ll -o - \ RUN: | llvm-dwarfdump -debug-frame=0x00000014 - | FileCheck %s CHECK: .debug_frame contents: CHECK-NEXT: 00000014 00000014 00000000 FDE cie=00000000 pc=00000000...0000001d +CHECK-NEXT: Format: DWARF32 CHECK-NEXT: DW_CFA_advance_loc: 1 CHECK-NOT: pc @@ -9,6 +10,7 @@ RUN: llvm-dwarfdump %p/../../dsymutil/Inputs/basic1.macho.x86_64.o \ RUN: -eh-frame=0x00000018 | FileCheck %s --check-prefix=EH EH: .eh_frame contents: EH-NEXT: 00000018 00000024 0000001c FDE cie=00000000 pc=fffffffffffffd00...fffffffffffffd24 +EH-NEXT: Format: DWARF32 EH-NEXT: DW_CFA_advance_loc: 1 EH-NOT: pc EH-NOT: CIE diff --git a/llvm/test/tools/llvm-dwarfdump/X86/eh-frame-return-address-reg.s b/llvm/test/tools/llvm-dwarfdump/X86/eh-frame-return-address-reg.s index 48d8320eb24f..fa9f95c9a4da 100644 --- a/llvm/test/tools/llvm-dwarfdump/X86/eh-frame-return-address-reg.s +++ b/llvm/test/tools/llvm-dwarfdump/X86/eh-frame-return-address-reg.s @@ -11,6 +11,7 @@ # CHECK: .eh_frame contents: # CHECK: 00000000 00000010 00000000 CIE +# CHECK-NEXT: Format: DWARF32 # CHECK-NEXT: Version: 1 # CHECK-NEXT: Augmentation: "zR" # CHECK-NEXT: Code alignment factor: 1