diff options
author | Adrian Prantl <aprantl@apple.com> | 2016-05-17 20:12:08 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2016-05-17 20:12:08 +0000 |
commit | f0a41089ff2a580ad6665f62e8198b5efaa1ede2 (patch) | |
tree | b1c1f1a62d481f8840bb63c29839fa0d703a3f1f /llvm/lib/CodeGen | |
parent | 18b61707e86ea69e5014adcbfbfaf7a12903722d (diff) | |
download | bcm5719-llvm-f0a41089ff2a580ad6665f62e8198b5efaa1ede2.tar.gz bcm5719-llvm-f0a41089ff2a580ad6665f62e8198b5efaa1ede2.zip |
Debug Info: Don't emit bitfields in the DWARF4 format when tuning for GDB.
As discovered in PR27758, GDB does not fully support the DWARF 4 format.
This patch ensures we always emit bitfields in the DWARF 2 when tuning for GDB.
llvm-svn: 269827
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index f8c3f489ca4..ec4e8e1106f 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -1390,10 +1390,14 @@ void DwarfUnit::constructMemberDIE(DIE &Buffer, const DIDerivedType *DT) { uint64_t Size = DT->getSizeInBits(); uint64_t FieldSize = getBaseTypeSize(DD, DT); uint64_t OffsetInBytes; + + // GDB does not fully support the DWARF 4 representation for bitfields. + bool EmitDWARF2Bitfields = (DD->getDwarfVersion() < 4) || (DD->tuneForGDB()); bool IsBitfield = FieldSize && Size != FieldSize; + if (IsBitfield) { // Handle bitfield, assume bytes are 8 bits. - if (DD->getDwarfVersion() < 4) + if (EmitDWARF2Bitfields) addUInt(MemberDie, dwarf::DW_AT_byte_size, None, FieldSize/8); addUInt(MemberDie, dwarf::DW_AT_bit_size, None, Size); @@ -1405,9 +1409,7 @@ void DwarfUnit::constructMemberDIE(DIE &Buffer, const DIDerivedType *DT) { // The byte offset of the field's aligned storage unit inside the struct. OffsetInBytes = (Offset - StartBitOffset) / 8; - if (DD->getDwarfVersion() >= 4) - addUInt(MemberDie, dwarf::DW_AT_data_bit_offset, None, Offset); - else { + if (EmitDWARF2Bitfields) { uint64_t HiMark = (Offset + FieldSize) & AlignMask; uint64_t FieldOffset = (HiMark - FieldSize); Offset -= FieldOffset; @@ -1418,17 +1420,20 @@ void DwarfUnit::constructMemberDIE(DIE &Buffer, const DIDerivedType *DT) { addUInt(MemberDie, dwarf::DW_AT_bit_offset, None, Offset); OffsetInBytes = FieldOffset >> 3; + } else { + addUInt(MemberDie, dwarf::DW_AT_data_bit_offset, None, Offset); } - } else + } else { // This is not a bitfield. OffsetInBytes = DT->getOffsetInBits() / 8; + } if (DD->getDwarfVersion() <= 2) { DIELoc *MemLocationDie = new (DIEValueAllocator) DIELoc; addUInt(*MemLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst); addUInt(*MemLocationDie, dwarf::DW_FORM_udata, OffsetInBytes); addBlock(MemberDie, dwarf::DW_AT_data_member_location, MemLocationDie); - } else if (!IsBitfield || DD->getDwarfVersion() < 4) + } else if (!IsBitfield || EmitDWARF2Bitfields) addUInt(MemberDie, dwarf::DW_AT_data_member_location, None, OffsetInBytes); } |