It might be a good idea to handle the process events yourself. We have some great sample code:
svn cat http://llvm.org/svn/llvm-project/lldb/trunk/examples/python/process_events.py This sample code shows you how to run a debug session and actually respond to all the events required to run a session. You should be able to insert your target create + connect code straight into this code and make it your own. Greg > On May 15, 2014, at 11:03 AM, Greg Clayton <[email protected]> wrote: > > >> On May 15, 2014, at 10:52 AM, Jason Dinh Ba Thanh <[email protected]> wrote: >> >> Should it be: >> >> target = debugger.CreateTarget (filename, triple, platform, False, error) > > Yes "debugger." is required before CreateTarget > >> >> I tried that and get error on this line >> process = target.ConnectRemote(debugger, "connect://localhost:1234", >> "gdb-remote", error) > > This should have been: > process = target.ConnectRemote(debugger.GetListener(), > "connect://localhost:1234", "gdb-remote", error) > >> >> File "lldbControl.py", line 54, in <module> >> process = target.ConnectRemote(debugger, "connect://localhost:1234", >> "gdb-remote", error) >> File >> "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/Python/lldb/__init__.py", >> line 7773, in ConnectRemote >> return _lldb.SBTarget_ConnectRemote(self, *args) >> >> This is an iPhone 4 running iOS 7 so I guess it's armv7, right? > > I believe so. > >> >> >> Jason >> >> >> On Fri, May 16, 2014 at 1:31 AM, Greg Clayton <[email protected]> wrote: >> >>> On May 15, 2014, at 9:30 AM, Jason Dinh Ba Thanh <[email protected]> wrote: >>> >>> I'm trying to do some research on iOS and it involves attaching lldb to a >>> process. I'm able to do it with lldb console, however when I'm trying to >>> convert it to a python script, it stuck at "process continue" for the first >>> time and never reach the commands at the end. Can anyone helps? Thanks. >>> >>> The code: http://pastebin.com/Yi380xFe >>> >>> I tried to get the attached process by "process = >>> debugger.GetSelectedTarget().GetProcess()" and call "process.Continue()" >>> but I'm getting the same result. >> >> >> I would try using the API a bit more instead of HandleCommand. Your original >> code: >> >> import lldb >> debugger = lldb.SBDebugger.Create() >> debugger.SetAsync(False) >> debugger.HandleCommand('platform select remote-ios') >> debugger.HandleCommand('process connect connect://localhost:1234') >> debugger.HandleCommand('process continue') >> >> New code using the API is a much better way: >> >> import lldb >> debugger = lldb.SBDebugger.Create() >> filename = None # fill this in if you know the local version of the >> executable file, else leave as None >> triple = 'armv7s-apple-ios' # Modify the ARM architecture to match >> platform = 'remote-ios' >> error = lldb.SBError() >> target = CreateTarget (filename, triple, platform, False, error) >> if target.IsValid(): >> process = target.ConnectRemote(debugger, "connect://localhost:1234", >> "gdb-remote", error) >> if process.IsValid(): >> process.Continue() >> >> > > _______________________________________________ > 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
