Objective C - getting line number or full stack trace from debugger error?

后端 未结 2 676
再見小時候
再見小時候 2020-12-02 09:24

Is it possible to get a line number for the source code (or anything that helps debug where the problem is) from the debugger, that shows where the problem is originating?

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-02 09:55

    You should also consider using the NSSetUncaughtExceptionHandler. (You can save the crash log to the disk, check next startup if a new crash log was saved, attach it to an email, etc.)

    put this into your didFinishLaunchingWithOptions method:

    NSSetUncaughtExceptionHandler(&exceptionHandler);
    

    and implement your exception handler:

    void exceptionHandler(NSException *exception)
    {        
        NSLog(@"%@",[exception name]);
        NSLog(@"%@",[exception reason]);
        NSLog(@"%@",[exception userInfo]);
        NSLog(@"%@",[exception callStackSymbols]);
        NSLog(@"%@",[exception callStackReturnAddresses]);
    }
    

提交回复
热议问题