<div dir="ltr">I agree that unwinding is probably a hard thing to write tests for.  But right now it has basically 0 coverage, so I really hope we can improve that.  I'll be the first to admit that I am *not* an expert in this area, but just looking at the patch description "<span style="font-size:13.1999998092651px;line-height:19.7999992370605px">This is initial implementation of assembly profiler which only scans prologue/epilogue assembly instructions to create CFI instructions" I feel like this is something that would be a great candidate for unit tests.  Since a unit test is written in C++, it need not be written against the public API.  You could just feed the profiler sequences of bytes that represent prologues / epilogues, and verify that the CFI instructions are correct.  (I hope that even makes sense, again I'm not an expert on this, just trying to make guesses based on the patch description).</span><br><div><span style="font-size:13.1999998092651px;line-height:19.7999992370605px"><br></span></div><div><span style="font-size:13.1999998092651px;line-height:19.7999992370605px">You wouldn't even need to have an input binary to make this work.  Just encode some prologues and epilogues into the unit test, and verify that the profiler does the right thing.</span></div></div><br><div class="gmail_quote">On Wed Feb 18 2015 at 8:46:07 PM Jason Molenda <<a href="mailto:jmolenda@apple.com">jmolenda@apple.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">For what it's worth, an example of a test file for this code would be a driver program written in C for simplicity which calls under1() written in assembly, which in turn calls under2().  lldb would stop in under2(), go up the stack to under1() and try to print a register that was preserved.<br>
<br>
Some utterly invalid syntax for a test file would look like:<br>
<br>
int main()<br>
 {<br>
<br>
  under1();<br>
<br>
}<br>
<br>
.asm("<br>
under1:<br>
<br>
  mov r16, 1<br>
  call under2<br>
<br>
under2:<br>
<br>
  sd r16(sp)       # I have no idea if that is right -- save contents of r16 on the local stack frame<br>
  mov r16, 5<br>
  call puts          ## whatever, stop at a breakpoint here<br>
<br>
");<br>
<br>
If lldb could select frame 1 and see that r16 has the value 1, that's a simple test case.<br>
<br>
But this test could only be run on a mips64 system.<br>
<br>
I want to add test cases like this for x86 but it might take some fiddling to get assembly that would work on all the Unix x86 systems at least (nevermind Windows! ;) and I've never gotten around to it.  I should start with at least simple x86 unwinder test cases that work correctly on Mac as a step 0.<br>
<br>
<br>
REPOSITORY<br>
  rL LLVM<br>
<br>
<a href="http://reviews.llvm.org/D7696" target="_blank">http://reviews.llvm.org/D7696</a><br>
<br>
EMAIL PREFERENCES<br>
  <a href="http://reviews.llvm.org/settings/panel/emailpreferences/" target="_blank">http://reviews.llvm.org/<u></u>settings/panel/<u></u>emailpreferences/</a><br>
<br>
<br>
</blockquote></div>