<div dir="ltr">Hi Greg,<div><br></div><div>awesome, this works like a charm! Thanks for the help.</div><div><br></div><div>ciao,</div><div>Mario</div><div><br><div class="gmail_extra"><div class="gmail_quote">On Fri, Sep 19, 2014 at 8:04 PM, Greg Clayton <span dir="ltr"><<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Try creating your target first, then give the platform file spec _before_ connecting, then connect remote<br>
<br>
local_path = "/host/machine/path/com.robovm.test.IOSDemo.app"<br>
triple = "armv7-apple-ios"<br>
platform = "remote-ios"<br>
add_dependent_modules = False<br>
error = lldb.SBError()<br>
<br>
target = debugger.CreateTarget (local_path, triple, platform, add_dependent_modules, error)<br>
<span>lldb.target.modules[0].SetPlatformFileSpec(lldb.SBFileSpec("/private/var/mobile/Containers/Bundle/Application/D26F7D18-CEBA-472A-9BD9-2978FB1D8E46/com.robovm.test.IOSDemo.app"))<br>
process = lldb.target.ConnectRemote(lldb.target.GetDebugger().GetListener(), "connect://localhost:8889", None, error)<br>
</span>if process.IsValid():<br>
target.Launch(lldb.SBLaunchInfo([]), error)<br>
<br>
Don't use the LLDB globals (lldb.target or lldb.process), use your local variables.<br>
<br>
Let me know if this helps. Send another full packet log. It seems like your packets tried to start the process which should have worked. You might also want to check the device console to make sure the device was happy with the app and its entitlements and code signing. Also make sure the program finger launches first to make sure it is signed correctly.<br>
<span><font color="#888888"><br>
Greg<br>
</font></span><div><div><br>
><br>
<br>
> On Sep 19, 2014, at 10:53 AM, Mario Zechner <<a href="mailto:badlogicgames@gmail.com" target="_blank">badlogicgames@gmail.com</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> i've removed any and all intervention between lldb and the debug server on the device, but i'm at a loss at how to set up the target and process.<br>
><br>
> Currently this happens:<br>
> 1) i fire up a debug server on the ios device (through libimobiledevice). This debug server does not attach or launch any process on the device, it just waits for someone to connect.<br>
> 2) i start a forwarding server on my local machine at some port which forwards any messages to the debug server on the device verbatim, and also returns any messages from the debug server to the connected client.<br>
> 3) i start lldb, and do the following:<br>
> platform select remote-ios // no errors, sdks are resolved, platform is not connected<br>
><br>
> 4) i create a target to the executable on the local disk via<br>
><br>
> (lldb) target create /tmp/robovm.HelloWorld.ios/com.robovm.test.IOSDemo.app<br>
> Current executable set to '/tmp/robovm.HelloWorld.ios/com.robovm.test.IOSDemo.app' (armv7).<br>
><br>
> 5) launch the target on the device through calling into the LLDB API from within the LLDB CLI.<br>
><br>
> error = lldb.SBError()<br>
> process = lldb.target.ConnectRemote(lldb.target.GetDebugger().GetListener(), "connect://localhost:8889", None, error)<br>
> lldb.target.modules[0].SetPlatformFileSpec(lldb.SBFileSpec("/private/var/mobile/Containers/Bundle/Application/D26F7D18-CEBA-472A-9BD9-2978FB1D8E46/com.robovm.test.IOSDemo.app"))<br>
> lldb.target.Launch(lldb.SBLaunchInfo([]), error)<br>
><br>
><br>
> Which also doesn't seem to work:<br>
> Sending packet (client): +<br>
> Sending packet (client): $QStartNoAckMode#b0<br>
> Received packet: +$OK#9a<br>
> Sending packet (client): +$QThreadSuffixSupported#e4<br>
> Received packet: $OK#00<br>
> Sending packet (client): $QListThreadsInStopReply#21<br>
> Received packet: $OK#00<br>
> Sending packet (client): $qHostInfo#9b<br>
> Received packet: $cputype:12;cpusubtype:10;ostype:ios;watchpoint_exceptions_received:before;vendor:apple;endian:little;ptrsize:4;#00<br>
> Sending packet (client): $vCont?#49<br>
> Received packet: $vCont;c;C;s;S#00<br>
> Sending packet (client): $qVAttachOrWaitSupported#38<br>
> Received packet: $OK#00<br>
> Sending packet (client): $qProcessInfo#dc<br>
> Received packet: $E68#00<br>
> Sending packet (client): $qC#b4<br>
> Received packet: $QC0#00<br>
> Sending packet (client): $QSetDisableASLR:1#ce$QSetDetachOnError:0#f7<br>
> Received packet: $OK#00<br>
> Received packet: $#00<br>
> Sending packet (client): $QLaunchArch:armv7#51<br>
> Received packet: $OK#00<br>
> Sending packet (client): $A228,0,2f707269766174652f7661722f6d6f62696c652f436f6e7461696e6572732f42756e646c652f4170706c69636174696f6e2f44323646374431382d434542412d343732412d394244392d3239373846423144384534362f636f6d2e726f626f766d2e746573742e494f5344656d6f2e617070#c9<br>
> Received packet: $OK#00<br>
> Sending packet (client): $qLaunchSuccess#a5<br>
> Received packet: $OK#00<br>
> Sending packet (client): $qProcessInfo#dc<br>
> Received packet: $pid:112;parent-pid:110;real-uid:1f5;real-gid:1f5;effective-uid:1f5;effective-gid:1f5;cputype:c;cpusubtype:b;ostype:ios;vendor:apple;endian:little;ptrsize:4;#00<br>
> Sending packet (client): $qC#b4<br>
> Received packet: $QC3e96#00<br>
><br>
> The app launches, but lldb closes the connection to the debug server and hangs on the lldb.target.Launch() command.<br>
><br>
> I'm terribly sorry for bugging this list, i know this is not something that usually comes up. i've tried to exhaust all available material on this problem (web, lldb source) but am none the wiser. I'd appreciate any guidance on how to remotely start and debug an ios app on a device via the LLDB command line tool.<br>
><br>
> Thanks,<br>
> Mario<br>
><br>
><br>
><br>
><br>
> On Fri, Sep 19, 2014 at 6:41 PM, Greg Clayton <<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>> wrote:<br>
><br>
> > On Sep 19, 2014, at 9:06 AM, Mario Zechner <<a href="mailto:badlogicgames@gmail.com" target="_blank">badlogicgames@gmail.com</a>> wrote:<br>
> ><br>
> > Hi,<br>
> ><br>
> > i'm trying to spin up an app on an ios device and then remotely connect to it. I'm starting starting a debug server on the device, then tell it to launch a specific app via the gdb-remote protocol, e.g.<br>
> ><br>
> > Sending packet: +<br>
> > Sending packet: $QStartNoAckMode#b0<br>
> > Received ack: +<br>
> > Received packet: $OK#9a<br>
> > Sending packet: +<br>
> > Sending packet: $QEnvironment:NSUnbufferedIO=YES#8d<br>
> > Received packet: $OK#00<br>
> > Sending packet: $QListThreadsInStopReply#21<br>
> > Received packet: $OK#00<br>
> > Sending packet: $A228,0,2f707269766174652f7661722f6d6f62696c652f436f6e7461696e6572732f42756e646c652f4170706c69636174696f6e2f44323736423144342d363135372d343837372d383839332d3338334630434437354233392f636f6d2e726f626f766d2e746573742e494f5344656d6f2e617070,28,1,2d72766d3a6c6f673d7472616365#ca<br>
> > Received packet: $OK#00<br>
> > Sending packet: $qLaunchSuccess#a5<br>
> > Received packet: $OK#00<br>
> ><br>
> > The app launches successfully. Next i setup a local server socket which then forwards the communication between lldb and the debugserver.<br>
> ><br>
> > In lldb, i set the platform to remote-ios, and create at target pointing at the local version of the executable file of the ios app, and then call gdb-remote which connects to the local forwarding socket:<br>
> ><br>
> > (lldb) platform select remote-ios<br>
> > Platform: remote-ios<br>
> > Connected: no<br>
> > SDK Path: "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/8.0 (12A365)"<br>
> > SDK Roots: [ 0] "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.2"<br>
> > SDK Roots: [ 1] "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3"<br>
> > SDK Roots: [ 2] "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/5.0"<br>
> > SDK Roots: [ 3] "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/5.1"<br>
> > SDK Roots: [ 4] "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/6.0"<br>
> > SDK Roots: [ 5] "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/6.1"<br>
> > SDK Roots: [ 6] "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/7.0"<br>
> > SDK Roots: [ 7] "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/7.1"<br>
> > SDK Roots: [ 8] "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/8.0 (12A365)"<br>
> > SDK Roots: [ 9] "/Users/badlogic/Library/Developer/Xcode/iOS DeviceSupport/7.1.1 (11D201)"<br>
> > SDK Roots: [10] "/Users/badlogic/Library/Developer/Xcode/iOS DeviceSupport/8.0 (12A365)"<br>
> > (lldb) target create /tmp/robovm.HelloWorld.ios/com.robovm.test.IOSDemo.app/com.robovm.test.IOSDemo<br>
> > Current executable set to '/tmp/robovm.HelloWorld.ios/com.robovm.test.IOSDemo.app/com.robovm.test.IOSDemo' (armv7).<br>
> > (lldb) gdb-remote 8889<br>
> ><br>
> > The debugserver and lldb then exchange a few messages:<br>
> ><br>
> > Sending packet (client): $QListThreadsInStopReply#21$qHostInfo#9b<br>
> > Received packet: $OK#00<br>
> > Received packet: $cputype:12;cpusubtype:10;ostype:ios;watchpoint_exceptions_received:before;vendor:apple;endian:little;ptrsize:4;#00<br>
> > Sending packet (client): $vCont?#49<br>
> > Received packet: $vCont;c;C;s;S#00<br>
> > Sending packet (client): $qVAttachOrWaitSupported#38<br>
> > Received packet: $OK#00<br>
> > Sending packet (client): $qProcessInfo#dc<br>
> > Received packet: $pid:2e9;parent-pid:2e8;real-uid:1f5;real-gid:1f5;effective-uid:1f5;effective-gid:1f5;cputype:c;cpusubtype:b;ostype:ios;vendor:apple;endian:little;ptrsize:4;#00<br>
> > Sending packet (client): $qC#b4<br>
> > Received packet: $QC108d6#00<br>
> ><br>
> > Note that the +$QStartNoAckMode#b0 message is not forwarded to the debug server but directly replied to by the forwarding server.<br>
><br>
> That is your problem. If you reply "OK" to "QStartNoAckMode", we stop sending ACK and NACK packets. This will obviously hose up any communication you do after that.<br>
><br>
> ><br>
> > LLDB seems be confused from this point onwards. It seems to think that a process has been launched but is unable to provide any information on the process or interrupt it or interact with it in any other way.<br>
> ><br>
> > I'd be greatful if somebody could point out any errors in the above workflow (apart from not using XCode, which is sadly not an option)<br>
> ><br>
> > Thanks,<br>
> > Mario<br>
> ><br>
> ><br>
> ><br>
> ><br>
> > _______________________________________________<br>
> > lldb-dev mailing list<br>
> > <a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a><br>
> > <a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
><br>
><br>
<br>
</div></div></blockquote></div><br></div></div></div>