<div dir="ltr">Using "slow-stepping" doesn't fix the issue. It appears that the debugger is setting some flags when hitting the breakpoint and stepping which prohibit the intrinsic to evaluate the conditionals properly.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 11, 2014 at 8:25 PM, Greg Clayton <span dir="ltr"><<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Does this work if you first type:<br>
<br>
(lldb) setting set target.use-fast-stepping false<br>
<br>
Then step?<br>
<div><div class="h5"><br>
<br>
> On Dec 11, 2014, at 1:38 AM, Mario Zechner <<a href="mailto:badlogicgames@gmail.com">badlogicgames@gmail.com</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> we are running into a problem with the __sync_bool_compare_and_swap intrinsic on ARM. Trying to step over the call to __sync_bool_compare_and_swap will put LLDB into a sort of infinite loop.<br>
><br>
> This is reproduceable in the latest XCode (6.1.1 (6A2008a)). Create an iOS project with the following main function:<br>
><br>
> int main(int argc, char * argv[]) {<br>
> int c = 0;<br>
> while(1) {<br>
> if(__sync_bool_compare_and_swap(&c, 0, 1)) {<br>
> break;<br>
> }<br>
> }<br>
> printf("%d\n", c);<br>
> }<br>
><br>
> The intrinsic compiles down to:<br>
><br>
> 0xb7010: dmb ish<br>
> 0xb7014: movs r0, #0x1<br>
> 0xb7016: movs r1, #0x0<br>
> 0xb7018: add r2, sp, #0x14<br>
> 0xb701a: str r0, [sp, #0x10]<br>
> 0xb701c: str r1, [sp, #0xc]<br>
> 0xb701e: str r2, [sp, #0x8]<br>
> -> 0xb7020: ldr r0, [sp, #0x8]<br>
> 0xb7022: ldrex r1, [r0]<br>
> 0xb7026: ldr r2, [sp, #0xc]<br>
> 0xb7028: cmp r1, r2<br>
> 0xb702a: str r1, [sp, #0x4]<br>
> 0xb702c: bne 0xb703a ; main + 62 at main.m:15<br>
> 0xb702e: ldr r1, [sp, #0x10]<br>
> 0xb7030: ldr r2, [sp, #0x8]<br>
> 0xb7032: strex r0, r1, [r2]<br>
> 0xb7036: cmp r0, #0x0<br>
> 0xb7038: bne 0xb7020 ; main + 36 at main.m:15<br>
> 0xb703a: dmb ish<br>
><br>
> When stepping over, LLDB will first set a breakpoint on 0xb702c: bne 0xb703a. Next it executes a single step, moving PC to 0xb702e: ldr r1, [sp, #0x10] as the condition is not meet.<br>
><br>
> LLDB then sets a breakpoint on the next branch instruction at 0xb7038: bne 0xb7020. It single steps the instruction, the condition is meet, and we end up at 0xb7020 again.<br>
><br>
> The code never breaks out of this loop, LLDB will continue to set the breakpoints indefinitely.<br>
><br>
> Any idea how to fix this?<br>
><br>
> Thanks,<br>
> Mario<br>
</div></div>> _______________________________________________<br>
> lldb-dev mailing list<br>
> <a href="mailto:lldb-dev@cs.uiuc.edu">lldb-dev@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
<br>
</blockquote></div></div>