Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PLAT-4707] Record thread information for unhandled JS errors #766

Merged
merged 6 commits into from
Jul 31, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Bugsnag/Client/BugsnagClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,11 @@ - (void)start {
[self.crashSentry install:self.configuration
apiClient:self.errorReportApiClient
onCrash:&BSSerializeDataCrashHandler];
// overridden elsewhere for handled errors, so we can assume that this only
// applies to unhandled errors
BSGThreadSendPolicy sendThreads = self.configuration.sendThreads;
[BSG_KSCrash sharedInstance].threadTracingEnabled = sendThreads == BSGThreadSendPolicyAlways
|| sendThreads == BSGThreadSendPolicyUnhandledOnly;
fractalwrench marked this conversation as resolved.
Show resolved Hide resolved
[self computeDidCrashLastLaunch];
[self setupConnectivityListener];
[self updateAutomaticBreadcrumbDetectionSettings];
Expand Down
3 changes: 1 addition & 2 deletions Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,8 @@

/**
* The methodology used for tracing threads.
* The value will be equal to an enum value from BSGThreadSendPolicy
*/
@property(nonatomic, readwrite, assign) int threadTracingEnabled;
@property(nonatomic, readwrite, assign) BOOL threadTracingEnabled;

/**
* If YES, binary images will be collected for each report.
Expand Down
8 changes: 1 addition & 7 deletions Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.m
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,6 @@ - (id)initWithReportFilesDirectory:(NSString *)reportFilesDirectory {

self.reportWhenDebuggerIsAttached = NO;
self.writeBinaryImagesForUserReported = YES;

// overridden elsewhere for handled errors, so we can assume that this only
// applies to unhandled errors
BSGThreadSendPolicy sendThreads = [Bugsnag configuration].sendThreads;
self.threadTracingEnabled = sendThreads == BSGThreadSendPolicyAlways
|| sendThreads == BSGThreadSendPolicyUnhandledOnly;
}
return self;
}
Expand Down Expand Up @@ -205,7 +199,7 @@ - (void)setReportWhenDebuggerIsAttached:(BOOL)reportWhenDebuggerIsAttached {
bsg_kscrash_setReportWhenDebuggerIsAttached(reportWhenDebuggerIsAttached);
}

- (void)setThreadTracingEnabled:(bool)threadTracingEnabled {
- (void)setThreadTracingEnabled:(BOOL)threadTracingEnabled {
_threadTracingEnabled = threadTracingEnabled;
bsg_kscrash_setThreadTracingEnabled(threadTracingEnabled);
}
Expand Down
4 changes: 3 additions & 1 deletion Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashC.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ void bsg_kscrash_setThreadTracingEnabled(bool threadTracingEnabled) {
}

char *bsg_kscrash_captureThreadTrace(int discardDepth, int frameCount, uintptr_t *callstack, const bool recordAllThreads) {
BSG_KSCrash_Context *context = crashContext();
BSG_KSCrash_Context *globalContext = crashContext();
BSG_KSCrash_Context *context = malloc(sizeof(BSG_KSCrash_Context));
fractalwrench marked this conversation as resolved.
Show resolved Hide resolved
memcpy(context, globalContext, sizeof(BSG_KSCrash_Context));

// populate context with pre-recorded stacktrace/thread info
// for KSCrash to serialize
Expand Down