Skip to content

Commit

Permalink
ref: Remove unused user crash monitor (#2448)
Browse files Browse the repository at this point in the history
The SentryCrashMonitor user is unused code and can be removed. Before SDK version 5.0.0,
the SDK exposed this API, but it is unused ever since.
  • Loading branch information
philipphofmann authored Nov 28, 2022
1 parent ff99713 commit 3936dd2
Show file tree
Hide file tree
Showing 14 changed files with 10 additions and 307 deletions.
8 changes: 0 additions & 8 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@
63FE70AD20DA4C1000CDBAE8 /* SentryCrashCString.m in Sources */ = {isa = PBXBuildFile; fileRef = 63FE6FD920DA4C1000CDBAE8 /* SentryCrashCString.m */; };
63FE70CB20DA4C1000CDBAE8 /* SentryCrashReportFixer.c in Sources */ = {isa = PBXBuildFile; fileRef = 63FE6FEA20DA4C1000CDBAE8 /* SentryCrashReportFixer.c */; };
63FE70CD20DA4C1000CDBAE8 /* SentryCrashDoctor.h in Headers */ = {isa = PBXBuildFile; fileRef = 63FE6FEB20DA4C1000CDBAE8 /* SentryCrashDoctor.h */; };
63FE70CF20DA4C1000CDBAE8 /* SentryCrashMonitor_User.h in Headers */ = {isa = PBXBuildFile; fileRef = 63FE6FED20DA4C1000CDBAE8 /* SentryCrashMonitor_User.h */; };
63FE70D120DA4C1000CDBAE8 /* SentryCrashMonitorContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 63FE6FEE20DA4C1000CDBAE8 /* SentryCrashMonitorContext.h */; };
63FE70D320DA4C1000CDBAE8 /* SentryCrashMonitor_AppState.c in Sources */ = {isa = PBXBuildFile; fileRef = 63FE6FEF20DA4C1000CDBAE8 /* SentryCrashMonitor_AppState.c */; };
63FE70D520DA4C1000CDBAE8 /* SentryCrashMonitor_NSException.m in Sources */ = {isa = PBXBuildFile; fileRef = 63FE6FF020DA4C1000CDBAE8 /* SentryCrashMonitor_NSException.m */; };
Expand All @@ -178,7 +177,6 @@
63FE70E320DA4C1000CDBAE8 /* SentryCrashMonitor_Zombie.c in Sources */ = {isa = PBXBuildFile; fileRef = 63FE6FF720DA4C1000CDBAE8 /* SentryCrashMonitor_Zombie.c */; };
63FE70E520DA4C1000CDBAE8 /* SentryCrashMonitor_CPPException.h in Headers */ = {isa = PBXBuildFile; fileRef = 63FE6FF820DA4C1000CDBAE8 /* SentryCrashMonitor_CPPException.h */; };
63FE70E720DA4C1000CDBAE8 /* SentryCrashMonitor.c in Sources */ = {isa = PBXBuildFile; fileRef = 63FE6FF920DA4C1000CDBAE8 /* SentryCrashMonitor.c */; };
63FE70E920DA4C1000CDBAE8 /* SentryCrashMonitor_User.c in Sources */ = {isa = PBXBuildFile; fileRef = 63FE6FFA20DA4C1000CDBAE8 /* SentryCrashMonitor_User.c */; };
63FE70EB20DA4C1000CDBAE8 /* SentryCrashMonitor_MachException.h in Headers */ = {isa = PBXBuildFile; fileRef = 63FE6FFB20DA4C1000CDBAE8 /* SentryCrashMonitor_MachException.h */; };
63FE70ED20DA4C1000CDBAE8 /* SentryCrashMonitor_NSException.h in Headers */ = {isa = PBXBuildFile; fileRef = 63FE6FFC20DA4C1000CDBAE8 /* SentryCrashMonitor_NSException.h */; };
63FE70EF20DA4C1000CDBAE8 /* SentryCrashMonitor_AppState.h in Headers */ = {isa = PBXBuildFile; fileRef = 63FE6FFD20DA4C1000CDBAE8 /* SentryCrashMonitor_AppState.h */; };
Expand Down Expand Up @@ -924,7 +922,6 @@
63FE6FD920DA4C1000CDBAE8 /* SentryCrashCString.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentryCrashCString.m; sourceTree = "<group>"; };
63FE6FEA20DA4C1000CDBAE8 /* SentryCrashReportFixer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SentryCrashReportFixer.c; sourceTree = "<group>"; };
63FE6FEB20DA4C1000CDBAE8 /* SentryCrashDoctor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SentryCrashDoctor.h; sourceTree = "<group>"; };
63FE6FED20DA4C1000CDBAE8 /* SentryCrashMonitor_User.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SentryCrashMonitor_User.h; sourceTree = "<group>"; };
63FE6FEE20DA4C1000CDBAE8 /* SentryCrashMonitorContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SentryCrashMonitorContext.h; sourceTree = "<group>"; };
63FE6FEF20DA4C1000CDBAE8 /* SentryCrashMonitor_AppState.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SentryCrashMonitor_AppState.c; sourceTree = "<group>"; };
63FE6FF020DA4C1000CDBAE8 /* SentryCrashMonitor_NSException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentryCrashMonitor_NSException.m; sourceTree = "<group>"; };
Expand All @@ -936,7 +933,6 @@
63FE6FF720DA4C1000CDBAE8 /* SentryCrashMonitor_Zombie.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SentryCrashMonitor_Zombie.c; sourceTree = "<group>"; };
63FE6FF820DA4C1000CDBAE8 /* SentryCrashMonitor_CPPException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SentryCrashMonitor_CPPException.h; sourceTree = "<group>"; };
63FE6FF920DA4C1000CDBAE8 /* SentryCrashMonitor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SentryCrashMonitor.c; sourceTree = "<group>"; };
63FE6FFA20DA4C1000CDBAE8 /* SentryCrashMonitor_User.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SentryCrashMonitor_User.c; sourceTree = "<group>"; };
63FE6FFB20DA4C1000CDBAE8 /* SentryCrashMonitor_MachException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SentryCrashMonitor_MachException.h; sourceTree = "<group>"; };
63FE6FFC20DA4C1000CDBAE8 /* SentryCrashMonitor_NSException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SentryCrashMonitor_NSException.h; sourceTree = "<group>"; };
63FE6FFD20DA4C1000CDBAE8 /* SentryCrashMonitor_AppState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SentryCrashMonitor_AppState.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2144,8 +2140,6 @@
63FE6FF420DA4C1000CDBAE8 /* SentryCrashMonitor_Signal.h */,
63FE700020DA4C1000CDBAE8 /* SentryCrashMonitor_System.h */,
63FE6FF320DA4C1000CDBAE8 /* SentryCrashMonitor_System.m */,
63FE6FFA20DA4C1000CDBAE8 /* SentryCrashMonitor_User.c */,
63FE6FED20DA4C1000CDBAE8 /* SentryCrashMonitor_User.h */,
63FE6FF720DA4C1000CDBAE8 /* SentryCrashMonitor_Zombie.c */,
63FE700320DA4C1000CDBAE8 /* SentryCrashMonitor_Zombie.h */,
63FE6FF920DA4C1000CDBAE8 /* SentryCrashMonitor.c */,
Expand Down Expand Up @@ -3075,7 +3069,6 @@
63AA76991EB9C1C200D153DE /* SentryDefines.h in Headers */,
0A4EDEA928D3461B00FA67CB /* SentryPerformanceTracker+Private.h in Headers */,
0A8F0A392886CC70000B15F6 /* SentryPermissionsObserver.h in Headers */,
63FE70CF20DA4C1000CDBAE8 /* SentryCrashMonitor_User.h in Headers */,
7B2A70DB27D607CF008B0D15 /* SentryThreadWrapper.h in Headers */,
8EAE980B261E9F530073B6B3 /* SentryPerformanceTracker.h in Headers */,
63FE718520DA4C1100CDBAE8 /* SentryCrashC.h in Headers */,
Expand Down Expand Up @@ -3616,7 +3609,6 @@
63FE714520DA4C1100CDBAE8 /* SentryCrashObjC.c in Sources */,
63FE710520DA4C1000CDBAE8 /* SentryCrashLogger.c in Sources */,
0A2D8D5B289815C0008720F6 /* SentryBaseIntegration.m in Sources */,
63FE70E920DA4C1000CDBAE8 /* SentryCrashMonitor_User.c in Sources */,
0ACBA10128A6406400D711F7 /* UIView+Sentry.m in Sources */,
639FCF991EBC7B9700778193 /* SentryEvent.m in Sources */,
632F43521F581D5400A18A36 /* SentryCrashExceptionApplication.m in Sources */,
Expand Down
15 changes: 3 additions & 12 deletions Sources/SentryCrash/Recording/Monitors/SentryCrashMonitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "SentryCrashMonitor_NSException.h"
#include "SentryCrashMonitor_Signal.h"
#include "SentryCrashMonitor_System.h"
#include "SentryCrashMonitor_User.h"
#include "SentryCrashMonitor_Zombie.h"
#include "SentryCrashSystemCapabilities.h"
#include "SentryCrashThread.h"
Expand Down Expand Up @@ -81,10 +80,6 @@ static Monitor g_monitors[] = {
.monitorType = SentryCrashMonitorTypeCPPException,
.getAPI = sentrycrashcm_cppexception_getAPI,
},
{
.monitorType = SentryCrashMonitorTypeUserReported,
.getAPI = sentrycrashcm_user_getAPI,
},
{
.monitorType = SentryCrashMonitorTypeSystem,
.getAPI = sentrycrashcm_system_getAPI,
Expand Down Expand Up @@ -235,12 +230,8 @@ sentrycrashcm_handleException(struct SentryCrash_MonitorContext *context)

g_onExceptionEvent(context);

if (context->currentSnapshotUserReported) {
g_handlingFatalException = false;
} else {
if (g_handlingFatalException && !g_crashedDuringExceptionHandling) {
SentryCrashLOG_DEBUG("Exception is fatal. Restoring original handlers.");
sentrycrashcm_setActiveMonitors(SentryCrashMonitorTypeNone);
}
if (g_handlingFatalException && !g_crashedDuringExceptionHandling) {
SentryCrashLOG_DEBUG("Exception is fatal. Restoring original handlers.");
sentrycrashcm_setActiveMonitors(SentryCrashMonitorTypeNone);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ extern "C" {
typedef struct SentryCrash_MonitorContext {
/** Unique identifier for this event. */
const char *eventID;
/**
If true, so reported user exception will have the current snapshot.
*/
bool currentSnapshotUserReported;

/** If true, the environment has crashed hard, and only async-safe
* functions should be used.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ static const struct {
MONITORTYPE(SentryCrashMonitorTypeSignal),
MONITORTYPE(SentryCrashMonitorTypeCPPException),
MONITORTYPE(SentryCrashMonitorTypeNSException),
MONITORTYPE(SentryCrashMonitorTypeUserReported),
MONITORTYPE(SentryCrashMonitorTypeSystem),
MONITORTYPE(SentryCrashMonitorTypeApplicationState),
MONITORTYPE(SentryCrashMonitorTypeZombie),
Expand Down
14 changes: 2 additions & 12 deletions Sources/SentryCrash/Recording/Monitors/SentryCrashMonitorType.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ extern "C" {
* - Fatal signal
* - Uncaught C++ exception
* - Uncaught Objective-C NSException
* - User reported custom exception
*/
typedef enum {
/* Captures and reports Mach exceptions. */
Expand All @@ -51,9 +50,6 @@ typedef enum {
/* Captures and reports NSExceptions. */
SentryCrashMonitorTypeNSException = 0x08,

/* Accepts and reports user-generated exceptions. */
SentryCrashMonitorTypeUserReported = 0x20,

/* Keeps track of and injects system information. */
SentryCrashMonitorTypeSystem = 0x40,

Expand All @@ -67,8 +63,8 @@ typedef enum {
#define SentryCrashMonitorTypeAll \
(SentryCrashMonitorTypeMachException | SentryCrashMonitorTypeSignal \
| SentryCrashMonitorTypeCPPException | SentryCrashMonitorTypeNSException \
| SentryCrashMonitorTypeUserReported | SentryCrashMonitorTypeSystem \
| SentryCrashMonitorTypeApplicationState | SentryCrashMonitorTypeZombie)
| SentryCrashMonitorTypeSystem | SentryCrashMonitorTypeApplicationState \
| SentryCrashMonitorTypeZombie)

#define SentryCrashMonitorTypeDebuggerUnsafe \
(SentryCrashMonitorTypeMachException | SentryCrashMonitorTypeSignal \
Expand Down Expand Up @@ -101,12 +97,6 @@ typedef enum {
#define SentryCrashMonitorTypeRequired \
(SentryCrashMonitorTypeSystem | SentryCrashMonitorTypeApplicationState)

/** Effectively disables automatica reporting. The only way to generate a report
* in this mode is by manually calling sentrycrash_reportUserException().
*/
#define SentryCrashMonitorTypeManual \
(SentryCrashMonitorTypeRequired | SentryCrashMonitorTypeUserReported)

#define SentryCrashMonitorTypeNone 0

const char *sentrycrashmonitortype_name(SentryCrashMonitorType monitorType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
*/

static void
handleException(NSException *exception, BOOL currentSnapshotUserReported)
handleException(NSException *exception)
{
SentryCrashLOG_DEBUG(@"Trapped exception %@", exception);
if (g_isEnabled) {
Expand Down Expand Up @@ -94,15 +94,11 @@
crashContext->exceptionName = crashContext->NSException.name;
crashContext->crashReason = [[exception reason] UTF8String];
crashContext->stackCursor = &cursor;
crashContext->currentSnapshotUserReported = currentSnapshotUserReported;

SentryCrashLOG_DEBUG(@"Calling main crash handler.");
sentrycrashcm_handleException(crashContext);

free(callstack);
if (currentSnapshotUserReported) {
sentrycrashmc_resumeEnvironment(threads, numThreads);
}
if (g_previousUncaughtExceptionHandler != NULL) {
SentryCrashLOG_DEBUG(@"Calling original exception handler.");
g_previousUncaughtExceptionHandler(exception);
Expand All @@ -111,16 +107,10 @@
}
}

static void
handleCurrentSnapshotUserReportedException(NSException *exception)
{
handleException(exception, true);
}

static void
handleUncaughtException(NSException *exception)
{
handleException(exception, false);
handleException(exception);
}

// ============================================================================
Expand All @@ -139,8 +129,6 @@
SentryCrashLOG_DEBUG(@"Setting new handler.");
NSSetUncaughtExceptionHandler(&handleUncaughtException);
SentryCrash.sharedInstance.uncaughtExceptionHandler = &handleUncaughtException;
SentryCrash.sharedInstance.currentSnapshotUserReportedExceptionHandler
= &handleCurrentSnapshotUserReportedException;
} else {
SentryCrashLOG_DEBUG(@"Restoring original handler.");
NSSetUncaughtExceptionHandler(g_previousUncaughtExceptionHandler);
Expand Down
108 changes: 0 additions & 108 deletions Sources/SentryCrash/Recording/Monitors/SentryCrashMonitor_User.c

This file was deleted.

70 changes: 0 additions & 70 deletions Sources/SentryCrash/Recording/Monitors/SentryCrashMonitor_User.h

This file was deleted.

5 changes: 0 additions & 5 deletions Sources/SentryCrash/Recording/SentryCrash.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,6 @@ static NSString *const SENTRYCRASH_REPORT_ATTACHMENTS_ITEM = @"attachments";
* debugger is running. **/
@property (nonatomic, assign) NSUncaughtExceptionHandler *uncaughtExceptionHandler;

/** Exposes the currentSnapshotUserReportedExceptionHandler if set from
* SentryCrash. Is nil if debugger is running. **/
@property (nonatomic, assign)
NSUncaughtExceptionHandler *currentSnapshotUserReportedExceptionHandler;

#pragma mark - Information -

/** Total active time elapsed since the last crash. */
Expand Down
Loading

0 comments on commit 3936dd2

Please sign in to comment.