1

I am developing an app in which I have to track crashes. There is a restriction that I can't use any third party source like Twitter's Fabric framework to handle crash logging.

Currently I am only able to get the reason for crash. I am not able to get the exact point of crash.

What I am doing:

In my app delegate's didFinishLaunchingWithOptions method I had made my own exception handler:

    NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler); 

uncaughtExceptionHandler ----

void uncaughtExceptionHandler(NSException *exception) {
    NSLog(@"CRASH: %@", exception);
    NSLog(@"callStackSymbols: %@", [exception callStackSymbols]);
    NSLog(@"callStackReturnAddresses: %@", [exception callStackReturnAddresses]);
    NSLog(@"reason: %@", [exception reason]);
    NSLog(@"name: %@", [exception name]);    
    NSLog(@"%s %d %s %s", __FILE__, __LINE__, __PRETTY_FUNCTION__, __FUNCTION__);
// Internal error reporting
}

I crashed my app in viewDidLoad method using this:

   NSArray *myary;

   myary = [NSArray arrayWithObjects:@"sad", nil];

   NSString *str =  [myary objectAtIndex:22];

Here is my Stack Trace.

Is their any way to achieve what I want?

I tried following these solutions from SO but they don't give me any lead:

Solution 1

Solution 2

Community
  • 1
  • 1
Rahul
  • 5,594
  • 7
  • 38
  • 92
  • your last NSLOg statement have the class name along with the method name right ? What else do you need ? – Teja Nandamuri Jun 23 '16 at 18:01
  • @TejaNandamuri that's the appDelegates method line number..but I want to crash point line number and method name – Rahul Jun 23 '16 at 18:03
  • you do get the method name, so what you need is the exact line number right ? – Teja Nandamuri Jun 23 '16 at 18:04
  • @TejaNandamuri I want the line number for `[myary objectAtIndex:22];` this...but the line number that I am getting is of this ` NSLog(@"%s %d %s %s", __FILE__, __LINE__, __PRETTY_FUNCTION__, __FUNCTION__);` – Rahul Jun 23 '16 at 18:31
  • yeah seems like it is not possible as the line number is not included in the crash log.Even crash tools like crashlytics or fabric can't get the number. They only get the method line number. – Teja Nandamuri Jun 23 '16 at 18:46
  • Services such as Crashlytics get the line number by parsing the `dsym` files that you upload (usually using a build phase script). The `dsym` has a mapping between code chunks and the file and line number from which they were compiled. – Avi Jun 23 '16 at 19:14
  • I understand your concern when you say that use of third party is restricted since you don't want the data to be shared with them. However you can use a open source crash tracker like https://plcrashreporter.org/ or maybe take a dip in their code to check – Ganesh Somani Jun 24 '16 at 02:13

0 Answers0