Skip to content

Commit c18d93a

Browse files
authored
Merge c11af52 into fbcffd6
2 parents fbcffd6 + c11af52 commit c18d93a

File tree

10 files changed

+45
-22
lines changed

10 files changed

+45
-22
lines changed

Sources/Sentry/SentryANRTrackingIntegration.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ @interface SentryANRTrackingIntegration () <SentryANRTrackerDelegate>
3131
@property (nonatomic, strong) SentryDispatchQueueWrapper *dispatchQueueWrapper;
3232
@property (nonatomic, strong) SentryCrashWrapper *crashWrapper;
3333
@property (nonatomic, strong) SentryDebugImageProvider *debugImageProvider;
34-
@property (nonatomic, strong) id<SentryThreadInspector> threadInspector;
34+
@property (nonatomic, strong) SentryThreadInspector *threadInspector;
3535
@property (atomic, assign) BOOL reportAppHangs;
3636
@property (atomic, assign) BOOL enableReportNonFullyBlockingAppHangs;
3737

Sources/Sentry/SentryDefaultThreadInspector.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ - (id)initWithStacktraceBuilder:(SentryStacktraceBuilder *)stacktraceBuilder
6666
return self;
6767
}
6868

69-
- (instancetype)initWithOptions:(SentryOptions *)options
69+
- (instancetype)initWithOptions:(SentryOptions *_Nullable)options
7070
{
7171
SentryInAppLogic *inAppLogic =
7272
[[SentryInAppLogic alloc] initWithInAppIncludes:options.inAppIncludes

Sources/Sentry/SentryDependencyContainer.m

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@
6363
@interface SentryFileManager () <SentryFileManagerProtocol>
6464
@end
6565

66-
@interface SentryDefaultThreadInspector () <SentryThreadInspector>
67-
@end
68-
6966
@interface SentryDefaultAppStateManager () <SentryAppStateManager>
7067
@end
7168

@@ -153,7 +150,7 @@ - (instancetype)init
153150

154151
_notificationCenterWrapper = NSNotificationCenter.defaultCenter;
155152

156-
_processInfoWrapper = NSProcessInfo.processInfo;
153+
_processInfoWrapper = SentryDependencies.processInfoWrapper;
157154
_crashWrapper = [[SentryCrashWrapper alloc] initWithProcessInfoWrapper:_processInfoWrapper];
158155
#if SENTRY_HAS_UIKIT
159156
_uiDeviceWrapper = SentryDependencies.uiDeviceWrapper;
@@ -227,10 +224,9 @@ - (nullable SentryFileManager *)fileManager SENTRY_THREAD_SANITIZER_DOUBLE_CHECK
227224
notificationCenterWrapper:self.notificationCenterWrapper]);
228225
}
229226

230-
- (id<SentryThreadInspector>)threadInspector SENTRY_THREAD_SANITIZER_DOUBLE_CHECKED_LOCK
227+
- (SentryThreadInspector *)threadInspector SENTRY_THREAD_SANITIZER_DOUBLE_CHECKED_LOCK
231228
{
232-
SENTRY_LAZY_INIT(_threadInspector,
233-
[[SentryDefaultThreadInspector alloc] initWithOptions:SentrySDKInternal.options]);
229+
return SentryDependencies.threadInspector;
234230
}
235231

236232
- (SentryFileIOTracker *)fileIOTracker SENTRY_THREAD_SANITIZER_DOUBLE_CHECKED_LOCK

Sources/Sentry/SentryFileIOTracker.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ @interface SentryFileIOTracker ()
2222

2323
@property (nonatomic, assign) BOOL isEnabled;
2424
@property (nonatomic, strong) NSMutableSet<NSData *> *processingData;
25-
@property (nonatomic, strong) id<SentryThreadInspector> threadInspector;
25+
@property (nonatomic, strong) SentryThreadInspector *threadInspector;
2626
@property (nonatomic, strong) id<SentryProcessInfoSource> processInfoWrapper;
2727

2828
@end
@@ -42,7 +42,7 @@ + (instancetype _Nullable)sharedInstance
4242
return SentryDependencyContainer.sharedInstance.fileIOTracker;
4343
}
4444

45-
- (instancetype)initWithThreadInspector:(id<SentryThreadInspector>)threadInspector
45+
- (instancetype)initWithThreadInspector:(SentryThreadInspector *)threadInspector
4646
processInfoWrapper:(id<SentryProcessInfoSource>)processInfoWrapper
4747
{
4848
if (self = [super init]) {
@@ -245,7 +245,7 @@ - (void)mainThreadExtraInfo:(id<SentrySpan>)span
245245
return;
246246
}
247247

248-
id<SentryThreadInspector> threadInspector = self.threadInspector;
248+
SentryThreadInspector *threadInspector = self.threadInspector;
249249
SentryStacktrace *stackTrace = [threadInspector stacktraceForCurrentThreadAsyncUnsafe];
250250

251251
NSArray *frames = [stackTrace.frames

Sources/Sentry/include/HybridPublic/SentryDependencyContainer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
@class SentryOptions;
2424
@class SentrySessionTracker;
2525
@class SentryGlobalEventProcessor;
26+
@class SentryThreadInspector;
2627
@class SentryReachability;
2728

2829
@protocol SentryAppStateManager;
@@ -33,7 +34,6 @@
3334
@protocol SentryApplication;
3435
@protocol SentryProcessInfoSource;
3536
@protocol SentryNSNotificationCenterWrapper;
36-
@protocol SentryThreadInspector;
3737
@protocol SentryObjCRuntimeWrapper;
3838

3939
#if SENTRY_HAS_METRIC_KIT
@@ -99,7 +99,7 @@ SENTRY_NO_INIT
9999

100100
@property (nonatomic, strong, nullable) SentryFileManager *fileManager;
101101
@property (nonatomic, strong) id<SentryAppStateManager> appStateManager;
102-
@property (nonatomic, strong) id<SentryThreadInspector> threadInspector;
102+
@property (nonatomic, strong) SentryThreadInspector *threadInspector;
103103
@property (nonatomic, strong) SentryFileIOTracker *fileIOTracker;
104104
@property (nonatomic, strong) SentryCrash *crashReporter;
105105
@property (nonatomic, strong) SentryScopePersistentStore *scopePersistentStore;

Sources/Sentry/include/SentryDefaultThreadInspector.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#import "SentryCrashMachineContextWrapper.h"
1+
#import "SentryCrashThread.h"
22
#import "SentryDefines.h"
33
#import <Foundation/Foundation.h>
44

@@ -7,6 +7,8 @@
77
@class SentryStacktraceBuilder;
88
@class SentryThread;
99

10+
@protocol SentryCrashMachineContextWrapper;
11+
1012
NS_ASSUME_NONNULL_BEGIN
1113

1214
@interface SentryDefaultThreadInspector : NSObject
@@ -16,7 +18,7 @@ SENTRY_NO_INIT
1618
andMachineContextWrapper:(id<SentryCrashMachineContextWrapper>)machineContextWrapper
1719
symbolicate:(BOOL)symbolicate;
1820

19-
- (instancetype)initWithOptions:(SentryOptions *)options;
21+
- (instancetype)initWithOptions:(SentryOptions *_Nullable)options;
2022

2123
- (nullable SentryStacktrace *)stacktraceForCurrentThreadAsyncUnsafe;
2224

Sources/Sentry/include/SentryFileIOTracker.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
NS_ASSUME_NONNULL_BEGIN
44

55
@protocol SentryProcessInfoSource;
6-
@protocol SentryThreadInspector;
6+
@class SentryThreadInspector;
77

88
@interface SentryFileIOTracker : NSObject
99
SENTRY_NO_INIT
@@ -18,7 +18,7 @@ SENTRY_NO_INIT
1818
*/
1919
+ (instancetype _Nullable)sharedInstance;
2020

21-
- (instancetype)initWithThreadInspector:(id<SentryThreadInspector>)threadInspector
21+
- (instancetype)initWithThreadInspector:(SentryThreadInspector *)threadInspector
2222
processInfoWrapper:(id<SentryProcessInfoSource>)processInfoWrapper;
2323

2424
- (void)enable;

Sources/Sentry/include/SentryPrivate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#import "SentryCrashMonitor_AppState.h"
3030
#import "SentryCrashMonitor_System.h"
3131
#import "SentryDateUtils.h"
32+
#import "SentryDefaultThreadInspector.h"
3233
#import "SentryDependencyContainerSwiftHelper.h"
3334
#import "SentryEvent+Serialize.h"
3435
#import "SentryFileIOTracker.h"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1+
@_implementationOnly import _SentryPrivate
2+
13
@objc(SentryDependencies) @_spi(Private) public final class Dependencies: NSObject {
4+
@objc public static let processInfoWrapper: SentryProcessInfoSource = ProcessInfo.processInfo
25
@objc public static let dispatchQueueWrapper = SentryDispatchQueueWrapper()
36
@objc public static let dateProvider = SentryDefaultCurrentDateProvider()
47
public static let objcRuntimeWrapper = SentryDefaultObjCRuntimeWrapper()
58
#if !os(watchOS) && !os(macOS) && !SENTRY_NO_UIKIT
69
@objc public static let uiDeviceWrapper = SentryDefaultUIDeviceWrapper(queueWrapper: Dependencies.dispatchQueueWrapper)
710
#endif // !os(watchOS) && !os(macOS) && !SENTRY_NO_UIKIT
11+
12+
@objc public static var threadInspector: SentryThreadInspector = {
13+
SentryThreadInspector()
14+
}()
15+
816
}
Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
1-
@_spi(Private) @objc public protocol SentryThreadInspector {
2-
func stacktraceForCurrentThreadAsyncUnsafe() -> SentryStacktrace?
3-
func getCurrentThreadsWithStackTrace() -> [SentryThread]
4-
func getThreadName(_ thread: UInt) -> String?
1+
@_implementationOnly import _SentryPrivate
2+
3+
@_spi(Private) @objc public class SentryThreadInspector: NSObject {
4+
private let internalHelper: SentryDefaultThreadInspector
5+
6+
override init() {
7+
internalHelper = SentryDefaultThreadInspector(options: SentrySDKInternal.options)
8+
}
9+
10+
@objc public func stacktraceForCurrentThreadAsyncUnsafe() -> SentryStacktrace? {
11+
internalHelper.stacktraceForCurrentThreadAsyncUnsafe()
12+
}
13+
14+
@objc public func getCurrentThreadsWithStackTrace() -> [SentryThread] {
15+
internalHelper.getCurrentThreadsWithStackTrace()
16+
}
17+
18+
@objc public func getThreadName(_ thread: UInt) -> String? {
19+
internalHelper.getThreadName(thread)
20+
}
521
}

0 commit comments

Comments
 (0)