[lldb-dev] Python script stuck when trying to continue process in lldb

Greg Clayton gclayton at apple.com
Thu May 15 14:57:46 PDT 2014

> On May 15, 2014, at 11:36 AM, Jason Dinh Ba Thanh <bathanh at gmail.com> wrote:
> I'm able to attach to the process now, however when I try to run a simple command and it crashes
> if target.IsValid():
>     process = target.ConnectRemote(debugger.GetListener(), "connect://localhost:1235", "gdb-remote", error)
>     if process.IsValid():
>         debugger.HandleCommand('po [UIApplication sharedApplication]')
>         process.Continue()
> Crash log:
> Crashed Thread:  0  Dispatch queue: com.apple.main-thread
> Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
> Exception Codes: KERN_INVALID_ADDRESS at 0x00000000000000f8
> VM Regions Near 0xf8:
> --> 
>     __TEXT                 0000000104926000-0000000104928000 [    8K] r-x/rwx SM=COW  /usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
> Application Specific Information:
> HandleCommand(command = "po [UIApplication sharedApplication]")
> Regarding the stuck script in original post, it seems like debugger.SetAsync(False) make process.Continue() never return, is it a bug? Sorry if I'm asking a lot of simple questions, I just started with this.

No this isn't a bug. When you set async to false, you are requiring your process to run and stop before "process.Continue()" returns. This is why I pointed you to the process_events.py example which properly allows you to wait for events (like "process running", "process stopped") and also timeout waiting for an event and run some commands. Before you run an expression, you will need to make sure your process is up and running. If you have debugserver launching your process for you on the device, then it will be stopped at the entry point. This isn't a great time to be running an expression 'po [UIApplication sharedApplication]' since you haven't loaded _anything_ yet. You will want to let your application run for a while to get into its run loop, then interrupt it. This will ensure that the objective C runtime has loaded and your app is ready to evaluate expressions.

We shouldn't be crashing though no matter what you do.


More information about the lldb-dev mailing list