[lldb-dev] issues with python scripting in LLDB

Enrico Granata granata.enrico at gmail.com
Fri Nov 4 05:20:19 PDT 2011


Hi Michael,
I have tried to reproduce your issue (BTW, which version of LLDB are you using? - I have tried with a revision of the code from yesterday).
I have defined your script as a Python command using "command script add".
In my case, there is no lockup, but the SBThread::StepOver() function appears to "over-step" and the test program terminates prematurely at the end of the stepping.
The issue, which effectively does not occur when sleeping between the several calls, seems to be related to the StepOver() method itself. I have also tried changing the lldb.thread.StepOver() call with debugger.HandleCommand("thread step-over -m this-thread"), but doing so, the test program terminates and the thread gets deselected. If thread.StepOver() is replaced with some other operation that does not involve threading (I have used debugger.HandleCommand("frame variable") in my example), everything works as it should.
I would bet the issue lies in stepping over itself, but I have never worked on ThreadPlans, so I leave it to someone who knows more about them.

As per your second question, you may want to try the solution described here: http://stackoverflow.com/questions/230751/how-to-flush-output-of-python-print

I have attached the Python script and test program used.


Sincerely,
- Enrico Granata

On Nov 4, 2011, at 7:58 AM, michael wrote:

> I have a script, something like:
> 
> #########################
> import lldb
> import sys
> import os
> import time
> 
> def StepOver(debugger, args, result, dict):
>   arg_split = args.split(" ")
>   print type(arg_split)
>   count = int(arg_split[0])
>   for i in range(0,count):
>     lldb.thread.StepOver(lldb.eOnlyThisThread)
>     print "step<%d>"%i
>     time.sleep(.75)
> ##########################
> 
> I also have an command shortcut assigned to call it.
> 
> I have 2 issues:
> 1. I have to sleep in the loop (for some period over some threshold),
>     or the script seems to lock up.
>     Is this due to some race condition ?
> 2. how can I force a console flush inside the loop, currently the console
>     is deferred until the script returns. Is there some sort of yield
>     or console flush command?
> 
> Thanks,
> 
> mtm
> 
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20111104/c4fc37f6/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: script.py
Type: text/x-python-script
Size: 502 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20111104/c4fc37f6/attachment.bin>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20111104/c4fc37f6/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: programma.cpp
Type: application/octet-stream
Size: 113 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20111104/c4fc37f6/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20111104/c4fc37f6/attachment-0002.html>


More information about the lldb-dev mailing list