Srinivasa Reddy
Srinivasa Reddy

Reputation: 77

How to get the class and method name which caused the crash?

When app crashes I am getting below stack in my debug console.

(
    0   CoreFoundation                      0x000000010811434b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x0000000107b4821e objc_exception_throw + 48
    2   CoreFoundation                      0x000000010816cbdf -[__NSSingleObjectArrayI objectAtIndex:] + 111
    3   FanPaas                             0x0000000106fa48fa -[ViewController openCrash] + 90
    4   UIKit                               0x0000000109bd3b88 -[UIApplication sendAction:to:from:forEvent:] + 83
    5   UIKit                               0x0000000109d592b2 -[UIControl sendAction:to:forEvent:] + 67
    6   UIKit                               0x0000000109d595cb -[UIControl _sendActionsForEvents:withEvent:] + 444
    7   UIKit                               0x0000000109d584c7 -[UIControl touchesEnded:withEvent:] + 668
    8   UIKit                               0x0000000109c410d5 -[UIWindow _sendTouchesForEvent:] + 2747
    9   UIKit                               0x0000000109c427c3 -[UIWindow sendEvent:] + 4011
    10  UIKit                               0x0000000109befa33 -[UIApplication sendEvent:] + 371
    11  UIKit                               0x000000010a3e1b6d __dispatchPreprocessedEventFromEventQueue + 3248
    12  UIKit                               0x000000010a3da817 __handleEventQueue + 4879
    13  CoreFoundation                      0x00000001080b9311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    14  CoreFoundation                      0x000000010809e59c __CFRunLoopDoSources0 + 556
    15  CoreFoundation                      0x000000010809da86 __CFRunLoopRun + 918
    16  CoreFoundation                      0x000000010809d494 CFRunLoopRunSpecific + 420
    17  GraphicsServices                    0x000000010f82ba6f GSEventRunModal + 161
    18  UIKit                               0x0000000109bd1f34 UIApplicationMain + 159
    19  FanPaas                             0x0000000106fdf66f main + 111
    20  libdyld.dylib                       0x000000010c65868d start + 1
)

so I tried to catch that stack trace using [NSThread callStackSymbols] in NSSetUncaughtExceptionHandler(&HandleException).

(
    0   FanPaas                             0x000000010176f05e +[UncaughtExceptionHandler backtrace] + 46
    1   FanPaas                             0x000000010176fe92 HandleException + 98
    2   CoreFoundation                      0x00000001028f156c __handleUncaughtException + 732
    3   libobjc.A.dylib                     0x00000001022bc496 _ZL15_objc_terminatev + 94
    4   libc++abi.dylib                     0x0000000107382e69 _ZSt11__terminatePFvvE + 8
    5   libc++abi.dylib                     0x0000000107382af4 __cxa_rethrow + 99
    6   libobjc.A.dylib                     0x00000001022bc3b7 objc_exception_rethrow + 40
    7   CoreFoundation                      0x000000010281151b CFRunLoopRunSpecific + 555
    8   GraphicsServices                    0x000000010a6bfa6f GSEventRunModal + 161
    9   UIKit                               0x0000000104345f34 UIApplicationMain + 159
    10  FanPaas                             0x000000010175020f main + 111
    11  libdyld.dylib                       0x00000001074ec68d start + 1
)

Actually [ViewController openCrash] caused crash, but i did not get that in callStackSymbols. But which is showing in debug console.

How to get the class and method name which caused the crash?

Upvotes: 1

Views: 751

Answers (3)

Rahul
Rahul

Reputation: 104

You can do this:

1. Enable exception breakpoint.
2. Your breakpoint will stop on method which causing crash.
3. Add try catch block in that method, in catch block you can print method name and exception.

Upvotes: 0

GeneCode
GeneCode

Reputation: 7588

You can use Fabric Crashlytic by Twitter. It is DAMN GOOD.

ps. I am not affiliated with Twitter.

SEE HERE https://fabric.io/kits/ios/crashlytics

Upvotes: 1

Matloob Hasnain
Matloob Hasnain

Reputation: 1037

enter image description here

Select break point symbol on top then click on + symbol at bottom and then click Exception Break Point.So it would leads you on particular line that cause crash.

Upvotes: 1

Related Questions