<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></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 Mar 11, 2015, at 11:16 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Mar 10, 2015 at 3:53 PM, Adrian Prantl <span dir="ltr" class=""><<a href="mailto:aprantl@apple.com" target="_blank" class="">aprantl@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Mar 10, 2015, at 3:35 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank" class="">dblaikie@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Mar 10, 2015 at 3:26 PM, Adrian Prantl <span dir="ltr" class=""><<a href="mailto:aprantl@apple.com" target="_blank" class="">aprantl@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Mar 10, 2015, at 3:14 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank" class="">dblaikie@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Mar 10, 2015 at 2:50 PM, Adrian Prantl <span dir="ltr" class=""><<a href="mailto:aprantl@apple.com" target="_blank" class="">aprantl@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">Hi echristo, dblaikie,<br class="">
<br class="">
<a href="http://llvm.org/bugs/show_bug.cgi?id=22762" target="_blank" class="">http://llvm.org/bugs/show_bug.cgi?id=22762</a><br class="">
The symptom was that DW_AT_frame_base should never use a DW_OP_(bit)_piece, the bug was that AddMachineRegPiece incorrectly created pieces to describe values that occupy only a subregister. Change this to emit a bit mask instead.<br class="">
<br class="">
</span>I'm posting this for review because emitting the bit mask increases the size occupied for DWARF expressions for sub-registers (~5 bytes for a 32-bit subregister). Previously we would (incorrectly!) use DW_OP_piece to describe a value occupying part of a register. However, "DW_OP_piece provides a way of describing how large a part of a variable a particular DWARF location description refers to.",</blockquote><div class=""><br class="">The spec also says "If the piece is located in a register, but does not occupy the entire
register, the placement of the piece within that register is defined by the ABI. " - so we can use this in some cases at least. Should we? I assume it just means if we say _piece of size 1 in a register of size 4 we get the low byte (whatever definition of 'low' there is)?<br class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"> not the size and offset of an entire variable inside a super-register. The way that most debuggers implement DW_OP_piece this sort of works out for subregisters that are at offset 0, but it causes confusion if the expression needs to be composed (such as in DW_AT_frame_base, or if the subregister contains only a part of the variable).<br class=""></blockquote></div></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">Yes this is exactly the edge case that we were relying on up to now. There are two problems I have with that:</div><div class="">a) how do we implement the “defined by the ABI” predicate correctly? Assume that it’s always the subregister at offset 0 and wait until someone complains?</div></div></div></blockquote><div class=""><br class="">I'd probably be OK with this, open to other opinions, but it seems pretty simply like "we stuffed this number in a big register, but we don't need all the bits in the big register, so take the lowest bits that we specify" - any platform that did anything stranger than that... well, we should probably have a talk with/about them anyway, so I wouldn't mind if them running into this feature was what caused us to have that discussion</div></div></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">Fine. I’ll do it this way then.</div><span class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">.<br class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><div class="">b) it doesn’t compose well, so we’d need to explicitly forbid it inside of DW_AT_frame_base and inside of a larger piece expression.</div></div></div></blockquote><div class=""><br class="">This bit I don't really understand - perhaps you could provide some expression examples?<br class=""></div></div></div></div></div></blockquote><div class=""><br class=""></div></span>As for DW_AT_frame_base, according to the PR, gdb just crashes if it encounters a DW_OP_piece in there. More generally, since the expression inside DW_AT_frame_base is just going to be evaluated when a DW_OP_fbreg is encountered, it makes the result of an expression like "DW_OP_fbreg 4 DW_OP_piece 4 DW_OP_fbreg 8 DW_OP_piece 4” highly ambiguous.</div></div></blockquote><div class=""><br class="">I'm still really not following how piece, frame_base, and fbreg are all connected to this issue.<br class=""><br class="">When/where do we use a piece to describe the frame_base?<br class=""></div></div></div></div></div></blockquote><div><br class=""></div><div>On x86_64-pc-linux-gnux32 the frame base is ebp, but in 64-bit mode ebp doesn’t have DWARF register number, so we need a way saying “the lower 32 bits or rbp”. Before this patch we would emit "DW_OP_reg(rbp) DW_OP_piece 4", after this patch it is "DW_OP_reg(rbp) DW_OP_constu 0xffffff DW_OP_and".</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">Is GDB's (which version?) implementation of fbreg not respecting the size of the piece specified in a _piece in frame_base?<br class=""></div></div></div></div></div></blockquote><div><br class=""></div><div>According to the PR (I didn’t verify that) gdb crashes when it encounter a DW_OP_piece in DW_AT_frame_base.</div><div>-> <a href="http://llvm.org/bugs/show_bug.cgi?id=22762" class="">http://llvm.org/bugs/show_bug.cgi?id=22762</a></div><div><br class=""></div><div>-- adrian</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><br class=""></div><div class="">For the larger expression, I suppose it actually works with the “defined by the ABI”-strategy. Consider a 2-byte struct on x86_64 where the lower byte is in al and the higher byte is in bl: DW_OP_reg0 DW_OP_piece 1 DW_OP_reg4 DW_OP_piece 1.</div><div class="">And the same struct in al:bh needs some shifting either way.</div><span class=""><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">b) is doable, if ugly, but I’d need some help with a).<br class=""></div></div></blockquote></div></div></div></div></blockquote><br class=""></div></span><div class="">Ugly (but compact) it is, then! :-)</div><div class=""><br class=""></div><div class="">thanks!</div><span class="HOEnZb"><font color="#888888" class=""><div class="">adrian</div><br class=""></font></span></div></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></body></html>