From 13a9ebd0044cb7bba525ea74e2fe0ffbd5753080 Mon Sep 17 00:00:00 2001 From: vng Date: Fri, 17 May 2013 02:21:37 +0300 Subject: [PATCH] [iOS] Added NSException logging. --- iphone/Maps/main.mm | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/iphone/Maps/main.mm b/iphone/Maps/main.mm index b6f0909466..64144915ae 100644 --- a/iphone/Maps/main.mm +++ b/iphone/Maps/main.mm @@ -3,10 +3,11 @@ #import #include "../../platform/platform.hpp" + #include "../../base/logging.hpp" -////////////////////////////////////////////////////////////////////////////////// -/// Used to trick iOs and enable multithreading support with non-native pthreads + +/// Used to trick iOs and enable multithreading support with non-native pthreads. @interface Dummy : NSObject - (void) dummyThread: (id) obj; @end @@ -14,12 +15,23 @@ @implementation Dummy - (void) dummyThread: (id) obj {} @end -/////////////////////////////////////////////////////////////////////////////////// + + +/// Used to log NSExceptions. +static void exceptionHandler(NSException * ex) +{ + NSArray *stack = [ex callStackSymbols]; + NSLog(@"%@", ex.name); + NSLog(@"%@", ex.reason); + NSLog(@"Stack trace: %@", stack); +} int main(int argc, char * argv[]) { LOG(LINFO, ("MapsWithMe started, detected CPU cores:", GetPlatform().CpuCores())); + NSSetUncaughtExceptionHandler(&exceptionHandler); + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; Dummy * dummy = [[Dummy alloc] autorelease];