Skip to content

Instantly share code, notes, and snippets.

@airdrummingfool
Forked from chrismiles/reveal.py
Last active August 29, 2015 13:57
Show Gist options
  • Save airdrummingfool/9557081 to your computer and use it in GitHub Desktop.
Save airdrummingfool/9557081 to your computer and use it in GitHub Desktop.
""" File: reveal.py
1. Add to ~/.lldbinit:
command script import ~/.lldb-scripts/reveal.py
2. Add Run Script Build Phase to copy libReveal.dylib into the bundle
(see https://gist.github.com/airdrummingfool/9557257)
Q: Want to automatically load the Reveal lib on launch while debugging from Xcode?
A: In Xcode:
Add a Symbolic Breakpoint
Symbol: "UIApplicationMain"
Action: Debugger Command with value "reveal"
Tick "Automatically continue after evaluating"
"""
__author__ = 'Chris Miles'
__modified-by__ = 'Tommy Goode'
__copyright__ = 'Copyright (c) Chris Miles 2013'
__license__ = 'MIT'
def auto_load_reveal(debugger, command, result, dict):
debugger.HandleCommand('call (void*)dlopen((char*)[(NSString*)[(NSBundle*)[NSBundle mainBundle] pathForResource:@"libReveal" ofType:@"dylib"] cStringUsingEncoding:0x4], 0x2)')
def __lldb_init_module(debugger, internal_dict):
debugger.HandleCommand('command script add -f reveal.auto_load_reveal reveal')
@airdrummingfool
Copy link
Author

Changed the auto_load_reveal command to use libReveal.dylib copied into the app bundle (this works on both the simulator and devices, as long as you set up a Run Script phase to copy the file: https://gist.github.com/airdrummingfool/9557257).

@airdrummingfool
Copy link
Author

For some reason - in only one project - I started getting error: no known method '-cStringUsingEncoding:'; cast the message send to the method's return type when the breakpoint ran reveal, so I added a cast to char* which seems to have resolved it.

@anefkens
Copy link

I'm trying to use this script. There are two issues that do not work:

1: I need to set the full path to the script, the ~/ step does not work and results in a unknown function error.

2: The auto load function returns the following error:
error: no known method '-cStringUsingEncoding:'; cast the message send to the method's return type
error: 1 errors parsing expression

When I try to debug I see that when I do a "p" of the (char_)[(NSString_)[(NSBundle*)[NSBundle mainBundle] pathForResource:@"libReveal" ofType:@"dylib"] cStringUsingEncoding:0x4] I do get an result:

(char *) $5 = 0x0000000170110871 "/private/var/mobile/Containers/Bundle/Application/3EB35EF5-A398-48A5-91E5-D92037FB57E0/libReveal.dylib"

When I try remove the (char*) casting. If I do a "p" I get the same error.

For the problem is not just limited to one project, but all projects, and even a clean created project.

Any ideas that could fix this? I'm sure we should be able to sort this out.

I'm using Xcode 6.1.1. Device is running iOS 8, Mac is OS X 10.10.2

@anefkens
Copy link

Small addition, I only have the issue when I try to debug on a device. On the simulator it just works.

Since I'm debugging layout issues on a device that has to have BTLE connectivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment