1 |
efrain |
1 |
// Copyright 2019 Google
|
|
|
2 |
//
|
|
|
3 |
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
4 |
// you may not use this file except in compliance with the License.
|
|
|
5 |
// You may obtain a copy of the License at
|
|
|
6 |
//
|
|
|
7 |
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
8 |
//
|
|
|
9 |
// Unless required by applicable law or agreed to in writing, software
|
|
|
10 |
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
12 |
// See the License for the specific language governing permissions and
|
|
|
13 |
// limitations under the License.
|
|
|
14 |
|
|
|
15 |
#pragma once
|
|
|
16 |
|
|
|
17 |
#include "Crashlytics/Crashlytics/Components/FIRCLSBinaryImage.h"
|
|
|
18 |
#include "Crashlytics/Crashlytics/Components/FIRCLSHost.h"
|
|
|
19 |
#include "Crashlytics/Crashlytics/Components/FIRCLSUserLogging.h"
|
|
|
20 |
#include "Crashlytics/Crashlytics/Handlers/FIRCLSException.h"
|
|
|
21 |
#include "Crashlytics/Crashlytics/Handlers/FIRCLSMachException.h"
|
|
|
22 |
#include "Crashlytics/Crashlytics/Handlers/FIRCLSSignal.h"
|
|
|
23 |
#include "Crashlytics/Crashlytics/Helpers/FIRCLSAllocate.h"
|
|
|
24 |
#include "Crashlytics/Crashlytics/Helpers/FIRCLSFeatures.h"
|
|
|
25 |
#include "Crashlytics/Crashlytics/Helpers/FIRCLSInternalLogging.h"
|
|
|
26 |
|
|
|
27 |
#include <dispatch/dispatch.h>
|
|
|
28 |
#include <stdbool.h>
|
|
|
29 |
|
|
|
30 |
// The purpose of the crash context is to hold values that absolutely must be read and/or written at
|
|
|
31 |
// crash time. For robustness against memory corruption, they are protected with guard pages.
|
|
|
32 |
// Further, the context is seperated into read-only and read-write sections.
|
|
|
33 |
|
|
|
34 |
__BEGIN_DECLS
|
|
|
35 |
|
|
|
36 |
#ifdef __OBJC__
|
|
|
37 |
@class FIRCLSInternalReport;
|
|
|
38 |
@class FIRCLSSettings;
|
|
|
39 |
@class FIRCLSInstallIdentifierModel;
|
|
|
40 |
@class FIRCLSFileManager;
|
|
|
41 |
#endif
|
|
|
42 |
|
|
|
43 |
typedef struct {
|
|
|
44 |
volatile bool initialized;
|
|
|
45 |
volatile bool debuggerAttached;
|
|
|
46 |
const char* previouslyCrashedFileFullPath;
|
|
|
47 |
const char* logPath;
|
|
|
48 |
// Initial report path represents the report path used to initialized the context;
|
|
|
49 |
// where non-on-demand exceptions and other crashes will be written.
|
|
|
50 |
const char* initialReportPath;
|
|
|
51 |
#if CLS_USE_SIGALTSTACK
|
|
|
52 |
void* signalStack;
|
|
|
53 |
#endif
|
|
|
54 |
#if CLS_MACH_EXCEPTION_SUPPORTED
|
|
|
55 |
void* machStack;
|
|
|
56 |
#endif
|
|
|
57 |
|
|
|
58 |
FIRCLSBinaryImageReadOnlyContext binaryimage;
|
|
|
59 |
FIRCLSExceptionReadOnlyContext exception;
|
|
|
60 |
FIRCLSHostReadOnlyContext host;
|
|
|
61 |
#if CLS_SIGNAL_SUPPORTED
|
|
|
62 |
FIRCLSSignalReadContext signal;
|
|
|
63 |
#endif
|
|
|
64 |
#if CLS_MACH_EXCEPTION_SUPPORTED
|
|
|
65 |
FIRCLSMachExceptionReadContext machException;
|
|
|
66 |
#endif
|
|
|
67 |
FIRCLSUserLoggingReadOnlyContext logging;
|
|
|
68 |
} FIRCLSReadOnlyContext;
|
|
|
69 |
|
|
|
70 |
typedef struct {
|
|
|
71 |
FIRCLSInternalLoggingWritableContext internalLogging;
|
|
|
72 |
volatile bool crashOccurred;
|
|
|
73 |
FIRCLSBinaryImageReadWriteContext binaryImage;
|
|
|
74 |
FIRCLSUserLoggingWritableContext logging;
|
|
|
75 |
FIRCLSExceptionWritableContext exception;
|
|
|
76 |
} FIRCLSReadWriteContext;
|
|
|
77 |
|
|
|
78 |
typedef struct {
|
|
|
79 |
FIRCLSReadOnlyContext* readonly;
|
|
|
80 |
FIRCLSReadWriteContext* writable;
|
|
|
81 |
FIRCLSAllocatorRef allocator;
|
|
|
82 |
} FIRCLSContext;
|
|
|
83 |
|
|
|
84 |
typedef struct {
|
|
|
85 |
const char* customBundleId;
|
|
|
86 |
const char* rootPath;
|
|
|
87 |
const char* previouslyCrashedFileRootPath;
|
|
|
88 |
const char* sessionId;
|
|
|
89 |
const char* betaToken;
|
|
|
90 |
bool errorsEnabled;
|
|
|
91 |
bool customExceptionsEnabled;
|
|
|
92 |
uint32_t maxCustomExceptions;
|
|
|
93 |
uint32_t maxErrorLogSize;
|
|
|
94 |
uint32_t maxLogSize;
|
|
|
95 |
uint32_t maxKeyValues;
|
|
|
96 |
} FIRCLSContextInitData;
|
|
|
97 |
|
|
|
98 |
#ifdef __OBJC__
|
|
|
99 |
bool FIRCLSContextInitialize(FIRCLSInternalReport* report,
|
|
|
100 |
FIRCLSSettings* settings,
|
|
|
101 |
FIRCLSFileManager* fileManager);
|
|
|
102 |
|
|
|
103 |
#endif
|
|
|
104 |
|
|
|
105 |
void FIRCLSContextBaseInit(void);
|
|
|
106 |
void FIRCLSContextBaseDeinit(void);
|
|
|
107 |
|
|
|
108 |
bool FIRCLSContextIsInitialized(void);
|
|
|
109 |
bool FIRCLSContextHasCrashed(void);
|
|
|
110 |
void FIRCLSContextMarkHasCrashed(void);
|
|
|
111 |
bool FIRCLSContextMarkAndCheckIfCrashed(void);
|
|
|
112 |
|
|
|
113 |
__END_DECLS
|