<div dir="ltr">Yes Greg, this was my expectation that it should not return until stops on break-point. But I had to downgrade sequentially from 5.0 to 4.0 to 3.9 to make it work as expected.<div><br></div><div>Can I get some diagnostics? Any log files? </div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-02-13 20:11 GMT+03:00 Greg Clayton <span dir="ltr"><<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">The example code is:<div><br></div><div><pre><tt><font color="green">#!/usr/bin/python</font>
import lldb
import os
def disassemble_instructions(<wbr>insts):
for i in insts:
print i
<font color="green"># Set the path to the executable to debug</font>
exe = "./a.out"
<font color="green"># Create a new debugger instance</font>
debugger = lldb.SBDebugger.Create()
<font color="green"># When we step or continue, don't return from the function until the process
# stops. Otherwise we would have to handle the process events ourselves which, while doable is
#a little tricky. We do this by setting the async mode to false.</font>
debugger.SetAsync (False)
<font color="green"># Create a target from a file and arch</font>
print "Creating a target for '%s'" % exe
target = debugger.<wbr>CreateTargetWithFileAndArch (exe, lldb.LLDB_ARCH_DEFAULT)
if target:
<font color="green"># If the target is valid set a breakpoint at main</font>
main_bp = target.BreakpointCreateByName ("main", target.GetExecutable().<wbr>GetFilename());
print main_bp
<font color="green"># Launch the process. Since we specified synchronous mode, we won't return
# from this function until we hit the breakpoint at main</font>
process = target.LaunchSimple (None, None, os.getcwd())
<font color="green"># Make sure the launch went ok</font>
if process:
<font color="green"># Print some simple process info</font>
state = process.GetState ()
print process
if state == lldb.eStateStopped:
<font color="green"># Get the first thread</font>
thread = process.GetThreadAtIndex (0)
if thread:
<font color="green"># Print some simple thread info</font>
print thread
<font color="green"># Get the first frame</font>
frame = thread.GetFrameAtIndex (0)
if frame:
<font color="green"># Print some simple frame info</font>
print frame
function = frame.GetFunction()
<font color="green"># See if we have debug info (a function)</font>
if function:
<font color="green"># We do have a function, print some info for the function</font>
print function
<font color="green"># Now get all instructions for this function and print them</font>
insts = function.GetInstructions(<wbr>target)
disassemble_instructions (insts)
else:
<font color="green"># See if we have a symbol in the symbol table for where we stopped</font>
symbol = frame.GetSymbol();
if symbol:
<font color="green"># We do have a symbol, print some info for the symbol</font>
print symbol</tt></pre><div><br></div><div>We set the async mode to false, so target.LaunchSimple() should not return until the process is stopped or exited. Note in your example it is returning with "state = launching", so this is what is failing. For some reason synchronous mode is not being obeyed.</div><div><br></div><div>Greg</div><div><br></div><div><blockquote type="cite"><div><div class="h5"><div>On Feb 11, 2017, at 10:07 AM, Roman Popov via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org" target="_blank">lldb-dev@lists.llvm.org</a>> wrote:</div><br class="m_-4638887264522284321Apple-interchange-newline"></div></div><div><div><div class="h5"><div dir="ltr"><div>I'm testing example from <a href="https://lldb.llvm.org/python-reference.html" target="_blank">https://lldb.llvm.org/<wbr>python-reference.html</a> (USING THE LLDB.PY MODULE IN PYTHON) on Ubuntu 16.04</div><div><br></div><div>For some reason it works only with LLDB 3.9, is it because LLDB 4.0/5.0 are not stable yet?</div><div><br></div><div><pre>#5.0 -- Does not work</pre><pre>deb <a href="http://apt.llvm.org/xenial/" target="_blank">http://apt.llvm.org/xenial/</a> llvm-toolchain-xenial main</pre><pre># 3.9 -- Works</pre><pre>deb <a href="http://apt.llvm.org/xenial/" target="_blank">http://apt.llvm.org/xenial/</a> llvm-toolchain-xenial-3.9 main</pre><pre># 4.0 -- Does not work</pre><pre>deb <a href="http://apt.llvm.org/xenial/" target="_blank">http://apt.llvm.org/xenial/</a> llvm-toolchain-xenial-4.0 main</pre><pre><br></pre><pre><font>>clang-5.0 -g test.cpp<br></font></pre><pre><font>>./python_example.py</font></pre><pre><font>Creating a target for './a.out'
SBBreakpoint: id = 1, name = 'main', locations = 1
SBProcess: pid = 0, state = launching, threads = 0, executable = a.out</font></pre></div>Thanks,<div>Roman</div></div></div></div>
______________________________<wbr>_________________<br>lldb-dev mailing list<br><a href="mailto:lldb-dev@lists.llvm.org" target="_blank">lldb-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/lldb-dev</a><br></div></blockquote></div><br></div></div></blockquote></div><br></div>