Tagged: Debugging Toggle Comment Threads | Keyboard Shortcuts

  • toto 15:51 on 4. June 2012 Permalink | Reply
    Tags: Debugging, , ,   

    Honey, where’s my dSYM? 

    Ever wondered how Xcode can symbolicate crash reports without you telling it the appropriate dSYM file? Xcode uses Spotlight to find the dSYMs on your system by adding a special attribute to the dSYMs Spotlight metadata. So with this CLI command you can find out where Xcode is (and isn’t) looking for the dSYM files:

    $ mdfind 'com_apple_xcode_dsym_uuids = *'  

  • Ullrich 13:45 on 7. December 2011 Permalink | Reply
    Tags: Debugging, , ,   

    Remote Web Inspector Pt. 2 

    It gets even better, because this also works in Mobile Safari on the iOS 5 Simulator!

    Here’s a little script you can run, that enables the remote Web Inspector via gdb (via @atnan).

    Here’s to all the mobile devs!

  • Ullrich 13:07 on 7. December 2011 Permalink | Reply
    Tags: Debugging, ,   

    Remote Web Inspector 

    We recently stumbled across a blog post mentioning a way to enable a remote interface to a web inspector that is hidden inside the WebKit on iOS 5.

    Here’s how it’s done. In your Application Delegate add the following code:

    + (void)initialize;
        [NSClassFromString(@"WebView") performSelector:@selector(_enableRemoteInspector)];

    With this you can direct your browser to http://localhost:9999 to open the web inspector.

    Have fun!

    • Ullrich 13:51 on 7. December 2011 Permalink

      Remember that this will influence you’re App Store review experience ;)

  • Ullrich 18:26 on 27. September 2011 Permalink | Reply
    Tags: , Debugging,   

    Symbolicating without Xcode 

    Ever wanted to symbolicate a incomplete crash file (i.e. the logs you get from TestFlight)?

    You can symbolicate individual addresses from the crashlog in the terminal using a command named `atos` (if you’ve got the dSYM file for your build). Here’s an example:

    atos -arch armv7 -o MyApp.app.dSYM/Contents/Resources/DWARF/MyApp 0x0000babe

    This will output you the line of code related to this address. I.e.:

    +[MyHappyClass fullOfFail] (in MyApp) + 429

    Pro Tip: not entering the address when calling the atos command leaves you in STDIN mode. Here you can add multiple addresses without restarting the tool.

  • Gernot 11:16 on 20. October 2010 Permalink | Reply
    Tags: Animations, Debugging, Simulator   

    How to slow down Simulator Animations 

    There’s a new way to slow down simulator which is really handy in case you want to debug rotation animations:

    • In the Hardware menu, enable “Simulate Hardware Keyboard”.
    • Hit the shift key three times in a row

    Now all the animations are slowed down for debugging. Triple-hit Shift again to deactivate.

  • Ullrich 09:14 on 14. October 2010 Permalink | Reply
    Tags: , , Debugging, ,   

    Colliding Category Methods 

    After multiple years of Objective-C experience yesterday was the first time that we actually ran into problems with colliding methods in categories.

    Here’s the story (you may skip this part): The issue was, that we added a method -setParameters: to NSMutableURLRequest which takes a dictionary and set’s it as query string or multipart form body depending on the HTTP Method used for sending the request. This method sadly conflicted with a category on the same class defined in a library called OAuthConsumer which doesn’t take a dictionary as argument but rather an array of key-value pairs. Both categories we’re linked to our application as static libraries.

    The result was that our -setParameters: was called with an array although a dictionary was expected. We noticed the problem since NSArray is not responding to -allKeys. It could have gone would have not noticed the problem. Just imagine trying to debug a misbehavior when you’re looking at the wrong piece of code.

    The quintessence, and what basically helped us finding the issue is a environment variable named OBJC_PRINT_REPLACED_METHODS. Similar to NSZombieEnabled you set it in the Arguments tab of your executable info as variable set to environment. Just like this:

  • Ullrich 15:27 on 27. September 2010 Permalink | Reply
    Tags: , Debugging,   


    Everyone should know the NSZombieEnabled environment variable. Set it to YES to temporarily disable deallocation of objects which reach a retain count of zero. You then can set breakpoints to common methods such as:

    fb -[_NSZombie init]
    fb -[_NSZombie retainCount]
    fb -[_NSZombie retain]
    fb -[_NSZombie release]
    fb -[_NSZombie autorelease]
    fb -[_NSZombie methodSignatureForSelector:]
    fb -[_NSZombie respondsToSelector:]
    fb -[_NSZombie forwardInvocation:]
    fb -[_NSZombie class]
    fb -[_NSZombie dealloc]

    But you should also know that this only works on NS classes. To have a similar effect on CoreFoundation classes use CFZombieLevel. The value of CFZombieLevel is defined by a bit array. See the following table. A good value is 5 :)

    Bit	Action
    0	scribble deallocated CF memory
    1	when scribbling deallocated CF memory, don't scribble object header (CFRuntimeBase)
    4	never free memory used to hold CF objects
    7	if set, scribble deallocations using bits 8..15, otherwise use 0xFC
    8..15	if bit 7 is set, scribble deallocations using this value
    16	scribble allocated CF memory
    23	if set, scribble allocations using bits 24..31, otherwise use 0xCF
    24..31	if bit 16 is set, scribble allocations using this value
  • Ullrich 15:34 on 16. April 2010 Permalink | Reply
    Tags: Debugging,   

    My list of breakpoints. Add them to your ~/.gdbinit

    fb -[NSException raise]
    fb -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:]
    fb -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
    fb NSKVODeallocateBreak
    fb _NSAutoreleaseNoPool
    fb -[_NSZombie init]
    fb -[_NSZombie retainCount]
    fb -[_NSZombie retain]
    fb -[_NSZombie release]
    fb -[_NSZombie autorelease]
    fb -[_NSZombie methodSignatureForSelector:]
    fb -[_NSZombie respondsToSelector:]
    fb -[_NSZombie forwardInvocation:]
    fb -[_NSZombie class]
    fb -[_NSZombie dealloc]
    fb szone_error
    fb objc_exception_throw
    fb malloc_error_break
    fb CGPostError
    fb malloc_printf
    fb _objc_error
    fb objc_exception_during_finalize_error
    fb auto_zone_resurrection_error
    fb auto_refcount_underflow_error

    UPDATE: added _NSAutoreleaseNoPool breakpoint to stop when there’s no autorelease pool but one is expected.

  • Ullrich 11:53 on 27. November 2009 Permalink | Reply
    Tags: Debugging,   

    Use NSAssert(…) during development.
    But set NS_BLOCK_ASSERTIONS pre compiler flag for release.

    • toto 15:23 on 17. May 2010 Permalink

      NS_BLOCK_ASSERTIONS=1 Seems to be default in XCode 3.2

  • Ullrich 18:01 on 23. November 2009 Permalink | Reply
    Tags: Debugging,   

    Optimize your Autorelease pools with the following environment variables

    Default: 0
    If set to X, autorelease pools will print a message if more than X objects accumulate in the pool

    Default: 0
    If set to Y, a message is logged for every Y objects that accumulate in the pool beyond the high-water mark (X)

Compose new post
Next post/Next comment
Previous post/Previous comment
Show/Hide comments
Go to top
Go to login
Show/Hide help
shift + esc