<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>A quick note about how you are setting your breakpoints in your "set_dispatch_breakpoints" function: you can use the SBTarget API so you don't have to get the count in order to guess at the breakpoint ID. There is a global named "lldb.target" that contains a link to the currently selected target, so the breakpoint can be set using the API. We still don't have a way to set the breakpoint command through the SBBreakpoint API, so the function can be simplified to:</div><div><br></div><div>def set_dispatch_breakpoints(debugger, command, result, dict):</div><div> bp = lldb.target.BreakpointCreateByName('dispatch_async')</div><div> debugger.HandleCommand("breakpoint command add -s command {index} -o 'store_stack -a $arg2'".format(index=bp.GetID()))</div><div> bp = lldb.target.BreakpointCreateByName('_dispatch_call_block_and_release')</div><div> lldb.debugger.HandleCommand("breakpoint command add -s command {index} -o 'print_stack -a $arg1'".format(index=bp.GetID()))</div><div> </div><div> </div><div>The "bp" objects are lldb.SBBreakpoint objects (do a "help(lldb.SBBreakpoint)" in the python interactive interpreter to get help on that class (and any other class or object in python!)) so you can get their breakpoint ID using "bp.GetID()".</div><div> </div><div>Another thing to note in the "lldbutil.print_stacktrace" function: you don't need to make up the following arrays:</div><div> </div><div> mods = get_module_names(thread)</div><div> funcs = get_function_names(thread)</div><div> symbols = get_symbol_names(thread)</div><div> files = get_filenames(thread)</div><div> lines = get_line_numbers(thread)</div><div> addrs = get_pc_addresses(thread)</div><div><br></div><div><br></div><div>The following are equivalent in your loop:</div><div><br></div><div> mods[i] -> frame.module</div><div> funcs[i] -> frame.function</div><div> symbols[i] -> frame.symbol</div><div> files[i] -> frame.line_entry.file.fullpath</div><div> lines[i] -> frame.line_entry.line</div><div> addrs[i] -> frame.addr</div><div><br></div><div>All symbol context (module, file, function, block, file + line, symbol) are all cached in the frame objects and only created once so they are very efficient.</div><div><br></div><div>I am not sure what is going on in your script yet, but I will take a look and get back to you.</div><div><br></div><div>Greg Clayton</div><div><br></div><div><div>On Jun 23, 2012, at 7:42 PM, Doug Russell wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">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>
_______________________________________________<br>lldb-dev mailing list<br><a href="mailto:lldb-dev@cs.uiuc.edu">lldb-dev@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev<br></blockquote></div><br></body></html>