Skip to content

Commit 7a141fd

Browse files
authored
Code clean-up (#9166)
Removes unused code surrounding mach exception mask and delegate.
1 parent d068ba5 commit 7a141fd

File tree

9 files changed

+21
-74
lines changed

9 files changed

+21
-74
lines changed

Crashlytics/Crashlytics/Components/FIRCLSContext.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ typedef struct {
5151
#if CLS_MACH_EXCEPTION_SUPPORTED
5252
void* machStack;
5353
#endif
54-
void* delegate;
55-
void* callbackDelegate;
5654

5755
FIRCLSBinaryImageReadOnlyContext binaryimage;
5856
FIRCLSExceptionReadOnlyContext exception;
@@ -81,15 +79,11 @@ typedef struct {
8179
} FIRCLSContext;
8280

8381
typedef struct {
84-
void* delegate;
8582
const char* customBundleId;
8683
const char* rootPath;
8784
const char* previouslyCrashedFileRootPath;
8885
const char* sessionId;
8986
const char* betaToken;
90-
#if CLS_MACH_EXCEPTION_SUPPORTED
91-
exception_mask_t machExceptionMask;
92-
#endif
9387
bool errorsEnabled;
9488
bool customExceptionsEnabled;
9589
uint32_t maxCustomExceptions;

Crashlytics/Crashlytics/Components/FIRCLSContext.m

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,6 @@ FIRCLSContextInitData FIRCLSContextBuildInitData(FIRCLSInternalReport* report,
7474
initData.maxKeyValues = [settings maxCustomKeys];
7575
initData.betaToken = "";
7676

77-
// If this is set, then we could attempt to do a synchronous submission for certain kinds of
78-
// events (exceptions). This is a very cool feature, but adds complexity to the backend. For now,
79-
// we're going to leave this disabled. It does work in the exception case, but will ultimtely
80-
// result in the following crash to be discared. Usually that crash isn't interesting. But, if it
81-
// was, we'd never have a chance to see it.
82-
initData.delegate = nil;
83-
84-
#if CLS_MACH_EXCEPTION_SUPPORTED
85-
__block exception_mask_t mask = 0;
86-
87-
// TODO(b/141241224) This if statement was hardcoded to no, so this block was never run
88-
// FIRCLSSignalEnumerateHandledSignals(^(int idx, int signal) {
89-
// if ([self.delegate ensureDeliveryOfUnixSignal:signal]) {
90-
// mask |= FIRCLSMachExceptionMaskForSignal(signal);
91-
// }
92-
// });
93-
94-
initData.machExceptionMask = mask;
95-
#endif
96-
9777
return initData;
9878
}
9979

@@ -126,7 +106,6 @@ bool FIRCLSContextInitialize(FIRCLSInternalReport* report,
126106

127107
// some values that aren't tied to particular subsystem
128108
_firclsContext.readonly->debuggerAttached = FIRCLSProcessDebuggerAttached();
129-
_firclsContext.readonly->delegate = initData->delegate;
130109

131110
dispatch_group_async(group, queue, ^{
132111
FIRCLSHostInitialize(&_firclsContext.readonly->host);
@@ -211,7 +190,7 @@ bool FIRCLSContextInitialize(FIRCLSInternalReport* report,
211190
_firclsContext.readonly->machException.path =
212191
FIRCLSContextAppendToRoot(rootPath, FIRCLSReportMachExceptionFile);
213192

214-
FIRCLSMachExceptionInit(&_firclsContext.readonly->machException, initData->machExceptionMask);
193+
FIRCLSMachExceptionInit(&_firclsContext.readonly->machException);
215194
});
216195
#endif
217196

@@ -222,7 +201,7 @@ bool FIRCLSContextInitialize(FIRCLSInternalReport* report,
222201
initData->customExceptionsEnabled ? initData->maxCustomExceptions : 0;
223202

224203
FIRCLSExceptionInitialize(&_firclsContext.readonly->exception,
225-
&_firclsContext.writable->exception, initData->delegate);
204+
&_firclsContext.writable->exception);
226205
});
227206
} else {
228207
FIRCLSSDKLog("Debugger present - not installing handlers\n");

Crashlytics/Crashlytics/Controllers/FIRCLSReportManager_Private.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,4 @@
2929

3030
@property(nonatomic, strong) FIRCLSLaunchMarkerModel *launchMarker;
3131

32-
- (BOOL)potentiallySubmittableCrashOccurred;
33-
3432
@end

Crashlytics/Crashlytics/Handlers/FIRCLSException.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ typedef struct {
5353
__BEGIN_DECLS
5454

5555
void FIRCLSExceptionInitialize(FIRCLSExceptionReadOnlyContext* roContext,
56-
FIRCLSExceptionWritableContext* rwContext,
57-
void* delegate);
56+
FIRCLSExceptionWritableContext* rwContext);
5857
void FIRCLSExceptionCheckHandlers(void* delegate);
5958

6059
void FIRCLSExceptionRaiseTestObjCException(void) __attribute((noreturn));
@@ -66,8 +65,7 @@ void FIRCLSExceptionRecordNSException(NSException* exception);
6665
void FIRCLSExceptionRecord(FIRCLSExceptionType type,
6766
const char* name,
6867
const char* reason,
69-
NSArray<FIRStackFrame*>* frames,
70-
BOOL attemptDelivery);
68+
NSArray<FIRStackFrame*>* frames);
7169
#endif
7270

7371
__END_DECLS

Crashlytics/Crashlytics/Handlers/FIRCLSException.mm

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@
5757

5858
#pragma mark - API
5959
void FIRCLSExceptionInitialize(FIRCLSExceptionReadOnlyContext *roContext,
60-
FIRCLSExceptionWritableContext *rwContext,
61-
void *delegate) {
60+
FIRCLSExceptionWritableContext *rwContext) {
6261
if (!FIRCLSUnlinkIfExists(roContext->path)) {
6362
FIRCLSSDKLog("Unable to reset the exception file %s\n", strerror(errno));
6463
}
@@ -82,8 +81,7 @@ void FIRCLSExceptionRecordModel(FIRExceptionModel *exceptionModel) {
8281
const char *name = [[exceptionModel.name copy] UTF8String];
8382
const char *reason = [[exceptionModel.reason copy] UTF8String] ?: "";
8483

85-
FIRCLSExceptionRecord(FIRCLSExceptionTypeCustom, name, reason, [exceptionModel.stackTrace copy],
86-
NO);
84+
FIRCLSExceptionRecord(FIRCLSExceptionTypeCustom, name, reason, [exceptionModel.stackTrace copy]);
8785
}
8886

8987
void FIRCLSExceptionRecordNSException(NSException *exception) {
@@ -107,7 +105,7 @@ void FIRCLSExceptionRecordNSException(NSException *exception) {
107105
}
108106

109107
FIRCLSExceptionRecord(FIRCLSExceptionTypeObjectiveC, [name UTF8String], [reason UTF8String],
110-
frames, YES);
108+
frames);
111109
}
112110

113111
static void FIRCLSExceptionRecordFrame(FIRCLSFile *file, FIRStackFrame *frame) {
@@ -189,15 +187,14 @@ void FIRCLSExceptionWrite(FIRCLSFile *file,
189187
void FIRCLSExceptionRecord(FIRCLSExceptionType type,
190188
const char *name,
191189
const char *reason,
192-
NSArray<FIRStackFrame *> *frames,
193-
BOOL attemptDelivery) {
190+
NSArray<FIRStackFrame *> *frames) {
194191
if (!FIRCLSContextIsInitialized()) {
195192
return;
196193
}
197194

198195
bool native = FIRCLSExceptionIsNative(type);
199196

200-
FIRCLSSDKLog("Recording an exception structure (%d, %d)\n", attemptDelivery, native);
197+
FIRCLSSDKLog("Recording an exception structure (%d)\n", native);
201198

202199
// exceptions can happen on multiple threads at the same time
203200
if (native) {
@@ -218,9 +215,6 @@ void FIRCLSExceptionRecord(FIRCLSExceptionType type,
218215
FIRCLSFileClose(&file);
219216

220217
// disallow immediate delivery for non-native exceptions
221-
if (attemptDelivery) {
222-
FIRCLSHandlerAttemptImmediateDelivery();
223-
}
224218
});
225219
} else {
226220
FIRCLSUserLoggingWriteAndCheckABFiles(
@@ -278,21 +272,19 @@ static void FIRCLSCatchAndRecordActiveException(std::type_info *typeInfo) {
278272
#endif
279273
}
280274
} catch (const char *exc) {
281-
FIRCLSExceptionRecord(FIRCLSExceptionTypeCpp, "const char *", exc, nil, YES);
275+
FIRCLSExceptionRecord(FIRCLSExceptionTypeCpp, "const char *", exc, nil);
282276
} catch (const std::string &exc) {
283-
FIRCLSExceptionRecord(FIRCLSExceptionTypeCpp, "std::string", exc.c_str(), nil, YES);
277+
FIRCLSExceptionRecord(FIRCLSExceptionTypeCpp, "std::string", exc.c_str(), nil);
284278
} catch (const std::exception &exc) {
285-
FIRCLSExceptionRecord(FIRCLSExceptionTypeCpp, FIRCLSExceptionDemangle(name), exc.what(), nil,
286-
YES);
279+
FIRCLSExceptionRecord(FIRCLSExceptionTypeCpp, FIRCLSExceptionDemangle(name), exc.what(), nil);
287280
} catch (const std::exception *exc) {
288-
FIRCLSExceptionRecord(FIRCLSExceptionTypeCpp, FIRCLSExceptionDemangle(name), exc->what(), nil,
289-
YES);
281+
FIRCLSExceptionRecord(FIRCLSExceptionTypeCpp, FIRCLSExceptionDemangle(name), exc->what(), nil);
290282
} catch (const std::bad_alloc &exc) {
291283
// it is especially important to avoid demangling in this case, because the expetation at this
292284
// point is that all allocations could fail
293-
FIRCLSExceptionRecord(FIRCLSExceptionTypeCpp, "std::bad_alloc", exc.what(), nil, YES);
285+
FIRCLSExceptionRecord(FIRCLSExceptionTypeCpp, "std::bad_alloc", exc.what(), nil);
294286
} catch (...) {
295-
FIRCLSExceptionRecord(FIRCLSExceptionTypeCpp, FIRCLSExceptionDemangle(name), "", nil, YES);
287+
FIRCLSExceptionRecord(FIRCLSExceptionTypeCpp, FIRCLSExceptionDemangle(name), "", nil);
296288
}
297289
}
298290

Crashlytics/Crashlytics/Handlers/FIRCLSHandler.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,5 @@
2121
__BEGIN_DECLS
2222

2323
void FIRCLSHandler(FIRCLSFile* file, thread_t crashedThread, void* uapVoid);
24-
void FIRCLSHandlerAttemptImmediateDelivery(void);
2524

2625
__END_DECLS

Crashlytics/Crashlytics/Handlers/FIRCLSHandler.m

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,3 @@ void FIRCLSHandler(FIRCLSFile* file, thread_t crashedThread, void* uapVoid) {
4747

4848
FIRCLSProcessResumeAllOtherThreads(&process);
4949
}
50-
51-
void FIRCLSHandlerAttemptImmediateDelivery(void) {
52-
// now, attempt to relay the event to the delegate
53-
FIRCLSReportManager* manager = (__bridge id)_firclsContext.readonly->delegate;
54-
55-
if ([manager respondsToSelector:@selector(potentiallySubmittableCrashOccurred)]) {
56-
[manager potentiallySubmittableCrashOccurred];
57-
}
58-
}

Crashlytics/Crashlytics/Handlers/FIRCLSMachException.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include <unistd.h>
3131

3232
#pragma mark Prototypes
33-
static exception_mask_t FIRCLSMachExceptionMask(void);
3433
static void* FIRCLSMachExceptionServer(void* argument);
3534
static bool FIRCLSMachExceptionThreadStart(FIRCLSMachExceptionReadContext* context);
3635
static bool FIRCLSMachExceptionReadMessage(FIRCLSMachExceptionReadContext* context,
@@ -40,20 +39,19 @@ static kern_return_t FIRCLSMachExceptionDispatchMessage(FIRCLSMachExceptionReadC
4039
static bool FIRCLSMachExceptionReply(FIRCLSMachExceptionReadContext* context,
4140
MachExceptionMessage* message,
4241
kern_return_t result);
43-
static bool FIRCLSMachExceptionRegister(FIRCLSMachExceptionReadContext* context,
44-
exception_mask_t ignoreMask);
42+
static bool FIRCLSMachExceptionRegister(FIRCLSMachExceptionReadContext* context);
4543
static bool FIRCLSMachExceptionUnregister(FIRCLSMachExceptionOriginalPorts* originalPorts,
4644
exception_mask_t mask);
4745
static bool FIRCLSMachExceptionRecord(FIRCLSMachExceptionReadContext* context,
4846
MachExceptionMessage* message);
4947

5048
#pragma mark - Initialization
51-
void FIRCLSMachExceptionInit(FIRCLSMachExceptionReadContext* context, exception_mask_t ignoreMask) {
49+
void FIRCLSMachExceptionInit(FIRCLSMachExceptionReadContext* context) {
5250
if (!FIRCLSUnlinkIfExists(context->path)) {
5351
FIRCLSSDKLog("Unable to reset the mach exception file %s\n", strerror(errno));
5452
}
5553

56-
if (!FIRCLSMachExceptionRegister(context, ignoreMask)) {
54+
if (!FIRCLSMachExceptionRegister(context)) {
5755
FIRCLSSDKLog("Unable to register mach exception handler\n");
5856
return;
5957
}
@@ -270,8 +268,7 @@ static bool FIRCLSMachExceptionReply(FIRCLSMachExceptionReadContext* context,
270268
}
271269

272270
#pragma mark - Registration
273-
static bool FIRCLSMachExceptionRegister(FIRCLSMachExceptionReadContext* context,
274-
exception_mask_t ignoreMask) {
271+
static bool FIRCLSMachExceptionRegister(FIRCLSMachExceptionReadContext* context) {
275272
mach_port_t task = mach_task_self();
276273

277274
kern_return_t kr = mach_port_allocate(task, MACH_PORT_RIGHT_RECEIVE, &context->port);
@@ -291,7 +288,7 @@ static bool FIRCLSMachExceptionRegister(FIRCLSMachExceptionReadContext* context,
291288
// but clear out any that are in our ignore list. We do this by ANDing with the bitwise
292289
// negation. Because we are only clearing bits, there's no way to set an incorrect mask
293290
// using ignoreMask.
294-
context->mask = FIRCLSMachExceptionMask() & ~ignoreMask;
291+
context->mask = FIRCLSMachExceptionMask();
295292

296293
// ORing with MACH_EXCEPTION_CODES will produce 64-bit exception data
297294
kr = task_swap_exception_ports(task, context->mask, context->port,

Crashlytics/Crashlytics/Handlers/FIRCLSMachException.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ typedef struct {
6666
} FIRCLSMachExceptionReadContext;
6767

6868
#pragma mark - API
69-
void FIRCLSMachExceptionInit(FIRCLSMachExceptionReadContext* context, exception_mask_t ignoreMask);
70-
exception_mask_t FIRCLSMachExceptionMaskForSignal(int signal);
69+
void FIRCLSMachExceptionInit(FIRCLSMachExceptionReadContext* context);
7170

7271
void FIRCLSMachExceptionCheckHandlers(void);
7372

0 commit comments

Comments
 (0)