PLCrashReporter - How to symbolicate crash data in-process?

ぃ、小莉子 提交于 2020-01-03 14:26:20

问题


Is there a way to symbolicate the crash reports after we get the crash data?

Currently, this is what I'm doing in handleCrashReport method;

PLCrashReportTextFormat textFormat = PLCrashReportTextFormatiOS;

    /* Decode data */

    PLCrashReport *crashLog = [[PLCrashReport alloc] initWithData: data error: &error];
    if (crashLog == nil) {
        NSLog(@"Could not decode crash file :%@",  [[error localizedDescription] UTF8String]);
    } else {
        NSString* report = [PLCrashReportTextFormatter stringValueForCrashReport: crashLog withTextFormat: textFormat];
        NSLog(@"Crash log \n\n\n%@ \n\n\n", report);

        NSString *outputPath = [documentsDirectory stringByAppendingPathComponent: @"app.crash"];
        if (![report writeToFile:outputPath atomically:YES encoding:NSUTF8StringEncoding error:nil]) {
            NSLog(@"Failed to write crash report");
        } else {
            NSLog(@"Saved crash report to: %@", outputPath);
        }

    }

When i print this out on console; I get this.

Application Specific Information:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'This should crash the application.'

Thread 0 Crashed:
0   libsystem_kernel.dylib              0x93a0d9c6 0x939f5000 + 100806
1   libsystem_c.dylib                   0x9c5aabdd 0x9c55b000 + 326621
2   shell                               0x00082a2c 0x1000 + 530988
3   CoreFoundation                      0x0263d0fc 0x253f000 + 1040636
4   libobjc.A.dylib                     0x00f8ef0f 0xf89000 + 24335
5   libc++abi.dylib                     0x02a028de 0x29fd000 + 22750
6   libc++abi.dylib                     0x02a02946 0x29fd000 + 22854
7   libc++abi.dylib                     0x02a03b3e 0x29fd000 + 27454
8   libobjc.A.dylib                     0x00f8ee15 0xf89000 + 24085
9   CoreFoundation                      0x02573de0 0x253f000 + 216544
10  CoreFoundation                      0x02573c9b 0x253f000 + 216219
11  UIKit                               0x0150ac65 0x1501000 + 40037
12  UIKit                               0x0150c626 0x1501000 + 46630
13  shell                               0x00002fed 0x1000 + 8173
14  shell                               0x00001f95 0x1000 + 3989

Thread 1:
0   libsystem_kernel.dylib              0x93a0e90a 0x939f5000 + 104714
1   libdispatch.dylib                   0x02ad2be1 0x2ad1000 + 7137

Thread 2:
0   libsystem_kernel.dylib              0x93a0bc22 0x939f5000 + 93218
1   libsystem_notify.dylib              0x97cb9cd2 0x97cb8000 + 7378
2   libsystem_notify.dylib              0x97cbdb4b 0x97cb8000 + 23371
3   libsystem_c.dylib                   0x9c5e859b 0x9c55b000 + 578971
4   CoreFoundation                      0x025e61c3 0x253f000 + 684483
5   CoreFoundation                      0x025e5d83 0x253f000 + 683395
6   Foundation                          0x00caab53 0xc34000 + 486227
7   Foundation                          0x00caaac5 0xc34000 + 486085
8   shell                               0x003ddbf8 0x1000 + 4049912
9   libdispatch.dylib                   0x02ad2330 0x2ad1000 + 4912
10  libdispatch.dylib                   0x02ad3f0c 0x2ad1000 + 12044
11  libdispatch.dylib                   0x02ad3cb4 0x2ad1000 + 11444
12  libdispatch.dylib                   0x02ad3402 0x2ad1000 + 9218
13  libsystem_c.dylib                   0x9c5b9b24 0x9c55b000 + 387876
14  libsystem_c.dylib                   0x9c5bb6fe 0x9c55b000 + 395006

I want to symbolicate in-process If this is possible. Any ideas?

Thanks much in advance.


回答1:


You can symbolicate the crash report in process, this requires three things:

  1. You should do that on then next app start only.
  2. You need the app symbols to be part of the binary, which increases its size by 30-50%
  3. You will not get line numbers.

The latest version of PLCrashReporter is able to do that, but I would not recommend it and rather symbolicate it using the dSYM because it is way more helpful.




回答2:


PLCrashReporter provides a configuration option to symbolicate on the device

  PLCrashReporterConfig *config = [[PLCrashReporterConfig alloc] initWithSignalHandlerType: PLCrashReporterSignalHandlerTypeBSD symbolicationStrategy: PLCrashReporterSymbolicationStrategyAll];
PLCrashReporter *crashReporter = [[PLCrashReporter alloc] initWithConfiguration:config];

However, there are 2 reasons why symbolication with DSYM is better:

  • the documentation recommends not to use this feature for a release version
  • The symbolication is not as good as the one using DSYM and the debug symbols of the system frameworks. You will get a lot of '' lines.

To symbolicate a crash report on your development machine you can do this (Make sure that the original binary and the dsym file are in the same directory and that you have the debug symbols for the iOS version mentioned in the crash report):

/Applications/Xcode.app/Contents/SharedFrameworks/DTDeviceKitBase.framework/Versions/A/Resources/symbolicatecrash MyCrash.crash


来源:https://stackoverflow.com/questions/11814155/plcrashreporter-how-to-symbolicate-crash-data-in-process

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!