Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print the exception automatically in xcode?

Ref: Xcode/LLDB: How to get information about an exception that was just thrown?

So I can get the exception by typing po *(id *)($ebp + 8) in debugger console, and there is an option in the breakpoint to print something when the breakpoint is met, but that option can only print the address of the object but not the description of it. The option about debugger command even print nothing by po.

Is there any setting to print the description of the exception automatically?

like image 876
Kay Chan Avatar asked Feb 15 '12 02:02

Kay Chan


1 Answers

I use such solution to print issues in debug builds and run:

void uncaughtExceptionHandler(NSException *exception)
{
    NSLog(@"CRASH: %@", exception);
    NSLog(@"Stack Trace: %@", [exception callStackSymbols]);
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#if DEBUG
    NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
#endif
    return YES;
}
like image 110
Vitalii Gozhenko Avatar answered Oct 05 '22 03:10

Vitalii Gozhenko