Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support iOS 7 / lldb #5

Closed
shazron opened this issue Sep 10, 2013 · 32 comments
Closed

Support iOS 7 / lldb #5

shazron opened this issue Sep 10, 2013 · 32 comments

Comments

@shazron
Copy link

shazron commented Sep 10, 2013

With iOS 7 / Xcode 5, gdb support has been removed. Support lldb.

@shazron
Copy link
Author

shazron commented Sep 12, 2013

Note that the patch does not apply cleanly, it will have to be manually patched.

@SteveAR
Copy link

SteveAR commented Sep 13, 2013

Using your patch I managed to get lldb to execute, but I'm stuck here:

[100%] Connecting to remote debug server
-------------------------
run
(lldb) run
Traceback (most recent call last):
  File "/private/tmp/fruitstrap.py", line 7, in __lldb_init_module
    lldb.target.modules[0].SetPlatformFileSpec(lldb.SBFileSpec(device_app))
IndexError: list index out of range
error: the platform is not currently connected

Any pointers to what I might miss?

@hcrowell
Copy link

I'm seeing this error too. Anyone know how to resolve it?

@shazron
Copy link
Author

shazron commented Sep 18, 2013

Not sure guys, will have to debug the python code :/ (lldb.target.modules is probably null here).

Also, a further patch: https://github.com/trigger-corp/fruitstrap/commit/04121e5351669f3c977857795143c04123f1a02f

@eternallam
Copy link

I'm getting the following error:

(lldb) run
Executing commands in '/tmp/fruitstrap-lldb-prep-cmds'.
(lldb) script fruitstrap_device_app="/private/var/mobile/Applications/5E125D7F-C63C-4FF3-839F-58AF60ADA9CF/MyApp.app"
(lldb) script fruitstrap_connect_url="connect://127.0.0.1:12345"
(lldb) platform select remote-ios
Platform: remote-ios
Connected: no
SDK Path: error: unable to locate SDK
(lldb) target create "/path/MyApp.app"
Current executable set to '/path/MyApp.app' (armv7).
(lldb) #settings set target.process.extra-startup-command "QSetLogging:bitmask=LOG_ALL;"
(lldb) command script import "/tmp/fruitstrap.py"
error: Aborting reading of commands after command #5: ' command script import "/tmp/fruitstrap.py"' failed with error: module importing failed: Python error raised while importing module: ('expected an indented block', ('/private/tmp/fruitstrap.py', 5, 10, "device_app=internal_dict['fruitstrap_device_app']\n")) - traceback: File "temp.py", line 1, in
error: the platform is not currently connected

shazron added a commit that referenced this issue Sep 19, 2013
…rors IndexError: list index out of range)
@shazron
Copy link
Author

shazron commented Sep 19, 2013

Can those on this thread check their lldb version? I have a strong suspicion that the lldb support wasn't tested on the lldb that came with Xcode 5. Not sure if the lldb interfaces would have changed in the interim...

lldb --version

On Xcode 5 GM, the lldb version I get is lldb-300.2.47
On Xcode 4.6.3 (I tested on a VM) I get the version as LLDB-179.5

@shazron
Copy link
Author

shazron commented Sep 19, 2013

I downloaded and ran trigger-corp's fruitstrap, and ran into the same "IndexError: list index out of range" error, so it looks more likely to be an lldb usage issue.

@shazron
Copy link
Author

shazron commented Sep 19, 2013

@eternallam check out my branch referenced above, then we can be on the same page.

@hcrowell
Copy link

@shazron Thanks for looking into this.
I also saw this error in my lldb version, which is lldb-300.5.46

@shazron
Copy link
Author

shazron commented Sep 19, 2013

@eternallam
Copy link

@shazron Thanks, now I'm seeing the same error you guys are getting.

lldb --version
lldb-300.5.46

@shazron
Copy link
Author

shazron commented Sep 19, 2013

More clues, I ran the .py scripts line by line:

$ lldb
(lldb) script fruitstrap_device_app="/private/var/mobile/Applications/8CDB95DC-4153-4897-90A4-B9CADCC0891C/InputTest.app"
(lldb) script fruitstrap_connect_url="connect://127.0.0.1:12345"
(lldb) platform select remote-ios
  Platform: remote-ios
 Connected: no
  SDK Path: error: unable to locate SDK

@hcrowell
Copy link

I attempted to resolve the SDK Path error by replacing line 31 in fruitstrap.c:
from:
platform select remote-ios
to: (on one line)
platform select remote-ios --sysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/*\n\

I verified in the lldb.log and found the 'unable to locate SDK' error seemed to be resolved by this attempt:

// lldb.log snippet

SBCommandReturnObject(0x7fdccb827880)::GetOutput () => "Executing commands in '/tmp/fruitstrap-lldb-prep-cmds'.
(lldb) script fruitstrap_device_app="/private/var/mobile/Applications/KIF.app"
(lldb) script fruitstrap_connect_url="connect://127.0.0.1:12345"
(lldb) platform select remote-ios --sysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/*
Platform: remote-ios
Connected: no
SDK Path: "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/*"
(lldb) target create "/tmp/build/KIF.app"
Current executable set to '/tmp/build/KIF.app' (armv7).
(lldb) #settings set target.process.extra-startup-command "QSetLogging:bitmask=LOG_ALL;"
(lldb) command script import "/tmp/fruitstrap.py"
"

Maybe this will help?

@shazron
Copy link
Author

shazron commented Sep 20, 2013

@hcrowell no dice :/

@hcrowell
Copy link

@shazron aww :( i'm not sure how to resolve this

@thefbiman
Copy link

Hi there,

Managed to get over the list index out of range using this modified order in prep cmds:

platform select remote-ios --sysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/*\n
target create "{disk_app}"\n
script fruitstrap_device_app="{device_app}"\n
script fruitstrap_connect_url="connect://127.0.0.1:12345"\n\

But, am now blocked at launch time, as i get "a process is already being debugged" when calling lldb.target.Launch(lldb.SBLaunchInfo(None),error). Nothing is launched...

any help would be appreciated.

@SteveAR
Copy link

SteveAR commented Sep 25, 2013

we ended up using the new XCTest framework for now. It can also be used to build and install an app on a device.

@thefbiman
Copy link

I will still use fruitstrap as i need some features that comes with it. So, here it goes.

Managed to work over the "a process is already being debugged" issue, was caused by remaining lldb & python processes.

Also, added command line parameters that were actually missing from the patch above.

You need to add the following:

#define LLDB_FRUITSTRAP_MODULE CFSTR(
...
def fsrun_command(debugger, command, result, internal_dict):\n
error=lldb.SBError()\n
lldb.target.Launch(lldb.SBLaunchInfo(['{args}']),error)\n
print str(error)\n
")
...
void write_lldb_prep_cmds(AMDeviceRef device, CFURLRef disk_app_url) {
...
if (args) {
CFStringRef cf_args = CFStringCreateWithCString(NULL, args, kCFStringEncodingASCII);
CFStringFindAndReplace(cmds, CFSTR("{args}"), cf_args, range, 0);
#if USE_LLDB
//format the arguments 'arg1 arg2 ....' to an argument list ['arg1', 'arg2', ...]
pmodule = CFStringCreateMutableCopy(NULL, 0, LLDB_FRUITSTRAP_MODULE);
CFMutableStringRef argsListLLDB = CFStringCreateMutableCopy(NULL, 0, cf_args);
CFRange rangeLLDB = { 0, CFStringGetLength(argsListLLDB) };
CFStringFindAndReplace(argsListLLDB, CFSTR(" "), CFSTR(" "), rangeLLDB, 0);//remove multiple spaces
rangeLLDB.length = CFStringGetLength(argsListLLDB);
CFStringFindAndReplace(argsListLLDB, CFSTR(" "), CFSTR("', '"), rangeLLDB, 0);
rangeLLDB.length = CFStringGetLength(pmodule);

    CFStringFindAndReplace(pmodule, CFSTR("{args}"), argsListLLDB, rangeLLDB, 0);   

#endif//USE_LLDB

Hope this helps others.

Also, i still have one issue: lldb takes a long time to launch. From the time i get " Process 0 connected" and "(lldb) run" to the time the applications actually starts working, it takes around 1-2 mins. Notice that in this time i get the application displayed on the device, but not updating.
This seams to be cause by didFinishLaunching which is received only after those about 1-2 mins. Any idea about this?

@shazron
Copy link
Author

shazron commented Oct 1, 2013

thanks@thefbiman! will get this integrated. Will work through the issues incrementally I suppose...

@markusjura
Copy link

Thanks to @thefbiman. This trick worked yesterday for me as well. However, today the app is not starting on the device anymore.

lldb is executing:
(lldb) run
Process 0 connected

Yesterday, when it was working, it was executing it in the following order:
Process 0 connected
(lldb) run

Any idea how to solve this?

Yesterday, when it was still working, I also faced the problem that loading takes 1 min. before the app has been launched on the device. Any idea how to solve that?

@markusjura
Copy link

The issue 'working yesterday, but not today' was related that I still had python and lldb processes running. Problem was solved by killing these.

Still interested how to decrease the loading time.

@eternallam
Copy link

Would also like to figure out how to better end the lldb process after the app finishes running. I know this is related to the sleep timer however I would like the process to automatically quit back to the command line after the process has finished.

@thefbiman
Copy link

Hello there,
For now, to eliminate the huge loading time, i use the gdb version with a little trick, injected gdb server inside xcode5 app:

  • Look for content\developer\platforms\iphoneos.platform\developer\usr\libexec, on xcode5 you only have 1 folder there, as.
  • You need to copy gdb folder from xcode4.X app and place it near the as folder in xcode5.
  • chmod 777 on the included binary from that folder so it can execute.
    This is a tempo fix for use till we figure out why that big launch delay with lldb.

@micmarcil
Copy link

When I launch the following :
./fruitstrap debug --bundle "my_app"

It stucks on "Use 'run' to start the app.".
I have to type the 'run' manually, which is not cool for automated process :(

Any way to inject the 'run' automatically ?

Thanks

@eternallam
Copy link

@micmarcil The run command is automatically injected. Take a look at line 20 of the source.

Has anyone else been able to make further headway on this issue? Currently looking for a way to automatically end lldb after the process has finish running. In addition removing the delay would be a great help.

@shazron
Copy link
Author

shazron commented Oct 22, 2013

I just tried out this fruitstrap fork, and it works with lldb: https://github.com/markusjura/fruitstrap
(note when I tested on a new project, it took about a minute for an app to fully load through the debugger)

@shazron
Copy link
Author

shazron commented Oct 22, 2013

Version 1.0.4 published with lldb support.

@shazron shazron closed this as completed Oct 22, 2013
@halfnelson
Copy link

on xcode 4.7 running ios-deploy 1.0.4 latest i am getting:

(lldb) run
error: invalid target, create a debug target using the 'target create' command
(lldb)

@tcab
Copy link

tcab commented Mar 27, 2014

I also get this error
(lldb) run
error: invalid target, create a debug target using the 'target create' command
(lldb)
at the end of my command

phonegap run ios

which used to work fine, till I upgraded xcode to 5.1 and phonegap to 3.4.0-0.19.8

P.S. And phonegap now spits out pages of information when I run that command - it used to be silent.

@shazron
Copy link
Author

shazron commented Mar 27, 2014

Try the newly released 1.0.5

@markusv
Copy link

markusv commented Apr 5, 2014

Hi,

I have this problem to. Would love a solution for this.

Cheers
Markus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants