I've been working on a script to store and fetch stack traces for gcd and I've got it working if I set the symbolic breakpoints manually, but if I set the breakpoints in the script, one of my breakpoints never hits and the command attached to it behaves weirdly:<div>
<br></div><div><a href="https://github.com/rustle/LLDBStackStoreFetch">https://github.com/rustle/LLDBStackStoreFetch</a></div><div><br></div><div>This is the function to make the breakpoints in the script</div><div><br></div>
<div><div>def set_dispatch_breakpoints(debugger, command, result, dict):</div><div><span class="Apple-tab-span" style="white-space:pre">      </span>debugger.HandleCommand('breakpoint set -F dispatch_async')</div><div>
<span class="Apple-tab-span" style="white-space:pre"> </span>breakpointcount = lldb.target.GetNumBreakpoints()</div><div><span class="Apple-tab-span" style="white-space:pre">    </span>debugger.HandleCommand("breakpoint command add -s command {index} -o 'store_stack -a $arg2'".format(index=breakpointcount))</div>
<div><span class="Apple-tab-span" style="white-space:pre">      </span>debugger.HandleCommand('breakpoint set -F _dispatch_call_block_and_release')</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>breakpointcount = lldb.target.GetNumBreakpoints()</div>
<div><span class="Apple-tab-span" style="white-space:pre">      </span>lldb.debugger.HandleCommand("breakpoint command add -s command {index} -o 'print_stack -a $arg1'".format(index=breakpointcount))</div></div>
<div><br></div><div>The breakpoints get made (using a debugging command on a breakpoint in main to call set_dispatch_breakpoints)</div><div><br></div><div><div>(lldb) b</div><div>breakpoint list --full</div><div>Current breakpoints:</div>
<div>1: file ='main.m', line = 27, locations = 1, resolved = 1</div><div><br></div><div>  1.1: where = BlockStack`main + 22 at main.m:27, address = 0x0000000100001c36, resolved, hit count = 1 </div><div><br></div>
<div>2: name = 'dispatch_async', locations = 1, resolved = 1</div><div>    Breakpoint commands:</div><div>      store_stack -a $arg2</div><div><br></div><div>  2.1: where = libdispatch.dylib`dispatch_async, address = 0x00007fff89753cb5, resolved, hit count = 0 </div>
<div><br></div><div>3: name = '_dispatch_call_block_and_release', locations = 1, resolved = 1</div><div>    Breakpoint commands:</div><div>      print_stack -a $arg1</div><div><br></div><div>  3.1: where = libdispatch.dylib`_dispatch_call_block_and_release, address = 0x00007fff89751a74, resolved, hit count = 0 </div>
</div><div><br></div><div>and the second break point gets called and the expression looking up the functions argument memory address description works as expected. The third breakpoint never hits, but it's debug command does. The debug command that hits for the third breakpoint resolves a garbage memory address and once it returns the debugger becomes unresponsive.</div>
<div><br></div><div>This is all on xcode 4.5 on lion</div><div><br></div><div>Thanks,</div><div>Doug Russell</div>