[llvm] r237145 - [DWARF] Add CIE header fields address_size and segment_size when generating dwarf-4
Keith Walker
kwalker at arm.com
Tue May 12 08:25:09 PDT 2015
Author: kwalker
Date: Tue May 12 10:25:08 2015
New Revision: 237145
URL: http://llvm.org/viewvc/llvm-project?rev=237145&view=rev
Log:
[DWARF] Add CIE header fields address_size and segment_size when generating dwarf-4
The DWARF-4 specification added 2 new fields in the CIE header called
address_size and segment_size.
Create these 2 new fields when generating dwarf-4 CIE entries, print out
the new fields when dumping the CIE and update tests
Differential Revision: http://reviews.llvm.org/D9558
Modified:
llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
llvm/trunk/lib/MC/MCDwarf.cpp
llvm/trunk/test/MC/ARM/dwarf-cfi-initial-state.s
llvm/trunk/test/MC/ELF/cfi-sections.s
llvm/trunk/test/MC/ELF/cfi-version.ll
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp?rev=237145&r1=237144&r2=237145&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp Tue May 12 10:25:08 2015
@@ -189,10 +189,13 @@ public:
// CIEs (and FDEs) are simply container classes, so the only sensible way to
// create them is by providing the full parsed contents in the constructor.
CIE(uint64_t Offset, uint64_t Length, uint8_t Version,
- SmallString<8> Augmentation, uint64_t CodeAlignmentFactor,
+ SmallString<8> Augmentation, uint8_t AddressSize,
+ uint8_t SegmentDescriptorSize, uint64_t CodeAlignmentFactor,
int64_t DataAlignmentFactor, uint64_t ReturnAddressRegister)
: FrameEntry(FK_CIE, Offset, Length), Version(Version),
Augmentation(std::move(Augmentation)),
+ AddressSize(AddressSize),
+ SegmentDescriptorSize(SegmentDescriptorSize),
CodeAlignmentFactor(CodeAlignmentFactor),
DataAlignmentFactor(DataAlignmentFactor),
ReturnAddressRegister(ReturnAddressRegister) {}
@@ -208,6 +211,12 @@ public:
<< "\n";
OS << format(" Version: %d\n", Version);
OS << " Augmentation: \"" << Augmentation << "\"\n";
+ if (Version >= 4) {
+ OS << format(" Address size: %u\n",
+ (uint32_t)AddressSize);
+ OS << format(" Segment desc size: %u\n",
+ (uint32_t)SegmentDescriptorSize);
+ }
OS << format(" Code alignment factor: %u\n",
(uint32_t)CodeAlignmentFactor);
OS << format(" Data alignment factor: %d\n",
@@ -222,9 +231,11 @@ public:
}
private:
- /// The following fields are defined in section 6.4.1 of the DWARF standard v3
+ /// The following fields are defined in section 6.4.1 of the DWARF standard v4
uint8_t Version;
SmallString<8> Augmentation;
+ uint8_t AddressSize;
+ uint8_t SegmentDescriptorSize;
uint64_t CodeAlignmentFactor;
int64_t DataAlignmentFactor;
uint64_t ReturnAddressRegister;
@@ -461,18 +472,18 @@ void DWARFDebugFrame::parse(DataExtracto
bool IsCIE = ((IsDWARF64 && Id == DW64_CIE_ID) || Id == DW_CIE_ID);
if (IsCIE) {
- // Note: this is specifically DWARFv3 CIE header structure. It was
- // changed in DWARFv4. We currently don't support reading DWARFv4
- // here because LLVM itself does not emit it (and LLDB doesn't
- // support it either).
uint8_t Version = Data.getU8(&Offset);
const char *Augmentation = Data.getCStr(&Offset);
+ uint8_t AddressSize = Version < 4 ? Data.getAddressSize() : Data.getU8(&Offset);
+ Data.setAddressSize(AddressSize);
+ uint8_t SegmentDescriptorSize = Version < 4 ? 0 : Data.getU8(&Offset);
uint64_t CodeAlignmentFactor = Data.getULEB128(&Offset);
int64_t DataAlignmentFactor = Data.getSLEB128(&Offset);
uint64_t ReturnAddressRegister = Data.getULEB128(&Offset);
auto Cie = make_unique<CIE>(StartOffset, Length, Version,
- StringRef(Augmentation), CodeAlignmentFactor,
+ StringRef(Augmentation), AddressSize,
+ SegmentDescriptorSize, CodeAlignmentFactor,
DataAlignmentFactor, ReturnAddressRegister);
CIEs[StartOffset] = Cie.get();
Entries.emplace_back(std::move(Cie));
Modified: llvm/trunk/lib/MC/MCDwarf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=237145&r1=237144&r2=237145&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCDwarf.cpp (original)
+++ llvm/trunk/lib/MC/MCDwarf.cpp Tue May 12 10:25:08 2015
@@ -1302,6 +1302,14 @@ const MCSymbol &FrameEmitterImpl::EmitCI
}
streamer.EmitIntValue(0, 1);
+ if (CIEVersion >= 4) {
+ // Address Size
+ streamer.EmitIntValue(context.getAsmInfo()->getPointerSize(), 1);
+
+ // Segment Descriptor Size
+ streamer.EmitIntValue(0, 1);
+ }
+
// Code Alignment Factor
streamer.EmitULEB128IntValue(context.getAsmInfo()->getMinInstAlignment());
Modified: llvm/trunk/test/MC/ARM/dwarf-cfi-initial-state.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/dwarf-cfi-initial-state.s?rev=237145&r1=237144&r2=237145&view=diff
==============================================================================
--- llvm/trunk/test/MC/ARM/dwarf-cfi-initial-state.s (original)
+++ llvm/trunk/test/MC/ARM/dwarf-cfi-initial-state.s Tue May 12 10:25:08 2015
@@ -13,5 +13,8 @@ bx lr
# When llvm-dwarfdump prints the full info for the DW_CFA_def_cfa
# field, we can check that here too.
# CHECK: DW_CFA_def_cfa:
+# The following 2 DW_CFA_nop instructions are "padding"
+# CHECK: DW_CFA_nop:
+# CHECK: DW_CFA_nop:
# CHECK-NOT: DW_CFA
# CHECK: FDE
Modified: llvm/trunk/test/MC/ELF/cfi-sections.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/cfi-sections.s?rev=237145&r1=237144&r2=237145&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/cfi-sections.s (original)
+++ llvm/trunk/test/MC/ELF/cfi-sections.s Tue May 12 10:25:08 2015
@@ -1,5 +1,11 @@
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -sd | FileCheck -check-prefix=ELF_64 %s
-// RUN: llvm-mc -filetype=obj -triple i686-pc-linux-gnu %s -o - | llvm-readobj -s -sd | FileCheck -check-prefix=ELF_32 %s
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu -dwarf-version 2 %s -o - | llvm-readobj -s -sd | FileCheck -check-prefix=ELF_64 -check-prefix=ELF_64_DWARF_2 %s
+// RUN: llvm-mc -filetype=obj -triple i686-pc-linux-gnu -dwarf-version 2 %s -o - | llvm-readobj -s -sd | FileCheck -check-prefix=ELF_32 -check-prefix=ELF_32_DWARF_2 %s
+
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu -dwarf-version 3 %s -o - | llvm-readobj -s -sd | FileCheck -check-prefix=ELF_64 -check-prefix=ELF_64_DWARF_3 %s
+// RUN: llvm-mc -filetype=obj -triple i686-pc-linux-gnu -dwarf-version 3 %s -o - | llvm-readobj -s -sd | FileCheck -check-prefix=ELF_32 -check-prefix=ELF_32_DWARF_3 %s
+
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu -dwarf-version 4 %s -o - | llvm-readobj -s -sd | FileCheck -check-prefix=ELF_64 -check-prefix=ELF_64_DWARF_4 %s
+// RUN: llvm-mc -filetype=obj -triple i686-pc-linux-gnu -dwarf-version 4 %s -o - | llvm-readobj -s -sd | FileCheck -check-prefix=ELF_32 -check-prefix=ELF_32_DWARF_4 %s
.cfi_sections .debug_frame
@@ -26,8 +32,12 @@ f2:
// ELF_64-NEXT: AddressAlignment: 8
// ELF_64-NEXT: EntrySize: 0
// ELF_64-NEXT: SectionData (
-// ELF_64-NEXT: 0000: 14000000 FFFFFFFF 04000178 100C0708
-// ELF_64-NEXT: 0010: 90010000 00000000 14000000 00000000
+// ELF_64_DWARF_2-NEXT: 0000: 14000000 FFFFFFFF 01000178 100C0708
+// ELF_64_DWARF_2-NEXT: 0010: 90010000 00000000 14000000 00000000
+// ELF_64_DWARF_3-NEXT: 0000: 14000000 FFFFFFFF 03000178 100C0708
+// ELF_64_DWARF_3-NEXT: 0010: 90010000 00000000 14000000 00000000
+// ELF_64_DWARF_4-NEXT: 0000: 14000000 FFFFFFFF 04000800 0178100C
+// ELF_64_DWARF_4-NEXT: 0010: 07089001 00000000 14000000 00000000
// ELF_64-NEXT: 0020: 00000000 00000000 01000000 00000000
// ELF_64-NEXT: 0030: 14000000 00000000 00000000 00000000
// ELF_64-NEXT: 0040: 01000000 00000000
@@ -47,9 +57,14 @@ f2:
// ELF_32-NEXT: AddressAlignment: 4
// ELF_32-NEXT: EntrySize: 0
// ELF_32-NEXT: SectionData (
-// ELF_32-NEXT: 0000: 10000000 FFFFFFFF 0400017C 080C0404
-// ELF_32-NEXT: 0010: 88010000 0C000000 00000000 00000000
+// ELF_32_DWARF_2-NEXT: 0000: 10000000 FFFFFFFF 0100017C 080C0404
+// ELF_32_DWARF_2-NEXT: 0010: 88010000 0C000000 00000000 00000000
+// ELF_32_DWARF_3-NEXT: 0000: 10000000 FFFFFFFF 0300017C 080C0404
+// ELF_32_DWARF_3-NEXT: 0010: 88010000 0C000000 00000000 00000000
+// ELF_32_DWARF_4-NEXT: 0000: 10000000 FFFFFFFF 04000400 017C080C
+// ELF_32_DWARF_4-NEXT: 0010: 04048801 0C000000 00000000 00000000
// ELF_32-NEXT: 0020: 01000000 0C000000 00000000 01000000
// ELF_32-NEXT: 0030: 01000000
+
// ELF_32-NEXT: )
// ELF_32-NEXT: }
Modified: llvm/trunk/test/MC/ELF/cfi-version.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/cfi-version.ll?rev=237145&r1=237144&r2=237145&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/cfi-version.ll (original)
+++ llvm/trunk/test/MC/ELF/cfi-version.ll Tue May 12 10:25:08 2015
@@ -39,11 +39,17 @@ attributes #1 = { "less-precise-fpmad"="
; DWARF2: .debug_frame contents:
; DWARF2: Version: 1
; DWARF2-NEXT: Augmentation:
+; DWARF2-NOT: Address size:
+; DWARF2-NOT: Segment desc size:
; DWARF3: .debug_frame contents:
; DWARF3: Version: 3
; DWARF3-NEXT: Augmentation:
+; DWARF3-NOT: Address size:
+; DWARF3-NOT: Segment desc size:
; DWARF4: .debug_frame contents:
; DWARF4: Version: 4
; DWARF4-NEXT: Augmentation:
+; DWARF4: Address size:
+; DWARF4: Segment desc size:
More information about the llvm-commits
mailing list