llvm.org GIT mirror llvm / c8f8f9c
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269827 91177308-0d34-0410-b5e6-96231b3b80d8 Adrian Prantl 4 years ago
3 changed file(s) with 15 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
13891389 uint64_t Size = DT->getSizeInBits();
13901390 uint64_t FieldSize = getBaseTypeSize(DD, DT);
13911391 uint64_t OffsetInBytes;
1392
1393 // GDB does not fully support the DWARF 4 representation for bitfields.
1394 bool EmitDWARF2Bitfields = (DD->getDwarfVersion() < 4) || (DD->tuneForGDB());
13921395 bool IsBitfield = FieldSize && Size != FieldSize;
1396
13931397 if (IsBitfield) {
13941398 // Handle bitfield, assume bytes are 8 bits.
1395 if (DD->getDwarfVersion() < 4)
1399 if (EmitDWARF2Bitfields)
13961400 addUInt(MemberDie, dwarf::DW_AT_byte_size, None, FieldSize/8);
13971401 addUInt(MemberDie, dwarf::DW_AT_bit_size, None, Size);
13981402
14041408 // The byte offset of the field's aligned storage unit inside the struct.
14051409 OffsetInBytes = (Offset - StartBitOffset) / 8;
14061410
1407 if (DD->getDwarfVersion() >= 4)
1408 addUInt(MemberDie, dwarf::DW_AT_data_bit_offset, None, Offset);
1409 else {
1411 if (EmitDWARF2Bitfields) {
14101412 uint64_t HiMark = (Offset + FieldSize) & AlignMask;
14111413 uint64_t FieldOffset = (HiMark - FieldSize);
14121414 Offset -= FieldOffset;
14171419
14181420 addUInt(MemberDie, dwarf::DW_AT_bit_offset, None, Offset);
14191421 OffsetInBytes = FieldOffset >> 3;
1422 } else {
1423 addUInt(MemberDie, dwarf::DW_AT_data_bit_offset, None, Offset);
14201424 }
1421 } else
1425 } else {
14221426 // This is not a bitfield.
14231427 OffsetInBytes = DT->getOffsetInBits() / 8;
1428 }
14241429
14251430 if (DD->getDwarfVersion() <= 2) {
14261431 DIELoc *MemLocationDie = new (DIEValueAllocator) DIELoc;
14271432 addUInt(*MemLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
14281433 addUInt(*MemLocationDie, dwarf::DW_FORM_udata, OffsetInBytes);
14291434 addBlock(MemberDie, dwarf::DW_AT_data_member_location, MemLocationDie);
1430 } else if (!IsBitfield || DD->getDwarfVersion() < 4)
1435 } else if (!IsBitfield || EmitDWARF2Bitfields)
14311436 addUInt(MemberDie, dwarf::DW_AT_data_member_location, None,
14321437 OffsetInBytes);
14331438 }
None ; RUN: llc -O0 -filetype=obj -mtriple=armeb-none-linux %s -o - \
0 ; RUN: llc -O0 -filetype=obj -mtriple=armeb-none-freebsd -debugger-tune=lldb %s -o - \
11 ; RUN: | llvm-dwarfdump --debug-dump=info - | FileCheck %s
22 ; Generated from:
33 ; struct S {
0 ; RUN: llc -mtriple x86_64-apple-macosx -O0 -filetype=obj -o - %s \
11 ; RUN: | llvm-dwarfdump -debug-dump=info - | FileCheck %s
2 ; RUN: llc -mtriple x86_64-gnu-linux -O0 -filetype=obj -o - %s \
3 ; RUN: | llvm-dwarfdump -debug-dump=info - | FileCheck %s --check-prefix=LINUX
4 ; LINUX-NOT: DW_AT_data_bit_offset
25 ;
36 ; Generated from:
47 ; #include