[llvm] r269827 - Debug Info: Don't emit bitfields in the DWARF4 format when tuning for GDB.

Francois Pichet via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 28 09:24:58 PDT 2016


On Tue, May 17, 2016 at 4:12 PM, Adrian Prantl via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: adrian
> Date: Tue May 17 15:12:08 2016
> New Revision: 269827
>
> URL: http://llvm.org/viewvc/llvm-project?rev=269827&view=rev
> Log:
> 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.
>
> Modified:
>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
>     llvm/trunk/test/DebugInfo/ARM/big-endian-bitfield.ll
>     llvm/trunk/test/DebugInfo/X86/bitfields-dwarf4.ll
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=269827&r1=269826&r2=269827&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Tue May 17 15:12:08
> 2016
> @@ -1390,10 +1390,14 @@ void DwarfUnit::constructMemberDIE(DIE &
>      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 &
>        // 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 &
>
>          addUInt(MemberDie, dwarf::DW_AT_bit_offset, None, Offset);
>          OffsetInBytes = FieldOffset >> 3;
> +      } else {
> +        addUInt(MemberDie, dwarf::DW_AT_data_bit_offset, None, Offset);
>        }
>

I tested this on a big endian system and it doesn't work.

The dwarf spec say that the DW_AT_data_bit_offset value must be the same
for big or litttle endian. LLDB will do the appropriate calculation.
But at the point Offset wont have the same value on little or big endian
system.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160728/3f65eca7/attachment.html>


More information about the llvm-commits mailing list