|
17 | 17 | #include <stdlib.h> |
18 | 18 | #include <string.h> |
19 | 19 |
|
| 20 | +#import "FIRCLSFileManager.h" |
| 21 | +#import "FIRCLSInstallIdentifierModel.h" |
| 22 | +#import "FIRCLSInternalReport.h" |
| 23 | +#import "FIRCLSSettings.h" |
| 24 | + |
20 | 25 | #include "FIRCLSApplication.h" |
21 | 26 | #include "FIRCLSCrashedMarkerFile.h" |
22 | 27 | #include "FIRCLSDefines.h" |
23 | 28 | #include "FIRCLSFeatures.h" |
24 | 29 | #include "FIRCLSGlobals.h" |
25 | | -#include "FIRCLSInternalReport.h" |
26 | 30 | #include "FIRCLSProcess.h" |
27 | 31 | #include "FIRCLSUtility.h" |
28 | 32 |
|
|
45 | 49 | static const char* FIRCLSContextAppendToRoot(NSString* root, NSString* component); |
46 | 50 | static void FIRCLSContextAllocate(FIRCLSContext* context); |
47 | 51 |
|
48 | | -bool FIRCLSContextInitialize(const FIRCLSContextInitData* initData) { |
| 52 | +FIRCLSContextInitData FIRCLSContextBuildInitData(FIRCLSInternalReport* report, |
| 53 | + FIRCLSSettings* settings, |
| 54 | + FIRCLSInstallIdentifierModel* installIDModel, |
| 55 | + FIRCLSFileManager* fileManager) { |
| 56 | + // Because we need to start the crash reporter right away, |
| 57 | + // it starts up either with default settings, or cached settings |
| 58 | + // from the last time they were fetched |
| 59 | + |
| 60 | + FIRCLSContextInitData initData; |
| 61 | + |
| 62 | + memset(&initData, 0, sizeof(FIRCLSContextInitData)); |
| 63 | + |
| 64 | + initData.customBundleId = nil; |
| 65 | + initData.installId = [installIDModel.installID UTF8String]; |
| 66 | + initData.sessionId = [[report identifier] UTF8String]; |
| 67 | + initData.rootPath = [[report path] UTF8String]; |
| 68 | + initData.previouslyCrashedFileRootPath = [[fileManager rootPath] UTF8String]; |
| 69 | + initData.errorsEnabled = [settings errorReportingEnabled]; |
| 70 | + initData.customExceptionsEnabled = [settings customExceptionsEnabled]; |
| 71 | + initData.maxCustomExceptions = [settings maxCustomExceptions]; |
| 72 | + initData.maxErrorLogSize = [settings errorLogBufferSize]; |
| 73 | + initData.maxLogSize = [settings logBufferSize]; |
| 74 | + initData.maxKeyValues = [settings maxCustomKeys]; |
| 75 | + |
| 76 | + // If this is set, then we could attempt to do a synchronous submission for certain kinds of |
| 77 | + // events (exceptions). This is a very cool feature, but adds complexity to the backend. For now, |
| 78 | + // we're going to leave this disabled. It does work in the exception case, but will ultimtely |
| 79 | + // result in the following crash to be discared. Usually that crash isn't interesting. But, if it |
| 80 | + // was, we'd never have a chance to see it. |
| 81 | + initData.delegate = nil; |
| 82 | + |
| 83 | +#if CLS_MACH_EXCEPTION_SUPPORTED |
| 84 | + __block exception_mask_t mask = 0; |
| 85 | + |
| 86 | + // TODO(b/141241224) This if statement was hardcoded to no, so this block was never run |
| 87 | + // FIRCLSSignalEnumerateHandledSignals(^(int idx, int signal) { |
| 88 | + // if ([self.delegate ensureDeliveryOfUnixSignal:signal]) { |
| 89 | + // mask |= FIRCLSMachExceptionMaskForSignal(signal); |
| 90 | + // } |
| 91 | + // }); |
| 92 | + |
| 93 | + initData.machExceptionMask = mask; |
| 94 | +#endif |
| 95 | + |
| 96 | + return initData; |
| 97 | +} |
| 98 | + |
| 99 | +bool FIRCLSContextInitialize(FIRCLSInternalReport* report, |
| 100 | + FIRCLSSettings* settings, |
| 101 | + FIRCLSInstallIdentifierModel* installIDModel, |
| 102 | + FIRCLSFileManager* fileManager) { |
| 103 | + FIRCLSContextInitData initDataObj = |
| 104 | + FIRCLSContextBuildInitData(report, settings, installIDModel, fileManager); |
| 105 | + FIRCLSContextInitData* initData = &initDataObj; |
| 106 | + |
49 | 107 | if (!initData) { |
50 | 108 | return false; |
51 | 109 | } |
@@ -197,7 +255,14 @@ bool FIRCLSContextInitialize(const FIRCLSContextInitData* initData) { |
197 | 255 | return true; |
198 | 256 | } |
199 | 257 |
|
200 | | -void FIRCLSContextUpdateMetadata(const FIRCLSContextInitData* initData) { |
| 258 | +void FIRCLSContextUpdateMetadata(FIRCLSInternalReport* report, |
| 259 | + FIRCLSSettings* settings, |
| 260 | + FIRCLSInstallIdentifierModel* installIDModel, |
| 261 | + FIRCLSFileManager* fileManager) { |
| 262 | + FIRCLSContextInitData initDataObj = |
| 263 | + FIRCLSContextBuildInitData(report, settings, installIDModel, fileManager); |
| 264 | + FIRCLSContextInitData* initData = &initDataObj; |
| 265 | + |
201 | 266 | NSString* rootPath = [NSString stringWithUTF8String:initData->rootPath]; |
202 | 267 |
|
203 | 268 | const char* metaDataPath = |
|
0 commit comments