<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi William,<div><br></div><div>Wonder if:</div><div><br></div><div>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=128755&view=rev">http://llvm.org/viewvc/llvm-project?rev=128755&view=rev</a><br>Log:<br>Add a Python script which launches a program from within lldb and loop until the<br>process stops for some reason. main.c (compiled into a.out) is used as an example in<br>the README-run-until-faulted file.<br><br>Added:<br> lldb/trunk/utils/test/README-run-until-faulted<br> lldb/trunk/utils/test/main.c<br> lldb/trunk/utils/test/run-until-faulted.py (with props)<br><div><div><br></div><div>is a good enough start for your need?</div><div><br></div><div>Thanks.</div><div><br></div><div>On Mar 31, 2011, at 6:15 PM, William Knop wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hello all,<br><br>I am attempting to use lldb to debug a segfault in my program that<br>happens sporadically. For instance, running `for ((i=0;i<1000;i++)) {<br>./myprogram; };` at a shell prompt may show one. It seems there is no<br>way to set lldb to run automatically and exit upon success from the<br>CLI, so I've been exploring lldb's python scripting.<br><br>The goal of the script is to loop, launching the process until<br>completion or error; if there's an error, I need the script to dump me<br>back into the lldb interpreter to investigate the bug. Here's what<br>I've come up with so far:<br><br><blockquote type="cite">import time<br></blockquote><blockquote type="cite">dbg = lldb.SBDebugger.FindDebuggerWithID(lldb.debugger_unique_id)<br></blockquote><blockquote type="cite">ci = dbg.GetCommandInterpreter()<br></blockquote><blockquote type="cite">res = lldb.SBCommandReturnObject()<br></blockquote><blockquote type="cite">dbg.SetAsync(False)<br></blockquote><blockquote type="cite">for i in range(1, 1000):<br></blockquote><blockquote type="cite"> ci.HandleCommand("process launch", res)<br></blockquote><blockquote type="cite"> while (not res.Succeeded()) : time.sleep(0.1)<br></blockquote><blockquote type="cite"> res.Clear()<br></blockquote><br>Unfortunately, however, it seems the command does not run to<br>completion, no matter how long I wait. Then when I call<br>`HandleCommand` a second time, lldb deadlocks. I intended to<br>eventually check `res.GetError()` or `res.GetStatus()` and call<br>`quit()` when the error appeared, but I haven't made it that far. I<br>also initially explored calling `dbg.GetTargetAtIndex(0).Launch()`<br>rather than `HandleCommand`, but I wasn't entirely sure how to go<br>about it. Any help would be much appreciated!<br><br>Will<br>_______________________________________________<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></div></blockquote></div><br></div></body></html>