The main problem with your approach is the "debugger" you created is already 
the listener for all process events. The process requires a listener when it is 
launched or attached to, and since none was provided when you launched, it used 
the debugger.

We have an example checked in that does what you want:

svn cat 
http://llvm.org/svn/llvm-project/lldb/trunk/examples/python/process_events.py

Just take this script and modify it to your liking, or you can just use the 
debuggers built in listener instead of creating your own:

    listener = debugger.GetListener()
    if listener.WaitForEvent(10, event):



On Mar 14, 2014, at 4:46 AM, Hikaru Gosun <[email protected]> wrote:

> Hi,
> 
> I have a small script to debug a program in OSX that looks more or less like 
> this:
> 
> debugger = lldb.SBDebugger.Create()
> target = debugger.CreateTargetWithFileAndArch(exe, 
> lldb.LLDB_ARCH_DEFAULT_64BIT)
> launch_info = lldb.SBLaunchInfo(args)
> launch_info.SetLaunchFlags(lldb.eLaunchFlagNone)
> error = lldb.SBError()
> process = target.Launch(launch_info, error)
> if not error.Success():
>     print args, str(error)
>     return
> 
> listener = lldb.SBListener("event_listener")
> process.GetBroadcaster().AddListener(listener, 
> lldb.SBProcess.eBroadcastBitStateChanged)
> done = 0
> while not done:
>     event = lldb.SBEvent()
>     if listener.WaitForEvent(10, event):
>       state = lldb.SBProcess.GetStateFromEvent(event)
>       print state
>       for thread in process:
>         print thread, thread.GetFrameAtIndex(0)
>       process.Continue()
>     else:
>       done = 1
> 
> My intention is to debug the target with some kind of timeout, that's why I'm 
> trying to use the async mode and use the timeout in WaitForEvent(). The 
> problem that I'm facing is that once WaitForEvent() succeeds, there's no way 
> I can get access to the thread information (for example to get frame info for 
> each thread). This is the output from the script:
> 
> 5
> SBThread: tid = 0x2b9672 No value
> SBThread: tid = 0x2b9686 No value
> SBThread: tid = 0x2b9687 No value
> SBThread: tid = 0x2b9689 No value
> SBThread: tid = 0x2b968a No value
> SBThread: tid = 0x2b96be No value
> SBThread: tid = 0x2b96bf No value
> SBThread: tid = 0x2b96c0 No value
> 
> Any ideas? Is there anything wrong with my approach?
> 
> Thanks,
> HG
> _______________________________________________
> lldb-dev mailing list
> [email protected]
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev

_______________________________________________
lldb-dev mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev

Reply via email to