<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jul 28, 2016, at 9:24 AM, Francois Pichet <<a href="mailto:pichet2000@gmail.com" class="">pichet2000@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br class="Apple-interchange-newline"><br class=""><div class="gmail_quote"><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">On Tue, May 17, 2016 at 4:12 PM, Adrian Prantl via llvm-commits<span class="Apple-converted-space"> </span></span><span dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a>></span><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><span class="Apple-converted-space"> </span></span><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">wrote:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">Author: adrian<br class="">Date: Tue May 17 15:12:08 2016<br class="">New Revision: 269827<br class=""><br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=269827&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=269827&view=rev</a><br class="">Log:<br class="">Debug Info: Don't emit bitfields in the DWARF4 format when tuning for GDB.<br class="">As discovered in PR27758, GDB does not fully support the DWARF 4 format.<br class="">This patch ensures we always emit bitfields in the DWARF 2 when tuning for GDB.<br class=""><br class="">Modified:<br class="">   <span class="Apple-converted-space"> </span>llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp<br class="">   <span class="Apple-converted-space"> </span>llvm/trunk/test/DebugInfo/ARM/big-endian-bitfield.ll<br class="">   <span class="Apple-converted-space"> </span>llvm/trunk/test/DebugInfo/X86/bitfields-dwarf4.ll<br class=""><br class="">Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=269827&r1=269826&r2=269827&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=269827&r1=269826&r2=269827&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)<br class="">+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Tue May 17 15:12:08 2016<br class="">@@ -1390,10 +1390,14 @@ void DwarfUnit::constructMemberDIE(DIE &<br class="">     uint64_t Size = DT->getSizeInBits();<br class="">     uint64_t FieldSize = getBaseTypeSize(DD, DT);<br class="">     uint64_t OffsetInBytes;<br class="">+<br class="">+    // GDB does not fully support the DWARF 4 representation for bitfields.<br class="">+    bool EmitDWARF2Bitfields = (DD->getDwarfVersion() < 4) || (DD->tuneForGDB());<br class="">     bool IsBitfield = FieldSize && Size != FieldSize;<br class="">+<br class="">     if (IsBitfield) {<br class="">       // Handle bitfield, assume bytes are 8 bits.<br class="">-      if (DD->getDwarfVersion() < 4)<br class="">+      if (EmitDWARF2Bitfields)<br class="">         addUInt(MemberDie, dwarf::DW_AT_byte_size, None, FieldSize/8);<br class="">       addUInt(MemberDie, dwarf::DW_AT_bit_size, None, Size);<br class=""><br class="">@@ -1405,9 +1409,7 @@ void DwarfUnit::constructMemberDIE(DIE &<br class="">       // The byte offset of the field's aligned storage unit inside the struct.<br class="">       OffsetInBytes = (Offset - StartBitOffset) / 8;<br class=""><br class="">-      if (DD->getDwarfVersion() >= 4)<br class="">-        addUInt(MemberDie, dwarf::DW_AT_data_bit_offset, None, Offset);<br class="">-      else {<br class="">+      if (EmitDWARF2Bitfields) {<br class="">         uint64_t HiMark = (Offset + FieldSize) & AlignMask;<br class="">         uint64_t FieldOffset = (HiMark - FieldSize);<br class="">         Offset -= FieldOffset;<br class="">@@ -1418,17 +1420,20 @@ void DwarfUnit::constructMemberDIE(DIE &<br class=""><br class="">         addUInt(MemberDie, dwarf::DW_AT_bit_offset, None, Offset);<br class="">         OffsetInBytes = FieldOffset >> 3;<br class="">+      } else {<br class="">+        addUInt(MemberDie, dwarf::DW_AT_data_bit_offset, None, Offset);<br class="">       }<br class=""></blockquote><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div class="gmail-adn gmail-ads" style="font-family: Helvetica; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; padding-bottom: 0px; font-size: inherit;"><div class="gmail-gs"><div id="gmail-:1g8" class="gmail-adP gmail-ii gmail-adO gmail-gt" style="font-size: 12.8px;"><div id="gmail-:1g7" class="gmail-a3s gmail-aXjCH gmail-m156323bd86ffe488"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">I tested this on a big endian system and it doesn't work.</div><div class=""><br class=""></div><div class="">The dwarf spec say that the <span class="gmail-il">DW_AT_data_bit_offset</span> value must be the same for big or litttle endian. LLDB will do the appropriate calculation.</div></div></div></div></div></div></div></div></div></div></blockquote><div><br class=""></div><div>That is correct. That said, I also see that test/DebugInfo/ARM/big-endian-bitfield.ll is the exact same testcase as in the big-endian example in the DWARF (v5) specification Fig. D23.</div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote"><div class="gmail-adn gmail-ads" style="font-family: Helvetica; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; padding-bottom: 0px; font-size: inherit;"><div class="gmail-gs"><div id="gmail-:1g8" class="gmail-adP gmail-ii gmail-adO gmail-gt" style="font-size: 12.8px;"><div id="gmail-:1g7" class="gmail-a3s gmail-aXjCH gmail-m156323bd86ffe488"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">But at the point Offset wont have the same value on little or big endian system.</div></div></div></div></div></div></div></div></div></div></blockquote><div><br class=""></div>Would you mind filing a PR about this and assigning it to me? And can you give an example of where we are emitting wrong values?</div><div>I'll try to look at this soon.</div><div><br class=""></div><div>thanks for reporting!</div><div>Adrian<br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote"><div class="gmail-adn gmail-ads" style="font-family: Helvetica; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; padding-bottom: 0px; font-size: inherit;"><div class="gmail-gs"><div id="gmail-:1g8" class="gmail-adP gmail-ii gmail-adO gmail-gt" style="font-size: 12.8px;"><div id="gmail-:1g7" class="gmail-a3s gmail-aXjCH gmail-m156323bd86ffe488"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="gmail-yj6qo"></div></div></div></div></div></div><div class="gmail-hi"></div></div><div class="gmail-ajx"></div></div><div class="gmail-gA gmail-gt gmail-acV" style="font-family: Helvetica; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12.8px; background-color: rgb(255, 255, 255);"><div class="gmail-xu gmail-gB"><br class="Apple-interchange-newline"></div></div></div></div></blockquote></div><br class=""></body></html>