From 04d16aa6cb7ef27e3f1ec227acaabc1fcb92a711 Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Wed, 27 Aug 2025 12:15:03 -0300 Subject: [PATCH 01/14] ref: Migrate `SentryBinaryImageCache` to Swift --- Sentry.xcodeproj/project.pbxproj | 32 +- .../SentryTestUtils-ObjC-BridgingHeader.h | 1 - Sources/Resources/Sentry.modulemap | 1 - Sources/Sentry/SentryBinaryImageCache.m | 197 ---------- .../Sentry/SentryBinaryImageCacheCallbacks.m | 30 ++ Sources/Sentry/SentryCrashStackEntryMapper.m | 3 +- Sources/Sentry/SentryDebugImageProvider.m | 4 +- Sources/Sentry/SentryDependencyContainer.m | 1 - Sources/Sentry/SentrySDKInternal.m | 5 +- .../Sentry/SentryUIViewControllerSwizzling.m | 1 - .../HybridPublic/SentryBinaryImageCache.h | 35 -- .../SentryBinaryImageCacheCallbacks.h | 6 + Sources/Sentry/include/SentryPrivate.h | 4 + .../Core/Helper/SentryBinaryImageCache.swift | 182 +++++++++ ...SentryUIViewControllerSwizzlingTests.swift | 11 +- .../SentryBinaryImageCache+Private.h | 12 - .../SentryBinaryImageCacheTests.swift | 266 ++++++------- ...s.m => SentryCrashBinaryImageCacheTests.m} | 26 -- .../SentryCrashBinaryImageCacheTests.swift | 348 ++++++++++++++++++ .../SentryCrashStackEntryMapperTests.swift | 13 +- .../SentryDebugImageProviderTests.swift | 13 +- Tests/SentryTests/SentrySDKTests.swift | 5 +- .../SentryTests/SentryTests-Bridging-Header.h | 1 - 23 files changed, 766 insertions(+), 431 deletions(-) delete mode 100644 Sources/Sentry/SentryBinaryImageCache.m create mode 100644 Sources/Sentry/SentryBinaryImageCacheCallbacks.m delete mode 100644 Sources/Sentry/include/HybridPublic/SentryBinaryImageCache.h create mode 100644 Sources/Sentry/include/HybridPublic/SentryBinaryImageCacheCallbacks.h create mode 100644 Sources/Swift/Core/Helper/SentryBinaryImageCache.swift delete mode 100644 Tests/SentryTests/SentryBinaryImageCache+Private.h rename Tests/SentryTests/SentryCrash/{SentryBinaryImageCacheTests.m => SentryCrashBinaryImageCacheTests.m} (89%) create mode 100644 Tests/SentryTests/SentryCrash/SentryCrashBinaryImageCacheTests.swift diff --git a/Sentry.xcodeproj/project.pbxproj b/Sentry.xcodeproj/project.pbxproj index a9ee96e9889..6e9bca56e9a 100644 --- a/Sentry.xcodeproj/project.pbxproj +++ b/Sentry.xcodeproj/project.pbxproj @@ -939,8 +939,8 @@ D855B3E827D652AF00BCED76 /* SentryCoreDataTrackingIntegrationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = D855B3E727D652AF00BCED76 /* SentryCoreDataTrackingIntegrationTest.swift */; }; D855B3EA27D652C700BCED76 /* TestCoreDataStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = D855B3E927D652C700BCED76 /* TestCoreDataStack.swift */; }; D85852BA27EDDC5900C6D8AE /* SentryUIApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = D85852B827EDDC5900C6D8AE /* SentryUIApplication.m */; }; - D858FA662A29EAB3002A3503 /* SentryBinaryImageCache.h in Headers */ = {isa = PBXBuildFile; fileRef = D858FA642A29EAB3002A3503 /* SentryBinaryImageCache.h */; settings = {ATTRIBUTES = (Private, ); }; }; - D858FA672A29EAB3002A3503 /* SentryBinaryImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = D858FA652A29EAB3002A3503 /* SentryBinaryImageCache.m */; }; + D858FA662A29EAB3002A3503 /* SentryBinaryImageCacheCallbacks.h in Headers */ = {isa = PBXBuildFile; fileRef = D858FA642A29EAB3002A3503 /* SentryBinaryImageCacheCallbacks.h */; settings = {ATTRIBUTES = (Private, ); }; }; + D858FA672A29EAB3002A3503 /* SentryBinaryImageCacheCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = D858FA652A29EAB3002A3503 /* SentryBinaryImageCacheCallbacks.m */; }; D859696B27BECD8F0036A46E /* SentryCoreDataTrackingIntegration.m in Sources */ = {isa = PBXBuildFile; fileRef = D859696927BECD8F0036A46E /* SentryCoreDataTrackingIntegration.m */; }; D859696F27BECDA20036A46E /* SentryCoreDataTracker.m in Sources */ = {isa = PBXBuildFile; fileRef = D859696D27BECDA20036A46E /* SentryCoreDataTracker.m */; }; D859697327BECDD20036A46E /* SentryCoreDataSwizzling.m in Sources */ = {isa = PBXBuildFile; fileRef = D859697127BECDD20036A46E /* SentryCoreDataSwizzling.m */; }; @@ -1012,7 +1012,7 @@ D8CB741B2947286500A5F964 /* SentryEnvelopeItemHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = D8CB741A2947286500A5F964 /* SentryEnvelopeItemHeader.m */; }; D8CB742B294B1DD000A5F964 /* SentryUIApplicationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8CB742A294B1DD000A5F964 /* SentryUIApplicationTests.swift */; }; D8CB742E294B294B00A5F964 /* MockUIScene.m in Sources */ = {isa = PBXBuildFile; fileRef = D8CB742D294B294B00A5F964 /* MockUIScene.m */; }; - D8CCFC632A1520C900DE232E /* SentryBinaryImageCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D8CCFC622A1520C900DE232E /* SentryBinaryImageCacheTests.m */; }; + D8CCFC632A1520C900DE232E /* SentryCrashBinaryImageCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D8CCFC622A1520C900DE232E /* SentryCrashBinaryImageCacheTests.m */; }; D8CD158F2D39405900EFF8AB /* TestFramesTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841325DE2BFED0510029228F /* TestFramesTracker.swift */; }; D8CE69BC277E39C700C6EC5C /* SentryFileIOTrackingIntegrationObjCTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D8CE69BB277E39C700C6EC5C /* SentryFileIOTrackingIntegrationObjCTests.m */; }; D8DBE0CA2C0E093000FAB1FD /* SentryTouchTrackerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8DBE0C92C0E093000FAB1FD /* SentryTouchTrackerTests.swift */; }; @@ -1042,6 +1042,8 @@ F458D1172E186DF20028273E /* SentryScopePersistentStore+Fingerprint.swift in Sources */ = {isa = PBXBuildFile; fileRef = F458D1162E186DF20028273E /* SentryScopePersistentStore+Fingerprint.swift */; }; F458D1192E186E000028273E /* SentryScopePersistentStore+Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = F458D1182E186E000028273E /* SentryScopePersistentStore+Extras.swift */; }; F46DA6C32E1DBCA000DF6E3B /* SentryScopePersistentStore+Helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = F46DA6C22E1DBCA000DF6E3B /* SentryScopePersistentStore+Helper.swift */; }; + F48F74582E5F52C2009D4E7D /* SentryCrashBinaryImageCacheTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F48F74572E5F52C2009D4E7D /* SentryCrashBinaryImageCacheTests.swift */; }; + F49236EB2E5E4B2F00663673 /* SentryBinaryImageCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = F49236EA2E5E4B2F00663673 /* SentryBinaryImageCache.swift */; }; F49D41982DEA27AF00D9244E /* SentryUseNSExceptionCallstackWrapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F49D41972DEA27AF00D9244E /* SentryUseNSExceptionCallstackWrapperTests.swift */; }; F49D419A2DEA2FB000D9244E /* SentryCrashExceptionApplicationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F49D41992DEA2FB000D9244E /* SentryCrashExceptionApplicationTests.swift */; }; F49D419C2DEA30C300D9244E /* SentryCrashExceptionApplicationHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = F49D419B2DEA30B800D9244E /* SentryCrashExceptionApplicationHelper.h */; }; @@ -2274,8 +2276,8 @@ D855B3E927D652C700BCED76 /* TestCoreDataStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestCoreDataStack.swift; sourceTree = ""; }; D85790282976A69F00C6AC1F /* TestDebugImageProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestDebugImageProvider.swift; sourceTree = ""; }; D85852B827EDDC5900C6D8AE /* SentryUIApplication.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryUIApplication.m; sourceTree = ""; }; - D858FA642A29EAB3002A3503 /* SentryBinaryImageCache.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryBinaryImageCache.h; path = include/HybridPublic/SentryBinaryImageCache.h; sourceTree = ""; }; - D858FA652A29EAB3002A3503 /* SentryBinaryImageCache.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryBinaryImageCache.m; sourceTree = ""; }; + D858FA642A29EAB3002A3503 /* SentryBinaryImageCacheCallbacks.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryBinaryImageCacheCallbacks.h; path = include/HybridPublic/SentryBinaryImageCacheCallbacks.h; sourceTree = ""; }; + D858FA652A29EAB3002A3503 /* SentryBinaryImageCacheCallbacks.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryBinaryImageCacheCallbacks.m; sourceTree = ""; }; D859696927BECD8F0036A46E /* SentryCoreDataTrackingIntegration.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryCoreDataTrackingIntegration.m; sourceTree = ""; }; D859696D27BECDA20036A46E /* SentryCoreDataTracker.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryCoreDataTracker.m; sourceTree = ""; }; D859697127BECDD20036A46E /* SentryCoreDataSwizzling.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryCoreDataSwizzling.m; sourceTree = ""; }; @@ -2357,7 +2359,7 @@ D8CB742A294B1DD000A5F964 /* SentryUIApplicationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUIApplicationTests.swift; sourceTree = ""; }; D8CB742C294B294B00A5F964 /* MockUIScene.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockUIScene.h; sourceTree = ""; }; D8CB742D294B294B00A5F964 /* MockUIScene.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MockUIScene.m; sourceTree = ""; }; - D8CCFC622A1520C900DE232E /* SentryBinaryImageCacheTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryBinaryImageCacheTests.m; sourceTree = ""; }; + D8CCFC622A1520C900DE232E /* SentryCrashBinaryImageCacheTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryCrashBinaryImageCacheTests.m; sourceTree = ""; }; D8CE69BB277E39C700C6EC5C /* SentryFileIOTrackingIntegrationObjCTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryFileIOTrackingIntegrationObjCTests.m; sourceTree = ""; }; D8DBE0C92C0E093000FAB1FD /* SentryTouchTrackerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryTouchTrackerTests.swift; sourceTree = ""; }; D8DBE0D12C0EFFC300FAB1FD /* SentryReplayOptionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryReplayOptionsTests.swift; sourceTree = ""; }; @@ -2388,6 +2390,8 @@ F458D1162E186DF20028273E /* SentryScopePersistentStore+Fingerprint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SentryScopePersistentStore+Fingerprint.swift"; sourceTree = ""; }; F458D1182E186E000028273E /* SentryScopePersistentStore+Extras.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SentryScopePersistentStore+Extras.swift"; sourceTree = ""; }; F46DA6C22E1DBCA000DF6E3B /* SentryScopePersistentStore+Helper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SentryScopePersistentStore+Helper.swift"; sourceTree = ""; }; + F48F74572E5F52C2009D4E7D /* SentryCrashBinaryImageCacheTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryCrashBinaryImageCacheTests.swift; sourceTree = ""; }; + F49236EA2E5E4B2F00663673 /* SentryBinaryImageCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryBinaryImageCache.swift; sourceTree = ""; }; F49D41972DEA27AF00D9244E /* SentryUseNSExceptionCallstackWrapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUseNSExceptionCallstackWrapperTests.swift; sourceTree = ""; }; F49D41992DEA2FB000D9244E /* SentryCrashExceptionApplicationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryCrashExceptionApplicationTests.swift; sourceTree = ""; }; F49D419B2DEA30B800D9244E /* SentryCrashExceptionApplicationHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryCrashExceptionApplicationHelper.h; path = include/SentryCrashExceptionApplicationHelper.h; sourceTree = ""; }; @@ -2953,8 +2957,8 @@ FAB359992E05D8080083D5E3 /* SentryEventSwiftHelper.m */, 33042A0B29DAF5F400C60085 /* SentryExtraContextProvider.h */, 33042A0C29DAF79A00C60085 /* SentryExtraContextProvider.m */, - D858FA642A29EAB3002A3503 /* SentryBinaryImageCache.h */, - D858FA652A29EAB3002A3503 /* SentryBinaryImageCache.m */, + D858FA642A29EAB3002A3503 /* SentryBinaryImageCacheCallbacks.h */, + D858FA652A29EAB3002A3503 /* SentryBinaryImageCacheCallbacks.m */, D8739D152BEEA33F007D2F66 /* SentryLevelHelper.h */, D8739D162BEEA33F007D2F66 /* SentryLevelHelper.m */, F452438B2DE65BC0003E8F50 /* SentryUseNSExceptionCallstackWrapper.h */, @@ -3291,7 +3295,8 @@ children = ( F4AACD602E01ACE800DDDD1E /* SentryCrashDynamicLinkerTests.m */, 63FE71F120DA66EA00CDBAE8 /* Container+DeepSearch_Tests.m */, - D8CCFC622A1520C900DE232E /* SentryBinaryImageCacheTests.m */, + D8CCFC622A1520C900DE232E /* SentryCrashBinaryImageCacheTests.m */, + F48F74572E5F52C2009D4E7D /* SentryCrashBinaryImageCacheTests.swift */, 63FE71F620DA66EB00CDBAE8 /* FileBasedTestCase.h */, 63FE71D920DA66E700CDBAE8 /* FileBasedTestCase.m */, 84EB21952BF01CEA00EDDA28 /* SentryCrashInstallationTests.swift */, @@ -4764,6 +4769,7 @@ FA67DCCC2DDBD4EA00896B02 /* Helper */ = { isa = PBXGroup; children = ( + F49236EA2E5E4B2F00663673 /* SentryBinaryImageCache.swift */, FA90FAA72E06614B008CAAE8 /* SentryExtraPackages.swift */, FA67DCC82DDBD4EA00896B02 /* Log */, FA67DCC92DDBD4EA00896B02 /* SentryBaggageSerialization.swift */, @@ -4982,7 +4988,7 @@ 8E4A037825F6F52100000D77 /* SentrySampleDecision.h in Headers */, 63FE717920DA4C1100CDBAE8 /* SentryCrashReportStore.h in Headers */, 0AAE202128ED9BCC00D0CD80 /* SentryReachability.h in Headers */, - D858FA662A29EAB3002A3503 /* SentryBinaryImageCache.h in Headers */, + D858FA662A29EAB3002A3503 /* SentryBinaryImageCacheCallbacks.h in Headers */, A839D89824864B80003B7AFD /* SentrySystemEventBreadcrumbs.h in Headers */, 7B14089624878F090035403D /* SentryCrashStackEntryMapper.h in Headers */, 63FE714920DA4C1100CDBAE8 /* SentryCrashStackCursor_Backtrace.h in Headers */, @@ -5679,7 +5685,7 @@ D473ACD72D8090FC000F1CC6 /* FileManager+SentryTracing.swift in Sources */, D4AF00212D2E92FD00F5F3D7 /* SentryNSFileManagerSwizzling.m in Sources */, 639FCFA91EBC80CC00778193 /* SentryFrame.m in Sources */, - D858FA672A29EAB3002A3503 /* SentryBinaryImageCache.m in Sources */, + D858FA672A29EAB3002A3503 /* SentryBinaryImageCacheCallbacks.m in Sources */, 8E564AEA267AF22600FE117D /* SentryNetworkTracker.m in Sources */, 15360CED2433A15500112302 /* SentryInstallation.m in Sources */, D8370B6A273DF1E900F66E2D /* SentryNSURLSessionTaskSearch.m in Sources */, @@ -5843,6 +5849,7 @@ FA3734862E0F09320091EF24 /* SentryDependencyContainerSwiftHelper.m in Sources */, 63FE70DF20DA4C1000CDBAE8 /* SentryCrashMonitorType.c in Sources */, D468C0622D3669A200964230 /* SentryFileIOTracker+SwiftHelpers.swift in Sources */, + F49236EB2E5E4B2F00663673 /* SentryBinaryImageCache.swift in Sources */, 7BF9EF7E2722B91F00B5BBEF /* SentryDefaultObjCRuntimeWrapper.m in Sources */, 7BC3936E25B1AB72004F03D3 /* SentryLevelMapper.m in Sources */, 6304360B1EC0595B00C4D3FA /* SentryNSDataUtils.m in Sources */, @@ -6084,6 +6091,7 @@ 7B6C5ED6264E62CA0010D138 /* SentryTransactionTests.swift in Sources */, D81FDF12280EA1060045E0E4 /* SentryScreenShotTests.swift in Sources */, D8019910286B089000C277F0 /* SentryCrashReportSinkTests.swift in Sources */, + F48F74582E5F52C2009D4E7D /* SentryCrashBinaryImageCacheTests.swift in Sources */, D885266427739D01001269FC /* SentryFileIOTrackingIntegrationTests.swift in Sources */, 7BBD18992449DE9D00427C76 /* TestRateLimits.swift in Sources */, 7B04A9AB24EA5F8D00E710B1 /* SentryUserTests.swift in Sources */, @@ -6122,7 +6130,7 @@ D480F9DB2DE47AF2009A0594 /* SentryScopePersistentStoreTests.swift in Sources */, F4DC35582E1FFE1F0077CE89 /* SentryVideoFrameProcessorTests.swift in Sources */, 7BC6EC18255C44540059822A /* SentryDebugMetaTests.swift in Sources */, - D8CCFC632A1520C900DE232E /* SentryBinaryImageCacheTests.m in Sources */, + D8CCFC632A1520C900DE232E /* SentryCrashBinaryImageCacheTests.m in Sources */, A811D867248E2770008A41EA /* SentrySystemEventBreadcrumbsTest.swift in Sources */, 7B82D54924E2A2D400EE670F /* SentryIdTests.swift in Sources */, 623FD9062D3FA9C800803EDA /* NSNumberDecodableWrapperTests.swift in Sources */, diff --git a/SentryTestUtils/SentryTestUtils-ObjC-BridgingHeader.h b/SentryTestUtils/SentryTestUtils-ObjC-BridgingHeader.h index 41c12603870..bfb2e0797f0 100644 --- a/SentryTestUtils/SentryTestUtils-ObjC-BridgingHeader.h +++ b/SentryTestUtils/SentryTestUtils-ObjC-BridgingHeader.h @@ -26,7 +26,6 @@ #import "PrivateSentrySDKOnly.h" #import "SentryAppStartMeasurement.h" -#import "SentryBinaryImageCache.h" #import "SentryClient+Private.h" #import "SentryClient+TestInit.h" #import "SentryCrash+Test.h" diff --git a/Sources/Resources/Sentry.modulemap b/Sources/Resources/Sentry.modulemap index 466bc7af067..554d757209f 100644 --- a/Sources/Resources/Sentry.modulemap +++ b/Sources/Resources/Sentry.modulemap @@ -9,7 +9,6 @@ framework module Sentry { header "PrivateSentrySDKOnly.h" header "PrivatesHeader.h" header "SentryAppStartMeasurement.h" - header "SentryBinaryImageCache.h" header "SentryBreadcrumb+Private.h" header "SentryDebugImageProvider+HybridSDKs.h" header "SentryDependencyContainer.h" diff --git a/Sources/Sentry/SentryBinaryImageCache.m b/Sources/Sentry/SentryBinaryImageCache.m deleted file mode 100644 index e2b3e8647c2..00000000000 --- a/Sources/Sentry/SentryBinaryImageCache.m +++ /dev/null @@ -1,197 +0,0 @@ -#import "SentryBinaryImageCache.h" -#import "SentryCrashBinaryImageCache.h" -#include "SentryCrashUUIDConversion.h" -#import "SentryDefaultObjCRuntimeWrapper.h" -#import "SentryDependencyContainer.h" -#import "SentryInternalDefines.h" -#import "SentryLogC.h" -#import "SentrySDK+Private.h" -#import "SentrySwift.h" - -NS_ASSUME_NONNULL_BEGIN - -static void binaryImageWasAdded(const SentryCrashBinaryImage *image); - -static void binaryImageWasRemoved(const SentryCrashBinaryImage *image); - -@implementation SentryBinaryImageInfo -@end - -@interface SentryBinaryImageCache () -@property (nonatomic, strong, nullable) NSMutableArray *cache; -@property (nonatomic, assign) BOOL isDebug; -- (void)binaryImageAdded:(const SentryCrashBinaryImage *)image; -- (void)binaryImageRemoved:(const SentryCrashBinaryImage *)image; -@end - -@implementation SentryBinaryImageCache - -- (void)start:(BOOL)isDebug -{ - @synchronized(self) { - _isDebug = isDebug; - _cache = [NSMutableArray array]; - sentrycrashbic_registerAddedCallback(&binaryImageWasAdded); - sentrycrashbic_registerRemovedCallback(&binaryImageWasRemoved); - } -} - -- (void)stop -{ - @synchronized(self) { - sentrycrashbic_registerAddedCallback(NULL); - sentrycrashbic_registerRemovedCallback(NULL); - _cache = nil; - } -} - -- (void)binaryImageAdded:(const SentryCrashBinaryImage *)image -{ - if (image == NULL) { - SENTRY_LOG_WARN(@"The image is NULL. Can't add NULL to cache."); - return; - } - - if (image->name == NULL) { - SENTRY_LOG_WARN(@"The image name was NULL. Can't add image to cache."); - return; - } - - NSString *imageName = [NSString stringWithCString:image->name encoding:NSUTF8StringEncoding]; - - if (imageName == nil) { - SENTRY_LOG_WARN(@"Couldn't convert the cString image name to an NSString. This could be " - @"due to a different encoding than NSUTF8StringEncoding of the cString.."); - return; - } - - SentryBinaryImageInfo *newImage = [[SentryBinaryImageInfo alloc] init]; - newImage.name = SENTRY_UNWRAP_NULLABLE(NSString, imageName); - newImage.UUID = [SentryBinaryImageCache convertUUID:image->uuid]; - newImage.address = image->address; - newImage.vmAddress = image->vmAddress; - newImage.size = image->size; - - @synchronized(self) { - NSUInteger left = 0; - NSUInteger right = _cache.count; - - while (left < right) { - NSUInteger mid = (left + right) / 2; - SentryBinaryImageInfo *compareImage = _cache[mid]; - if (newImage.address < compareImage.address) { - right = mid; - } else { - left = mid + 1; - } - } - - [_cache insertObject:newImage atIndex:left]; - } - - if (self.isDebug) { - // This validation adds some overhead with each class present in the image, so we only - // run this when debug is enabled. A non main queue is used to avoid affecting the UI. - [LoadValidator - checkForDuplicatedSDKWithImageName:imageName - imageAddress:@(newImage.address) - imageSize:@(newImage.size) - dispatchQueueWrapper:[[SentryDependencyContainer sharedInstance] - dispatchQueueWrapper]]; - } -} - -+ (NSString *_Nullable)convertUUID:(const unsigned char *const)value -{ - if (nil == value) { - return nil; - } - - char uuidBuffer[37]; - sentrycrashdl_convertBinaryImageUUID(value, uuidBuffer); - return [[NSString alloc] initWithCString:uuidBuffer encoding:NSASCIIStringEncoding]; -} - -- (void)binaryImageRemoved:(const SentryCrashBinaryImage *)image -{ - if (image == NULL) { - SENTRY_LOG_WARN(@"The image is NULL. Can't remove it from the cache."); - return; - } - - @synchronized(self) { - NSInteger index = [self indexOfImage:image->address]; - if (index >= 0) { - [_cache removeObjectAtIndex:index]; - } - } -} - -- (nullable SentryBinaryImageInfo *)imageByAddress:(const uint64_t)address; -{ - @synchronized(self) { - NSInteger index = [self indexOfImage:address]; - return index >= 0 ? _cache[index] : nil; - } -} - -- (NSInteger)indexOfImage:(uint64_t)address -{ - if (_cache == nil) - return -1; - - NSInteger left = 0; - NSInteger right = _cache.count - 1; - - while (left <= right) { - NSInteger mid = (left + right) / 2; - SentryBinaryImageInfo *image = _cache[mid]; - - if (address >= image.address && address < (image.address + image.size)) { - return mid; - } else if (address < image.address) { - right = mid - 1; - } else { - left = mid + 1; - } - } - - return -1; // Address not found -} - -- (NSSet *)imagePathsForInAppInclude:(NSString *)inAppInclude -{ - NSMutableSet *imagePaths = [NSMutableSet new]; - - @synchronized(self) { - for (SentryBinaryImageInfo *info in _cache) { - if ([SentryInAppLogic isImageNameInApp:info.name inAppInclude:inAppInclude]) { - [imagePaths addObject:info.name]; - } - } - } - return imagePaths; -} - -- (NSArray *)getAllBinaryImages -{ - @synchronized(self) { - return SENTRY_UNWRAP_NULLABLE(NSArray, _cache.copy); - } -} - -@end - -static void -binaryImageWasAdded(const SentryCrashBinaryImage *image) -{ - [SentryDependencyContainer.sharedInstance.binaryImageCache binaryImageAdded:image]; -} - -static void -binaryImageWasRemoved(const SentryCrashBinaryImage *image) -{ - [SentryDependencyContainer.sharedInstance.binaryImageCache binaryImageRemoved:image]; -} - -NS_ASSUME_NONNULL_END diff --git a/Sources/Sentry/SentryBinaryImageCacheCallbacks.m b/Sources/Sentry/SentryBinaryImageCacheCallbacks.m new file mode 100644 index 00000000000..c0a9c4f699b --- /dev/null +++ b/Sources/Sentry/SentryBinaryImageCacheCallbacks.m @@ -0,0 +1,30 @@ +#import "SentryBinaryImageCacheCallbacks.h" +#import "SentryDependencyContainer.h" +#import "SentryInternalDefines.h" +#import "SentrySwift.h" + +// Used to call SentryDependencyContainer, since it isn't available to swift yet +void +binaryImageWasAdded(const SentryCrashBinaryImage *_Nullable image) +{ + if (image == NULL) { + SENTRY_LOG_WARN(@"The image is NULL. Can't add NULL to cache."); + return; + } + [SentryDependencyContainer.sharedInstance.binaryImageCache binaryImageAdded:image->name + vmAddress:image->vmAddress + address:image->address + size:image->size + uuid:image->uuid]; +} + +// Used to call SentryDependencyContainer, since it isn't available to swift yet +void +binaryImageWasRemoved(const SentryCrashBinaryImage *_Nullable image) +{ + if (image == NULL) { + SENTRY_LOG_WARN(@"The image is NULL. Can't remove it from the cache."); + return; + } + [SentryDependencyContainer.sharedInstance.binaryImageCache binaryImageRemoved:image->address]; +} diff --git a/Sources/Sentry/SentryCrashStackEntryMapper.m b/Sources/Sentry/SentryCrashStackEntryMapper.m index 46bd06a2528..f8007104c2b 100644 --- a/Sources/Sentry/SentryCrashStackEntryMapper.m +++ b/Sources/Sentry/SentryCrashStackEntryMapper.m @@ -1,5 +1,4 @@ #import "SentryCrashStackEntryMapper.h" -#import "SentryBinaryImageCache.h" #import "SentryDependencyContainer.h" #import "SentryFormatter.h" #import "SentryFrame.h" @@ -42,7 +41,7 @@ - (SentryFrame *)sentryCrashStackEntryToSentryFrame:(SentryCrashStackEntry)stack // we get image from the cache. if (stackEntry.imageAddress == 0 && stackEntry.imageName == NULL) { SentryBinaryImageInfo *info = [SentryDependencyContainer.sharedInstance.binaryImageCache - imageByAddress:stackEntry.address]; + imageByAddress:(uint64_t)stackEntry.address]; frame.imageAddress = sentry_formatHexAddressUInt64(info.address); frame.package = info.name; diff --git a/Sources/Sentry/SentryDebugImageProvider.m b/Sources/Sentry/SentryDebugImageProvider.m index ea53b532d08..ff06cd148c7 100644 --- a/Sources/Sentry/SentryDebugImageProvider.m +++ b/Sources/Sentry/SentryDebugImageProvider.m @@ -1,5 +1,4 @@ #import "SentryDebugImageProvider.h" -#import "SentryBinaryImageCache.h" #import "SentryDebugImageProvider+HybridSDKs.h" #if !SDK_V9 # import "SentryCrashDefaultBinaryImageProvider.h" @@ -13,6 +12,7 @@ #import "SentryInternalDefines.h" #import "SentryLogC.h" #import "SentryStacktrace.h" +#import "SentrySwift.h" #import "SentryThread.h" #import @@ -228,7 +228,7 @@ - (SentryDebugMeta *)fillDebugMetaFrom:(SentryCrashBinaryImage)image - (SentryDebugMeta *)fillDebugMetaFromBinaryImageInfo:(SentryBinaryImageInfo *)info { SentryDebugMeta *debugMeta = [[SentryDebugMeta alloc] init]; - debugMeta.debugID = info.UUID; + debugMeta.debugID = info.uuid; debugMeta.type = SentryDebugImageType; if (info.vmAddress > 0) { diff --git a/Sources/Sentry/SentryDependencyContainer.m b/Sources/Sentry/SentryDependencyContainer.m index 69a50a0a652..e7dfebd4b1c 100644 --- a/Sources/Sentry/SentryDependencyContainer.m +++ b/Sources/Sentry/SentryDependencyContainer.m @@ -1,7 +1,6 @@ #import "SentryANRTrackerV1.h" #import "SentryApplication.h" -#import "SentryBinaryImageCache.h" #import "SentryDefaultObjCRuntimeWrapper.h" #import "SentryDispatchFactory.h" #import "SentryDisplayLinkWrapper.h" diff --git a/Sources/Sentry/SentrySDKInternal.m b/Sources/Sentry/SentrySDKInternal.m index 926309679c5..81d82a0d1b5 100644 --- a/Sources/Sentry/SentrySDKInternal.m +++ b/Sources/Sentry/SentrySDKInternal.m @@ -3,7 +3,6 @@ #import "SentryANRTrackingIntegration.h" #import "SentryAppStartMeasurement.h" #import "SentryAppStateManager.h" -#import "SentryBinaryImageCache.h" #import "SentryBreadcrumb.h" #import "SentryClient+Private.h" #import "SentryCrash.h" @@ -287,7 +286,9 @@ + (void)startWithOptions:(SentryOptions *)options [SentrySDKInternal setCurrentHub:hub]; [SentryCrashWrapper.sharedInstance startBinaryImageCache]; - [SentryDependencyContainer.sharedInstance.binaryImageCache start:options.debug]; + [SentryDependencyContainer.sharedInstance.binaryImageCache + start:options.debug + dispatchQueueWrapper:SentryDependencyContainer.sharedInstance.dispatchQueueWrapper]; [SentrySDKInternal installIntegrations]; diff --git a/Sources/Sentry/SentryUIViewControllerSwizzling.m b/Sources/Sentry/SentryUIViewControllerSwizzling.m index a52e1305afb..40de39cf2a5 100644 --- a/Sources/Sentry/SentryUIViewControllerSwizzling.m +++ b/Sources/Sentry/SentryUIViewControllerSwizzling.m @@ -2,7 +2,6 @@ #if SENTRY_HAS_UIKIT -# import "SentryBinaryImageCache.h" # import "SentryDefaultObjCRuntimeWrapper.h" # import "SentryDefines.h" # import "SentryDependencyContainer.h" diff --git a/Sources/Sentry/include/HybridPublic/SentryBinaryImageCache.h b/Sources/Sentry/include/HybridPublic/SentryBinaryImageCache.h deleted file mode 100644 index e4f7b05ce4a..00000000000 --- a/Sources/Sentry/include/HybridPublic/SentryBinaryImageCache.h +++ /dev/null @@ -1,35 +0,0 @@ -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface SentryBinaryImageInfo : NSObject -@property (nonatomic, strong) NSString *name; -@property (nonatomic, copy) NSString *UUID; -@property (nonatomic) uint64_t vmAddress; -@property (nonatomic) uint64_t address; -@property (nonatomic) uint64_t size; - -@end - -/** - * This class listens to `SentryCrashBinaryImageCache` to keep a copy of the loaded binaries - * information in a sorted collection that will be used to symbolicate frames with better - * performance. - */ -@interface SentryBinaryImageCache : NSObject - -- (void)start:(BOOL)isDebug; - -- (void)stop; - -- (NSArray *)getAllBinaryImages; - -- (nullable SentryBinaryImageInfo *)imageByAddress:(const uint64_t)address; - -- (NSSet *)imagePathsForInAppInclude:(NSString *)inAppInclude; - -+ (NSString *_Nullable)convertUUID:(const unsigned char *const)value; - -@end - -NS_ASSUME_NONNULL_END diff --git a/Sources/Sentry/include/HybridPublic/SentryBinaryImageCacheCallbacks.h b/Sources/Sentry/include/HybridPublic/SentryBinaryImageCacheCallbacks.h new file mode 100644 index 00000000000..4b09f29d90a --- /dev/null +++ b/Sources/Sentry/include/HybridPublic/SentryBinaryImageCacheCallbacks.h @@ -0,0 +1,6 @@ +#import "SentryCrashDynamicLinker.h" +#import + +void binaryImageWasAdded(const SentryCrashBinaryImage *_Nullable image); + +void binaryImageWasRemoved(const SentryCrashBinaryImage *_Nullable image); diff --git a/Sources/Sentry/include/SentryPrivate.h b/Sources/Sentry/include/SentryPrivate.h index ee4cf848f58..5af46a02d3e 100644 --- a/Sources/Sentry/include/SentryPrivate.h +++ b/Sources/Sentry/include/SentryPrivate.h @@ -1,7 +1,11 @@ // Sentry internal headers that are needed for swift code; you cannot import headers that depend on // public interfaces here #import "NSLocale+Sentry.h" +#import "SentryBinaryImageCacheCallbacks.h" +#import "SentryCrashBinaryImageCache.h" +#import "SentryCrashDynamicLinker.h" #import "SentryCrashExceptionApplicationHelper.h" +#import "SentryCrashUUIDConversion.h" #import "SentryEventSwiftHelper.h" #import "SentryNSDataUtils.h" #import "SentryObjCRuntimeWrapper.h" diff --git a/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift b/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift new file mode 100644 index 00000000000..c2475ee8b95 --- /dev/null +++ b/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift @@ -0,0 +1,182 @@ +@_implementationOnly import _SentryPrivate +import Foundation + +@objc(SentryBinaryImageInfo) +public class SentryBinaryImageInfo: NSObject { + @objc public var name: String + @objc public var uuid: String? + @objc public var vmAddress: UInt64 + @objc public var address: UInt64 + @objc public var size: UInt64 + + @objc public init(name: String, uuid: String?, vmAddress: UInt64, address: UInt64, size: UInt64) { + self.name = name + self.uuid = uuid + self.vmAddress = vmAddress + self.address = address + self.size = size + super.init() + } +} + +/** + * This class listens to `SentryCrashBinaryImageCache` to keep a copy of the loaded binaries + * information in a sorted collection that will be used to symbolicate frames with better + * performance. + */ +@objc(SentryBinaryImageCache) +public class SentryBinaryImageCache: NSObject { + @objc public internal(set) var cache: [SentryBinaryImageInfo]? + private var isDebug: Bool = false + // Use a recursive lock to allow the same thread to enter again + private let lock = NSRecursiveLock() + private var dispatchQueueWrapper: SentryDispatchQueueWrapper! + + @objc public override init() { + self.isDebug = false + } + + @_spi(Private) @objc public func start(_ isDebug: Bool, dispatchQueueWrapper: SentryDispatchQueueWrapper) { + lock.synchronized { + self.isDebug = isDebug + self.cache = [] + self.dispatchQueueWrapper = dispatchQueueWrapper + sentrycrashbic_registerAddedCallback(binaryImageWasAdded) + sentrycrashbic_registerRemovedCallback(binaryImageWasRemoved) + } + } + + @objc public func stop() { + lock.synchronized { + sentrycrashbic_registerAddedCallback(nil) + sentrycrashbic_registerRemovedCallback(nil) + self.cache = nil + } + } + + // We have to expand `SentryCrashBinaryImage` since the model is defined in SentryPrivate + @objc(binaryImageAdded:vmAddress:address:size:uuid:) + public func binaryImageAdded(imageName: UnsafePointer?, + vmAddress: UInt64, + address: UInt64, + size: UInt64, + uuid: UnsafePointer?) { + guard let imageName else { + SentrySDKLog.warning("The image name was NULL. Can't add image to cache.") + return + } + guard let nameString = String(cString: imageName, encoding: .utf8) else { + SentrySDKLog.warning("Couldn't convert the cString image name to an NSString. This could be due to a different encoding than NSUTF8StringEncoding of the cString..") + return + } + + let newImage = SentryBinaryImageInfo( + name: nameString, + uuid: Self.convertUUID(uuid), + vmAddress: vmAddress, + address: address, + size: size + ) + + lock.synchronized { + guard let cache = self.cache else { return } + + // Binary search insertion to maintain sorted order by address + var left = 0 + var right = cache.count + + while left < right { + let mid = (left + right) / 2 + let compareImage = cache[mid] + if newImage.address < compareImage.address { + right = mid + } else { + left = mid + 1 + } + } + + self.cache?.insert(newImage, at: left) + } + + if isDebug { + // This validation adds some overhead with each class present in the image, so we only + // run this when debug is enabled. A non main queue is used to avoid affecting the UI. + LoadValidator.checkForDuplicatedSDK(imageName: nameString, + imageAddress: NSNumber(value: newImage.address), + imageSize: NSNumber(value: newImage.size), + dispatchQueueWrapper: dispatchQueueWrapper) + } + } + + @objc + public static func convertUUID(_ value: UnsafePointer?) -> String? { + guard let value = value else { return nil } + + var uuidBuffer = [CChar](repeating: 0, count: 37) + sentrycrashdl_convertBinaryImageUUID(value, &uuidBuffer) + return String(cString: uuidBuffer) + } + + @objc + public func binaryImageRemoved(_ imageAddress: UInt64) { + lock.synchronized { + guard let index = indexOfImage(address: imageAddress), index >= 0 else { return } + self.cache?.remove(at: index) + } + } + + @objc + public func imageByAddress(_ address: UInt64) -> SentryBinaryImageInfo? { + lock.synchronized { + guard let index = indexOfImage(address: address), index >= 0 else { return nil } + return cache?[index] + } + } + + private func indexOfImage(address: UInt64) -> Int? { + guard let cache = self.cache else { return nil } + + var left = 0 + var right = cache.count - 1 + + while left <= right { + let mid = (left + right) / 2 + let image = cache[mid] + + if address >= image.address && address < (image.address + image.size) { + return mid + } else if address < image.address { + right = mid - 1 + } else { + left = mid + 1 + } + } + + return -1 // Address not found + } + + @objc(imagePathsForInAppInclude:) + public func imagePathsFor(inAppInclude: String) -> Set { + var imagePaths = Set() + + imagePaths = lock.synchronized { + guard let cache = self.cache else { return imagePaths } + + for info in cache { + if SentryInAppLogic.isImageNameInApp(info.name, inAppInclude: inAppInclude) { + imagePaths.insert(info.name) + } + } + return imagePaths + } + + return imagePaths + } + + @objc + public func getAllBinaryImages() -> [SentryBinaryImageInfo] { + lock.synchronized { + return cache ?? [] + } + } +} diff --git a/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerSwizzlingTests.swift b/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerSwizzlingTests.swift index 98654561b1d..707be20da5b 100644 --- a/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerSwizzlingTests.swift +++ b/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerSwizzlingTests.swift @@ -204,9 +204,14 @@ class SentryUIViewControllerSwizzlingTests: XCTestCase { let debugDylib = "\(imageName).debug.dylib" - var image = createCrashBinaryImage(0, name: debugDylib) - SentryDependencyContainer.sharedInstance().binaryImageCache.start(false) - SentryDependencyContainer.sharedInstance().binaryImageCache.binaryImageAdded(&image) + let image = createCrashBinaryImage(0, name: debugDylib) + let dispatchQueueWrapper = TestSentryDispatchQueueWrapper() + SentryDependencyContainer.sharedInstance().binaryImageCache.start(false, dispatchQueueWrapper: dispatchQueueWrapper) + SentryDependencyContainer.sharedInstance().binaryImageCache.binaryImageAdded(imageName: image.name, + vmAddress: image.vmAddress, + address: image.address, + size: image.size, + uuid: image.uuid) let sut = fixture.sut sut.start() diff --git a/Tests/SentryTests/SentryBinaryImageCache+Private.h b/Tests/SentryTests/SentryBinaryImageCache+Private.h deleted file mode 100644 index 699ecfd0552..00000000000 --- a/Tests/SentryTests/SentryBinaryImageCache+Private.h +++ /dev/null @@ -1,12 +0,0 @@ -#import "SentryBinaryImageCache.h" -#import "SentryCrashBinaryImageCache.h" - -@interface SentryBinaryImageCache () - -@property (nonatomic, strong) NSArray *cache; - -- (void)binaryImageAdded:(const SentryCrashBinaryImage *)image; - -- (void)binaryImageRemoved:(const SentryCrashBinaryImage *)image; - -@end diff --git a/Tests/SentryTests/SentryBinaryImageCacheTests.swift b/Tests/SentryTests/SentryBinaryImageCacheTests.swift index 5ccd5e16385..cc24376fc2c 100644 --- a/Tests/SentryTests/SentryBinaryImageCacheTests.swift +++ b/Tests/SentryTests/SentryBinaryImageCacheTests.swift @@ -1,4 +1,5 @@ -import SentryTestUtils +@_spi(Private) @testable import Sentry +@_spi(Private) import SentryTestUtils import XCTest class SentryBinaryImageCacheTests: XCTestCase { @@ -8,119 +9,132 @@ class SentryBinaryImageCacheTests: XCTestCase { override func setUp() { super.setUp() - sut.start(false) + let dispatchQueueWrapper = TestSentryDispatchQueueWrapper() + sut.start(false, dispatchQueueWrapper: dispatchQueueWrapper) } override func tearDown() { sut.stop() super.tearDown() } + + private func addBinaryImageToSut(_ binaryImage: SentryCrashBinaryImage) { + sut.binaryImageAdded(imageName: binaryImage.name, + vmAddress: binaryImage.vmAddress, + address: binaryImage.address, + size: binaryImage.size, + uuid: binaryImage.uuid) + } func testBinaryImageAdded() { - var binaryImage0 = createCrashBinaryImage(0, vmAddress: 0) - var binaryImage1 = createCrashBinaryImage(100, vmAddress: 100) - var binaryImage2 = createCrashBinaryImage(200, vmAddress: 200) - var binaryImage3 = createCrashBinaryImage(400, vmAddress: 400) - sut.binaryImageAdded(&binaryImage1) - - XCTAssertEqual(sut.cache.count, 1) - XCTAssertEqual(sut.cache.first?.name, "Expected Name at 100") - XCTAssertEqual(sut.cache.first?.uuid, "84BAEBDA-AD1A-33F4-B35D-8A45F5DAF322") - XCTAssertEqual(sut.cache.first?.vmAddress, 100) - - sut.binaryImageAdded(&binaryImage3) - XCTAssertEqual(sut.cache.count, 2) - XCTAssertEqual(sut.cache.last?.name, "Expected Name at 400") - XCTAssertEqual(sut.cache.last?.uuid, "84BAEBDA-AD1A-33F4-B35D-8A45F5DAF322") - XCTAssertEqual(sut.cache.last?.vmAddress, 400) - - sut.binaryImageAdded(&binaryImage2) - XCTAssertEqual(sut.cache.count, 3) - XCTAssertEqual(sut.cache.first?.name, "Expected Name at 100") - XCTAssertEqual(try XCTUnwrap(sut.cache.element(at: 1)).name, "Expected Name at 200") - XCTAssertEqual(sut.cache.last?.name, "Expected Name at 400") - - sut.binaryImageAdded(&binaryImage0) - XCTAssertEqual(sut.cache.count, 4) - XCTAssertEqual(sut.cache.first?.name, "Expected Name at 0") - XCTAssertEqual(try XCTUnwrap(sut.cache.element(at: 1)).name, "Expected Name at 100") + let binaryImage0 = createCrashBinaryImage(0, vmAddress: 0) + let binaryImage1 = createCrashBinaryImage(100, vmAddress: 100) + let binaryImage2 = createCrashBinaryImage(200, vmAddress: 200) + let binaryImage3 = createCrashBinaryImage(400, vmAddress: 400) + addBinaryImageToSut(binaryImage1) + + XCTAssertEqual(sut.cache?.count, 1) + XCTAssertEqual(sut.cache?.first?.name, "Expected Name at 100") + XCTAssertEqual(sut.cache?.first?.uuid, "84BAEBDA-AD1A-33F4-B35D-8A45F5DAF322") + XCTAssertEqual(sut.cache?.first?.vmAddress, 100) + + addBinaryImageToSut(binaryImage3) + XCTAssertEqual(sut.cache?.count, 2) + XCTAssertEqual(sut.cache?.last?.name, "Expected Name at 400") + XCTAssertEqual(sut.cache?.last?.uuid, "84BAEBDA-AD1A-33F4-B35D-8A45F5DAF322") + XCTAssertEqual(sut.cache?.last?.vmAddress, 400) + + addBinaryImageToSut(binaryImage2) + XCTAssertEqual(sut.cache?.count, 3) + XCTAssertEqual(sut.cache?.first?.name, "Expected Name at 100") + XCTAssertEqual(try XCTUnwrap(sut.cache?.element(at: 1)).name, "Expected Name at 200") + XCTAssertEqual(sut.cache?.last?.name, "Expected Name at 400") + + addBinaryImageToSut(binaryImage0) + XCTAssertEqual(sut.cache?.count, 4) + XCTAssertEqual(sut.cache?.first?.name, "Expected Name at 0") + XCTAssertEqual(try XCTUnwrap(sut.cache?.element(at: 1)).name, "Expected Name at 100") } - func testBinaryImageAdded_IsNull() { - sut.binaryImageAdded(nil) + func testBinaryImageAdded_WithNilName() { + sut.binaryImageAdded(imageName: nil, + vmAddress: 100, + address: 1_000, + size: 100, + uuid: nil) - XCTAssertEqual(self.sut.cache.count, 0) + XCTAssertEqual(self.sut.cache?.count, 0) } func testBinaryImageRemoved() { - var binaryImage0 = createCrashBinaryImage(0) - var binaryImage1 = createCrashBinaryImage(100) - var binaryImage2 = createCrashBinaryImage(200) - var binaryImage3 = createCrashBinaryImage(400) - - sut.binaryImageAdded(&binaryImage1) - sut.binaryImageAdded(&binaryImage3) - sut.binaryImageAdded(&binaryImage2) - sut.binaryImageAdded(&binaryImage0) - XCTAssertEqual(sut.cache.count, 4) - - XCTAssertEqual(sut.image(byAddress: 150)?.name, "Expected Name at 100") - sut.binaryImageRemoved(&binaryImage1) - XCTAssertEqual(sut.cache.count, 3) - XCTAssertNil(sut.image(byAddress: 100)) - - XCTAssertEqual(sut.image(byAddress: 450)?.name, "Expected Name at 400") - sut.binaryImageRemoved(&binaryImage3) - XCTAssertEqual(sut.cache.count, 2) - XCTAssertNil(sut.image(byAddress: 400)) - - XCTAssertEqual(sut.image(byAddress: 0)?.name, "Expected Name at 0") - sut.binaryImageRemoved(&binaryImage0) - XCTAssertEqual(sut.cache.count, 1) - XCTAssertNil(sut.image(byAddress: 0)) - - XCTAssertEqual(sut.image(byAddress: 200)?.name, "Expected Name at 200") - sut.binaryImageRemoved(&binaryImage2) - XCTAssertEqual(sut.cache.count, 0) - XCTAssertNil(sut.image(byAddress: 240)) + let binaryImage0 = createCrashBinaryImage(0) + let binaryImage1 = createCrashBinaryImage(100) + let binaryImage2 = createCrashBinaryImage(200) + let binaryImage3 = createCrashBinaryImage(400) + + addBinaryImageToSut(binaryImage1) + addBinaryImageToSut(binaryImage3) + addBinaryImageToSut(binaryImage2) + addBinaryImageToSut(binaryImage0) + XCTAssertEqual(sut.cache?.count, 4) + + XCTAssertEqual(sut.imageByAddress(150)?.name, "Expected Name at 100") + sut.binaryImageRemoved(binaryImage1.address) + XCTAssertEqual(sut.cache?.count, 3) + XCTAssertNil(sut.imageByAddress(100)) + + XCTAssertEqual(sut.imageByAddress(450)?.name, "Expected Name at 400") + sut.binaryImageRemoved(binaryImage3.address) + XCTAssertEqual(sut.cache?.count, 2) + XCTAssertNil(sut.imageByAddress(400)) + + XCTAssertEqual(sut.imageByAddress(0)?.name, "Expected Name at 0") + sut.binaryImageRemoved(binaryImage0.address) + XCTAssertEqual(sut.cache?.count, 1) + XCTAssertNil(sut.imageByAddress(0)) + + XCTAssertEqual(sut.imageByAddress(200)?.name, "Expected Name at 200") + sut.binaryImageRemoved(binaryImage2.address) + XCTAssertEqual(sut.cache?.count, 0) + XCTAssertNil(sut.imageByAddress(240)) } - func testBinaryImageRemoved_IsNull() { - var binaryImage = createCrashBinaryImage(0) - sut.binaryImageAdded(&binaryImage) + func testBinaryImageRemoved_InvalidAddress() { + let binaryImage = createCrashBinaryImage(0) + addBinaryImageToSut(binaryImage) - sut.binaryImageRemoved(nil) + sut.binaryImageRemoved(1_000_000) - XCTAssertEqual(self.sut.cache.count, 1) + XCTAssertEqual(self.sut.cache?.count, 1) } func testImageNameByAddress() { - var binaryImage0 = createCrashBinaryImage(0) - var binaryImage1 = createCrashBinaryImage(100) - var binaryImage2 = createCrashBinaryImage(200) - var binaryImage3 = createCrashBinaryImage(400) - - sut.binaryImageAdded(&binaryImage1) - sut.binaryImageAdded(&binaryImage3) - sut.binaryImageAdded(&binaryImage2) - sut.binaryImageAdded(&binaryImage0) - - XCTAssertEqual(sut.image(byAddress: 150)?.name, "Expected Name at 100") - XCTAssertEqual(sut.image(byAddress: 0)?.name, "Expected Name at 0") - XCTAssertEqual(sut.image(byAddress: 10)?.name, "Expected Name at 0") - XCTAssertEqual(sut.image(byAddress: 99)?.name, "Expected Name at 0") - XCTAssertEqual(sut.image(byAddress: 200)?.name, "Expected Name at 200") - XCTAssertEqual(sut.image(byAddress: 299)?.name, "Expected Name at 200") - XCTAssertEqual(sut.image(byAddress: 400)?.name, "Expected Name at 400") - XCTAssertNil(sut.image(byAddress: 300)) - XCTAssertNil(sut.image(byAddress: 399)) + let binaryImage0 = createCrashBinaryImage(0) + let binaryImage1 = createCrashBinaryImage(100) + let binaryImage2 = createCrashBinaryImage(200) + let binaryImage3 = createCrashBinaryImage(400) + + addBinaryImageToSut(binaryImage1) + addBinaryImageToSut(binaryImage3) + addBinaryImageToSut(binaryImage2) + addBinaryImageToSut(binaryImage0) + + XCTAssertEqual(sut.imageByAddress(150)?.name, "Expected Name at 100") + XCTAssertEqual(sut.imageByAddress(0)?.name, "Expected Name at 0") + XCTAssertEqual(sut.imageByAddress(10)?.name, "Expected Name at 0") + XCTAssertEqual(sut.imageByAddress(99)?.name, "Expected Name at 0") + XCTAssertEqual(sut.imageByAddress(200)?.name, "Expected Name at 200") + XCTAssertEqual(sut.imageByAddress(299)?.name, "Expected Name at 200") + XCTAssertEqual(sut.imageByAddress(400)?.name, "Expected Name at 400") + XCTAssertNil(sut.imageByAddress(300)) + XCTAssertNil(sut.imageByAddress(399)) } func testImagePathByName() { - var binaryImage = createCrashBinaryImage(0) - var binaryImage2 = createCrashBinaryImage(1) - sut.binaryImageAdded(&binaryImage) - sut.binaryImageAdded(&binaryImage2) + let binaryImage = createCrashBinaryImage(0) + let binaryImage2 = createCrashBinaryImage(1) + addBinaryImageToSut(binaryImage) + addBinaryImageToSut(binaryImage2) let paths = sut.imagePathsFor(inAppInclude: "Expected Name at 0") XCTAssertEqual(paths.first, "Expected Name at 0") @@ -138,7 +152,7 @@ class SentryBinaryImageCacheTests: XCTestCase { func testBinaryImageWithNULLName_DoesNotAddImage() { let address = UInt64(100) - var binaryImage = SentryCrashBinaryImage( + let binaryImage = SentryCrashBinaryImage( address: address, vmAddress: 0, size: 100, @@ -150,9 +164,9 @@ class SentryBinaryImageCacheTests: XCTestCase { crashInfoMessage2: nil ) - sut.binaryImageAdded(&binaryImage) - XCTAssertNil(self.sut.image(byAddress: address)) - XCTAssertEqual(self.sut.cache.count, 0) + addBinaryImageToSut(binaryImage) + XCTAssertNil(self.sut.imageByAddress(address)) + XCTAssertEqual(self.sut.cache?.count, 0) } func testBinaryImageNameDifferentEncoding_DoesNotAddImage() { @@ -162,7 +176,7 @@ class SentryBinaryImageCacheTests: XCTestCase { let nameCString = name.cString(using: UInt(8)) let address = UInt64(100) - var binaryImage = SentryCrashBinaryImage( + let binaryImage = SentryCrashBinaryImage( address: address, vmAddress: 0, size: 100, @@ -174,9 +188,9 @@ class SentryBinaryImageCacheTests: XCTestCase { crashInfoMessage2: nil ) - sut.binaryImageAdded(&binaryImage) - XCTAssertNil(self.sut.image(byAddress: address)) - XCTAssertEqual(self.sut.cache.count, 0) + addBinaryImageToSut(binaryImage) + XCTAssertNil(self.sut.imageByAddress(address)) + XCTAssertEqual(self.sut.cache?.count, 0) } func testAddingImagesWhileStoppingAndStartingOnDifferentThread() { @@ -184,14 +198,15 @@ class SentryBinaryImageCacheTests: XCTestCase { let expectation = expectation(description: "Add images on background thread") expectation.expectedFulfillmentCount = count + let dispatchQueueWrapper = TestSentryDispatchQueueWrapper() for i in 0.. SentryCrashBinaryImage { - let imageName = name ?? "Expected Name at \(address)" - let nameCString = imageName.withCString { strdup($0) } - - var uuidPointer = UnsafeMutablePointer(nil) - let uuidAsCharArray: [UInt8] = [132, 186, 235, 218, 173, 26, 51, 244, 179, 93, 138, 69, 245, 218, 243, 34] - uuidPointer = UnsafeMutablePointer.allocate(capacity: uuidAsCharArray.count) - uuidPointer?.initialize(from: uuidAsCharArray, count: uuidAsCharArray.count) - - let binaryImage = SentryCrashBinaryImage( - address: UInt64(address), - vmAddress: vmAddress, - size: 100, - name: nameCString, - uuid: uuidPointer, - cpuType: 1, - cpuSubType: 1, - crashInfoMessage: nil, - crashInfoMessage2: nil - ) - - return binaryImage + let imageName = name ?? "Expected Name at \(address)" + let nameCString = imageName.withCString { strdup($0) } + + var uuidPointer = UnsafeMutablePointer(nil) + let uuidAsCharArray: [UInt8] = [132, 186, 235, 218, 173, 26, 51, 244, 179, 93, 138, 69, 245, 218, 243, 34] + uuidPointer = UnsafeMutablePointer.allocate(capacity: uuidAsCharArray.count) + uuidPointer?.initialize(from: uuidAsCharArray, count: uuidAsCharArray.count) + + let binaryImage = SentryCrashBinaryImage( + address: UInt64(address), + vmAddress: vmAddress, + size: 100, + name: nameCString, + uuid: uuidPointer, + cpuType: 1, + cpuSubType: 1, + crashInfoMessage: nil, + crashInfoMessage2: nil + ) + + return binaryImage } diff --git a/Tests/SentryTests/SentryCrash/SentryBinaryImageCacheTests.m b/Tests/SentryTests/SentryCrash/SentryCrashBinaryImageCacheTests.m similarity index 89% rename from Tests/SentryTests/SentryCrash/SentryBinaryImageCacheTests.m rename to Tests/SentryTests/SentryCrash/SentryCrashBinaryImageCacheTests.m index 2fdd1f9aacf..4a9f63f9cef 100644 --- a/Tests/SentryTests/SentryCrash/SentryBinaryImageCacheTests.m +++ b/Tests/SentryTests/SentryCrash/SentryCrashBinaryImageCacheTests.m @@ -1,4 +1,3 @@ -#import "SentryBinaryImageCache+Private.h" #import "SentryCrashBinaryImageCache.h" #import "SentryCrashDynamicLinker+Test.h" #import "SentryCrashWrapper.h" @@ -279,31 +278,6 @@ - (void)testCloseCacheWhileAdding XCTAssertEqual(result, 0); } -// Adding a SentryBinaryImageCache test inside -// SentryCrashBinaryImageCache to test integration between both -// because is easier to control SentryCrashBinaryImageCache in an objc test -- (void)testSentryBinaryImageCacheIntegration -{ - sentrycrashbic_startCache(); - - SentryBinaryImageCache *imageCache = SentryDependencyContainer.sharedInstance.binaryImageCache; - [imageCache start:false]; - // by calling start, SentryBinaryImageCache will register a callback with - // `SentryCrashBinaryImageCache` that should be called for every image already cached. - XCTAssertEqual(5, imageCache.cache.count); - - addBinaryImage([mach_headers_test_cache[5] pointerValue], 0); - XCTAssertEqual(6, imageCache.cache.count); - - removeBinaryImage([mach_headers_expect_array[1] pointerValue], 0); - removeBinaryImage([mach_headers_expect_array[2] pointerValue], 0); - XCTAssertEqual(4, imageCache.cache.count); - [imageCache stop]; - - addBinaryImage([mach_headers_test_cache[6] pointerValue], 0); - XCTAssertNil(imageCache.cache); -} - - (void)assertBinaryImageCacheLength:(int)expected { int counter = 0; diff --git a/Tests/SentryTests/SentryCrash/SentryCrashBinaryImageCacheTests.swift b/Tests/SentryTests/SentryCrash/SentryCrashBinaryImageCacheTests.swift new file mode 100644 index 00000000000..0227ed28f03 --- /dev/null +++ b/Tests/SentryTests/SentryCrash/SentryCrashBinaryImageCacheTests.swift @@ -0,0 +1,348 @@ +import MachO +@_spi(Private) @testable import Sentry +@_spi(Private) @testable import SentryTestUtils +import XCTest + +// Import C functions from the SentryCrashBinaryImageCache +// These are test-only functions exposed from the implementation +@_silgen_name("sentry_setRegisterFuncForAddImage") +func sentry_setRegisterFuncForAddImage(_ addFunction: UnsafeMutableRawPointer?) + +@_silgen_name("sentry_setRegisterFuncForRemoveImage") +func sentry_setRegisterFuncForRemoveImage(_ removeFunction: UnsafeMutableRawPointer?) + +@_silgen_name("sentry_resetFuncForAddRemoveImage") +func sentry_resetFuncForAddRemoveImage() + +@_silgen_name("sentry_setFuncForBeforeAdd") +func sentry_setFuncForBeforeAdd(_ callback: (@convention(c) () -> Void)?) + +@_silgen_name("sentrycrashbic_iterateOverImages") +func sentrycrashbic_iterateOverImages(_ callback: (@convention(c) (UnsafeMutablePointer, UnsafeMutableRawPointer?) -> Void)?, _ context: UnsafeMutableRawPointer?) + +@_silgen_name("sentrycrashdl_clearDyld") +func sentrycrashdl_clearDyld() + +// Global variables to mirror the Objective-C implementation +private var addBinaryImageFunc: (@convention(c) (UnsafePointer?, Int) -> Void)? +private var removeBinaryImageFunc: (@convention(c) (UnsafePointer?, Int) -> Void)? +private var machHeadersTestCache: [UnsafeRawPointer] = [] +private var machHeadersExpectArray: [UnsafeRawPointer] = [] + +// Semaphores for testing parallel operations +private var delaySemaphore: DispatchSemaphore? +private var delayCalled: DispatchSemaphore? + +// C callback functions +private let sentryRegisterFuncForAddImage: @convention(c) ((@convention(c) (UnsafePointer?, Int) -> Void)?) -> Void = +{ function in + addBinaryImageFunc = function + + if !machHeadersExpectArray.isEmpty { + // Skip first item which is dyld and already included when starting the cache + for i in 1..?, Int) -> Void)?) -> Void = { function in + removeBinaryImageFunc = function +} + +private let cacheMachHeaders: @convention(c) (UnsafePointer?, Int) -> Void = { mh, _ in + guard let mh = mh else { return } + machHeadersTestCache.append(UnsafeRawPointer(mh)) +} + +private let countNumberOfImagesInCache: @convention(c) (UnsafeMutablePointer, UnsafeMutableRawPointer?) -> Void = { _, context in + guard let context = context else { return } + let counter = context.assumingMemoryBound(to: Int.self) + counter.pointee += 1 +} + +private let addBinaryImageToArray: @convention(c) (UnsafeMutablePointer, UnsafeMutableRawPointer?) -> Void = { image, context in + guard let context = context else { return } + let array = Unmanaged.fromOpaque(context).takeUnretainedValue() + array.add(NSValue(pointer: image)) +} + +private let delayAddBinaryImage: @convention(c) () -> Void = { + if let delayCalled = delayCalled { + delayCalled.signal() + } + if let delaySemaphore = delaySemaphore { + delaySemaphore.wait() + } +} + +class SentryCrashBinaryImageCacheTests: XCTestCase { + + override class func setUp() { + super.setUp() + // Create a test cache of actual binary images to be used during tests + machHeadersTestCache = [] + + // Manually include dyld + sentrycrashdl_initialize() + if let dyldHeader = sentryDyldHeader { + machHeadersTestCache.append(UnsafeRawPointer(dyldHeader)) + } + _dyld_register_func_for_add_image(cacheMachHeaders) + } + + override func setUp() { + super.setUp() + sentry_setRegisterFuncForAddImage(unsafeBitCast(sentryRegisterFuncForAddImage, to: UnsafeMutableRawPointer.self)) + sentry_setRegisterFuncForRemoveImage(unsafeBitCast(sentryRegisterFuncForRemoveImage, to: UnsafeMutableRawPointer.self)) + + // Copy the first 5 images from the temporary list + // 5 is a magic number from the original implementation + let endIndex = min(5, machHeadersTestCache.count) + machHeadersExpectArray = Array(machHeadersTestCache[0.. 5 { + let header = machHeadersTestCache[5].assumingMemoryBound(to: mach_header.self) + addBinaryImageFunc?(header, 0) + machHeadersExpectArray = Array(machHeadersTestCache[0..<6]) + assertBinaryImageCacheLength(6) + assertCachedBinaryImages() + } + + if machHeadersTestCache.count > 6 { + let header = machHeadersTestCache[6].assumingMemoryBound(to: mach_header.self) + addBinaryImageFunc?(header, 0) + machHeadersExpectArray = Array(machHeadersTestCache[0..<7]) + assertBinaryImageCacheLength(7) + assertCachedBinaryImages() + } + } + + func testAddInvalidHeader() { + sentrycrashbic_startCache() + assertBinaryImageCacheLength(5) + + addBinaryImageFunc?(nil, 0) + assertBinaryImageCacheLength(5) + } + + func testAddNewImageAfterStopping() { + sentrycrashbic_startCache() + assertBinaryImageCacheLength(5) + + sentrycrashbic_stopCache() + if machHeadersTestCache.count > 6 { + let header = machHeadersTestCache[6].assumingMemoryBound(to: mach_header.self) + addBinaryImageFunc?(header, 0) + } + assertBinaryImageCacheLength(0) + } + + func testRemoveImageFromTail() { + sentrycrashbic_startCache() + assertBinaryImageCacheLength(5) + + let header4 = machHeadersExpectArray[4].assumingMemoryBound(to: mach_header.self) + removeBinaryImageFunc?(header4, 0) + assertBinaryImageCacheLength(4) + assertCachedBinaryImages() + + let header3 = machHeadersExpectArray[3].assumingMemoryBound(to: mach_header.self) + removeBinaryImageFunc?(header3, 0) + assertBinaryImageCacheLength(3) + assertCachedBinaryImages() + } + + func testRemoveImageFromBeginning() { + sentrycrashbic_startCache() + assertBinaryImageCacheLength(5) + + let header0 = machHeadersExpectArray[0].assumingMemoryBound(to: mach_header.self) + removeBinaryImageFunc?(header0, 0) + assertBinaryImageCacheLength(4) + machHeadersExpectArray.removeFirst() + assertCachedBinaryImages() + + let newHeader0 = machHeadersExpectArray[0].assumingMemoryBound(to: mach_header.self) + removeBinaryImageFunc?(newHeader0, 0) + assertBinaryImageCacheLength(3) + machHeadersExpectArray.removeFirst() + assertCachedBinaryImages() + } + + func testRemoveImageAddAgain() { + // Use index 1 since we can't dynamically insert dyld image (`dladdr` returns null) + let indexToRemove = 1 + + sentrycrashbic_startCache() + assertBinaryImageCacheLength(5) + + let headerToRemove = machHeadersExpectArray[indexToRemove].assumingMemoryBound(to: mach_header.self) + removeBinaryImageFunc?(headerToRemove, 0) + assertBinaryImageCacheLength(4) + + let removeItem = machHeadersExpectArray[indexToRemove] + machHeadersExpectArray.remove(at: indexToRemove) + assertCachedBinaryImages() + + addBinaryImageFunc?(removeItem.assumingMemoryBound(to: mach_header.self), 0) + assertBinaryImageCacheLength(5) + machHeadersExpectArray.insert(removeItem, at: 4) + assertCachedBinaryImages() + } + + func testAddBinaryImageInParallel() { + sentrycrashbic_startCache() + let queue = DispatchQueue.global(qos: .default) + + // Guard against underflow when machHeadersTestCache.count < 5 + let taskCount = machHeadersTestCache.count - 5 + guard taskCount > 0 else { + XCTFail("Expected a positive task count, but got \(taskCount)") + return + } + + let expectation = self.expectation(description: "Add binary images in parallel") + expectation.expectedFulfillmentCount = taskCount + + for i in 5.. 6 { + let header = machHeadersTestCache[6].assumingMemoryBound(to: mach_header.self) + addBinaryImageFunc?(header, 0) + } + } + + let result = delayCalled?.wait(timeout: .now() + 5) + sentrycrashbic_stopCache() + delaySemaphore?.signal() + assertBinaryImageCacheLength(0) + XCTAssertEqual(result, .success) + } + + // Adding a SentryBinaryImageCache test inside SentryCrashBinaryImageCache to test integration + // The test is in Swift because of some classes are not available to Objective-C + func testSentryBinaryImageCacheIntegration() { + sentrycrashbic_startCache() + + let imageCache = SentryDependencyContainer.sharedInstance().binaryImageCache + let dispatchQueueWrapper = TestSentryDispatchQueueWrapper() + imageCache.start(false, dispatchQueueWrapper: dispatchQueueWrapper) + // By calling start, SentryBinaryImageCache will register a callback with + // `SentryCrashBinaryImageCache` that should be called for every image already cached. + XCTAssertEqual(5, imageCache.cache?.count ?? 0) + + if machHeadersTestCache.count > 5 { + let header = machHeadersTestCache[5].assumingMemoryBound(to: mach_header.self) + addBinaryImageFunc?(header, 0) + XCTAssertEqual(6, imageCache.cache?.count ?? 0) + } + + if machHeadersExpectArray.count > 1 { + let header1 = machHeadersExpectArray[1].assumingMemoryBound(to: mach_header.self) + removeBinaryImageFunc?(header1, 0) + } + + if machHeadersExpectArray.count > 2 { + let header2 = machHeadersExpectArray[2].assumingMemoryBound(to: mach_header.self) + removeBinaryImageFunc?(header2, 0) + } + + XCTAssertEqual(4, imageCache.cache?.count ?? 0) + imageCache.stop() + + if machHeadersTestCache.count > 6 { + let header = machHeadersTestCache[6].assumingMemoryBound(to: mach_header.self) + addBinaryImageFunc?(header, 0) + } + XCTAssertNil(imageCache.cache) + } + + // MARK: - Helper Methods + + private func assertBinaryImageCacheLength(_ expected: Int) { + var counter = 0 + withUnsafeMutablePointer(to: &counter) { counterPtr in + sentrycrashbic_iterateOverImages(countNumberOfImagesInCache, UnsafeMutableRawPointer(counterPtr)) + } + XCTAssertEqual(counter, expected) + } + + private func assertCachedBinaryImages() { + let cached = binaryImageCacheToArray() + for i in 0.. NSArray { + let result = NSMutableArray() + let unmanagedArray = Unmanaged.passUnretained(result) + sentrycrashbic_iterateOverImages(addBinaryImageToArray, unmanagedArray.toOpaque()) + return result + } +} diff --git a/Tests/SentryTests/SentryCrash/SentryCrashStackEntryMapperTests.swift b/Tests/SentryTests/SentryCrash/SentryCrashStackEntryMapperTests.swift index 8f4d6fadee9..c95fb067d33 100644 --- a/Tests/SentryTests/SentryCrash/SentryCrashStackEntryMapperTests.swift +++ b/Tests/SentryTests/SentryCrash/SentryCrashStackEntryMapperTests.swift @@ -1,5 +1,5 @@ @_spi(Private) @testable import Sentry -import SentryTestUtils +@_spi(Private) import SentryTestUtils import XCTest /** Some of the test parameters are copied during debbuging a working implementation. @@ -86,9 +86,14 @@ class SentryCrashStackEntryMapperTests: XCTestCase { } func testImageFromCache() { - var image = createCrashBinaryImage(2_488_998_912) - SentryDependencyContainer.sharedInstance().binaryImageCache.start(false) - SentryDependencyContainer.sharedInstance().binaryImageCache.binaryImageAdded(&image) + let image = createCrashBinaryImage(2_488_998_912) + let dispatchQueueWrapper = TestSentryDispatchQueueWrapper() + SentryDependencyContainer.sharedInstance().binaryImageCache.start(false, dispatchQueueWrapper: dispatchQueueWrapper) + SentryDependencyContainer.sharedInstance().binaryImageCache.binaryImageAdded(imageName: image.name, + vmAddress: image.vmAddress, + address: image.address, + size: image.size, + uuid: image.uuid) var cursor = SentryCrashStackCursor() cursor.stackEntry.address = 2_488_998_950 diff --git a/Tests/SentryTests/SentryCrash/SentryDebugImageProviderTests.swift b/Tests/SentryTests/SentryCrash/SentryDebugImageProviderTests.swift index 01d6868e820..eddfb69174e 100644 --- a/Tests/SentryTests/SentryCrash/SentryDebugImageProviderTests.swift +++ b/Tests/SentryTests/SentryCrash/SentryDebugImageProviderTests.swift @@ -1,4 +1,5 @@ -@testable import Sentry +@_spi(Private) @testable import Sentry +@_spi(Private) @testable import SentryTestUtils import XCTest /** @@ -17,13 +18,17 @@ class SentryDebugImageProviderTests: XCTestCase { func getSut(images: [SentryCrashBinaryImage] = []) -> SentryDebugImageProvider { let imageProvider = TestSentryCrashBinaryImageProvider() + let dispatchQueueWrapper = TestSentryDispatchQueueWrapper() imageProvider.imageCount = images.count imageProvider.binaryImage = images - cache.start(false) + cache.start(false, dispatchQueueWrapper: dispatchQueueWrapper) for image in images { - var i = image - cache.binaryImageAdded(&i) + cache.binaryImageAdded(imageName: image.name, + vmAddress: image.vmAddress, + address: image.address, + size: image.size, + uuid: image.uuid) } return SentryDebugImageProvider(binaryImageProvider: imageProvider, binaryImageCache: cache) diff --git a/Tests/SentryTests/SentrySDKTests.swift b/Tests/SentryTests/SentrySDKTests.swift index d636f451c3b..b0f3adea26a 100644 --- a/Tests/SentryTests/SentrySDKTests.swift +++ b/Tests/SentryTests/SentrySDKTests.swift @@ -153,14 +153,15 @@ class SentrySDKTests: XCTestCase { } @available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated") - func testStartStopBinaryImageCache() { + func testStartStopBinaryImageCache() throws { SentrySDK.start { options in options.debug = true options.removeAllIntegrations() } XCTAssertNotNil(SentryDependencyContainer.sharedInstance().binaryImageCache.cache) - XCTAssertGreaterThan(SentryDependencyContainer.sharedInstance().binaryImageCache.cache.count, 0) + let cache = try XCTUnwrap(SentryDependencyContainer.sharedInstance().binaryImageCache.cache) + XCTAssertGreaterThan(cache.count, 0) SentrySDK.close() diff --git a/Tests/SentryTests/SentryTests-Bridging-Header.h b/Tests/SentryTests/SentryTests-Bridging-Header.h index c5913cf5957..e77d4257e5d 100644 --- a/Tests/SentryTests/SentryTests-Bridging-Header.h +++ b/Tests/SentryTests/SentryTests-Bridging-Header.h @@ -188,7 +188,6 @@ #import "NSData+Unzip.h" #import "Sentry/Sentry-Swift.h" -#import "SentryBinaryImageCache+Private.h" #import "SentryCrashBinaryImageCache.h" #import "SentryDispatchFactory.h" #import "SentryDispatchSourceWrapper.h" From a94ac99ff8ee6063d8bf3f5bb0746992b6519609 Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Wed, 27 Aug 2025 14:09:09 -0300 Subject: [PATCH 02/14] Fix compile on xrOS --- .../HybridPublic/SentryBinaryImageCacheCallbacks.h | 8 ++++++++ .../SentryCrash/Recording/SentryCrashBinaryImageCache.h | 8 ++++++++ .../Recording/Tools/SentryCrashDynamicLinker.h | 8 ++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Sources/Sentry/include/HybridPublic/SentryBinaryImageCacheCallbacks.h b/Sources/Sentry/include/HybridPublic/SentryBinaryImageCacheCallbacks.h index 4b09f29d90a..c966ef3e076 100644 --- a/Sources/Sentry/include/HybridPublic/SentryBinaryImageCacheCallbacks.h +++ b/Sources/Sentry/include/HybridPublic/SentryBinaryImageCacheCallbacks.h @@ -1,6 +1,14 @@ #import "SentryCrashDynamicLinker.h" #import +#ifdef __cplusplus +extern "C" { +#endif + void binaryImageWasAdded(const SentryCrashBinaryImage *_Nullable image); void binaryImageWasRemoved(const SentryCrashBinaryImage *_Nullable image); + +#ifdef __cplusplus +} +#endif diff --git a/Sources/SentryCrash/Recording/SentryCrashBinaryImageCache.h b/Sources/SentryCrash/Recording/SentryCrashBinaryImageCache.h index 4c8ee11db31..01fbe576b54 100644 --- a/Sources/SentryCrash/Recording/SentryCrashBinaryImageCache.h +++ b/Sources/SentryCrash/Recording/SentryCrashBinaryImageCache.h @@ -4,6 +4,10 @@ #include "SentryCrashDynamicLinker.h" #include +#ifdef __cplusplus +extern "C" { +#endif + typedef void (*sentrycrashbic_imageIteratorCallback)(SentryCrashBinaryImage *, void *context); typedef void (*sentrycrashbic_cacheChangeCallback)(const SentryCrashBinaryImage *binaryImage); @@ -33,4 +37,8 @@ void sentrycrashbic_registerAddedCallback(sentrycrashbic_cacheChangeCallback cal */ void sentrycrashbic_registerRemovedCallback(sentrycrashbic_cacheChangeCallback callback); +#ifdef __cplusplus +} +#endif + #endif /* SentryCrashBinaryImageCache_h */ diff --git a/Sources/SentryCrash/Recording/Tools/SentryCrashDynamicLinker.h b/Sources/SentryCrash/Recording/Tools/SentryCrashDynamicLinker.h index 44ba737b627..faf8fb529c2 100644 --- a/Sources/SentryCrash/Recording/Tools/SentryCrashDynamicLinker.h +++ b/Sources/SentryCrash/Recording/Tools/SentryCrashDynamicLinker.h @@ -28,14 +28,14 @@ #ifndef HDR_SentryCrashDynamicLinker_h #define HDR_SentryCrashDynamicLinker_h -#ifdef __cplusplus -extern "C" { -#endif - #include #include #include +#ifdef __cplusplus +extern "C" { +#endif + #define SENTRY_DYLD_INDEX UINT_MAX - 1 #if __LP64__ From 0e416ddd9782dac33ef7b912296111dca84dcca3 Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Wed, 27 Aug 2025 14:31:10 -0300 Subject: [PATCH 03/14] Move headers to include folder --- Sentry.xcodeproj/project.pbxproj | 12 +- .../SentryBinaryImageCacheCallbacks.h | 7 +- .../include}/SentryCrashBinaryImageCache.h | 0 .../include}/SentryCrashDynamicLinker.h | 0 .../include}/SentryCrashUUIDConversion.h | 0 .../SentryCrashBinaryImageCacheTests.m | 305 ------------------ 6 files changed, 10 insertions(+), 314 deletions(-) rename Sources/Sentry/include/{HybridPublic => }/SentryBinaryImageCacheCallbacks.h (61%) rename Sources/{SentryCrash/Recording => Sentry/include}/SentryCrashBinaryImageCache.h (100%) rename Sources/{SentryCrash/Recording/Tools => Sentry/include}/SentryCrashDynamicLinker.h (100%) rename Sources/{SentryCrash/Recording/Tools => Sentry/include}/SentryCrashUUIDConversion.h (100%) delete mode 100644 Tests/SentryTests/SentryCrash/SentryCrashBinaryImageCacheTests.m diff --git a/Sentry.xcodeproj/project.pbxproj b/Sentry.xcodeproj/project.pbxproj index 6e9bca56e9a..228b0ddcba8 100644 --- a/Sentry.xcodeproj/project.pbxproj +++ b/Sentry.xcodeproj/project.pbxproj @@ -1012,7 +1012,6 @@ D8CB741B2947286500A5F964 /* SentryEnvelopeItemHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = D8CB741A2947286500A5F964 /* SentryEnvelopeItemHeader.m */; }; D8CB742B294B1DD000A5F964 /* SentryUIApplicationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8CB742A294B1DD000A5F964 /* SentryUIApplicationTests.swift */; }; D8CB742E294B294B00A5F964 /* MockUIScene.m in Sources */ = {isa = PBXBuildFile; fileRef = D8CB742D294B294B00A5F964 /* MockUIScene.m */; }; - D8CCFC632A1520C900DE232E /* SentryCrashBinaryImageCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D8CCFC622A1520C900DE232E /* SentryCrashBinaryImageCacheTests.m */; }; D8CD158F2D39405900EFF8AB /* TestFramesTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841325DE2BFED0510029228F /* TestFramesTracker.swift */; }; D8CE69BC277E39C700C6EC5C /* SentryFileIOTrackingIntegrationObjCTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D8CE69BB277E39C700C6EC5C /* SentryFileIOTrackingIntegrationObjCTests.m */; }; D8DBE0CA2C0E093000FAB1FD /* SentryTouchTrackerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8DBE0C92C0E093000FAB1FD /* SentryTouchTrackerTests.swift */; }; @@ -1540,7 +1539,7 @@ 63FE703420DA4C1000CDBAE8 /* SentryCrashSignalInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SentryCrashSignalInfo.h; sourceTree = ""; }; 63FE703520DA4C1000CDBAE8 /* SentryCrashSymbolicator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SentryCrashSymbolicator.h; sourceTree = ""; }; 63FE703620DA4C1000CDBAE8 /* SentryCrashID.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SentryCrashID.c; sourceTree = ""; }; - 63FE703820DA4C1000CDBAE8 /* SentryCrashDynamicLinker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SentryCrashDynamicLinker.h; sourceTree = ""; }; + 63FE703820DA4C1000CDBAE8 /* SentryCrashDynamicLinker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryCrashDynamicLinker.h; path = ../../../Sentry/include/SentryCrashDynamicLinker.h; sourceTree = ""; }; 63FE703920DA4C1000CDBAE8 /* SentryCrashMemory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SentryCrashMemory.h; sourceTree = ""; }; 63FE703A20DA4C1000CDBAE8 /* SentryCrashCPU.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SentryCrashCPU.c; sourceTree = ""; }; 63FE703B20DA4C1000CDBAE8 /* SentryCrashStackCursor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SentryCrashStackCursor.c; sourceTree = ""; }; @@ -1592,7 +1591,7 @@ 63FE71FB20DA66EB00CDBAE8 /* SentryCrashMonitor_NSException_Tests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentryCrashMonitor_NSException_Tests.m; sourceTree = ""; }; 63FE71FC20DA66EB00CDBAE8 /* SentryCrashFileUtils_Tests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentryCrashFileUtils_Tests.m; sourceTree = ""; }; 69BEE6F62620729E006DF9DF /* UrlSessionDelegateSpy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UrlSessionDelegateSpy.swift; sourceTree = ""; }; - 71F11CDEF5952DF5CC69AC74 /* SentryCrashUUIDConversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SentryCrashUUIDConversion.h; sourceTree = ""; }; + 71F11CDEF5952DF5CC69AC74 /* SentryCrashUUIDConversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryCrashUUIDConversion.h; path = ../../../Sentry/include/SentryCrashUUIDConversion.h; sourceTree = ""; }; 7B0002312477F0520035FEF1 /* SentrySessionTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentrySessionTests.m; sourceTree = ""; }; 7B0002332477F52D0035FEF1 /* SentrySessionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySessionTests.swift; sourceTree = ""; }; 7B01CE3C271993AB00B5AF31 /* SentryTransportFactoryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryTransportFactoryTests.swift; sourceTree = ""; }; @@ -2276,7 +2275,7 @@ D855B3E927D652C700BCED76 /* TestCoreDataStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestCoreDataStack.swift; sourceTree = ""; }; D85790282976A69F00C6AC1F /* TestDebugImageProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestDebugImageProvider.swift; sourceTree = ""; }; D85852B827EDDC5900C6D8AE /* SentryUIApplication.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryUIApplication.m; sourceTree = ""; }; - D858FA642A29EAB3002A3503 /* SentryBinaryImageCacheCallbacks.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryBinaryImageCacheCallbacks.h; path = include/HybridPublic/SentryBinaryImageCacheCallbacks.h; sourceTree = ""; }; + D858FA642A29EAB3002A3503 /* SentryBinaryImageCacheCallbacks.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryBinaryImageCacheCallbacks.h; path = include/SentryBinaryImageCacheCallbacks.h; sourceTree = ""; }; D858FA652A29EAB3002A3503 /* SentryBinaryImageCacheCallbacks.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryBinaryImageCacheCallbacks.m; sourceTree = ""; }; D859696927BECD8F0036A46E /* SentryCoreDataTrackingIntegration.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryCoreDataTrackingIntegration.m; sourceTree = ""; }; D859696D27BECDA20036A46E /* SentryCoreDataTracker.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryCoreDataTracker.m; sourceTree = ""; }; @@ -2286,7 +2285,7 @@ D8603DD7284F894C000E1227 /* SentryBaggage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryBaggage.h; path = Public/SentryBaggage.h; sourceTree = ""; }; D86130112BB563FD004C0F5E /* SentrySessionReplayIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySessionReplayIntegrationTests.swift; sourceTree = ""; }; D861301B2BB5A267004C0F5E /* SentrySessionReplayTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySessionReplayTests.swift; sourceTree = ""; }; - D865892D29D6ECA7000BE151 /* SentryCrashBinaryImageCache.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SentryCrashBinaryImageCache.h; sourceTree = ""; }; + D865892D29D6ECA7000BE151 /* SentryCrashBinaryImageCache.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryCrashBinaryImageCache.h; path = ../../Sentry/include/SentryCrashBinaryImageCache.h; sourceTree = ""; }; D865892E29D6ECA7000BE151 /* SentryCrashBinaryImageCache.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = SentryCrashBinaryImageCache.c; sourceTree = ""; }; D867063A27C3BC2400048851 /* SentryCoreDataTrackingIntegration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryCoreDataTrackingIntegration.h; path = include/SentryCoreDataTrackingIntegration.h; sourceTree = ""; }; D867063B27C3BC2400048851 /* SentryCoreDataSwizzling.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryCoreDataSwizzling.h; path = include/SentryCoreDataSwizzling.h; sourceTree = ""; }; @@ -2359,7 +2358,6 @@ D8CB742A294B1DD000A5F964 /* SentryUIApplicationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUIApplicationTests.swift; sourceTree = ""; }; D8CB742C294B294B00A5F964 /* MockUIScene.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockUIScene.h; sourceTree = ""; }; D8CB742D294B294B00A5F964 /* MockUIScene.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MockUIScene.m; sourceTree = ""; }; - D8CCFC622A1520C900DE232E /* SentryCrashBinaryImageCacheTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryCrashBinaryImageCacheTests.m; sourceTree = ""; }; D8CE69BB277E39C700C6EC5C /* SentryFileIOTrackingIntegrationObjCTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryFileIOTrackingIntegrationObjCTests.m; sourceTree = ""; }; D8DBE0C92C0E093000FAB1FD /* SentryTouchTrackerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryTouchTrackerTests.swift; sourceTree = ""; }; D8DBE0D12C0EFFC300FAB1FD /* SentryReplayOptionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryReplayOptionsTests.swift; sourceTree = ""; }; @@ -3295,7 +3293,6 @@ children = ( F4AACD602E01ACE800DDDD1E /* SentryCrashDynamicLinkerTests.m */, 63FE71F120DA66EA00CDBAE8 /* Container+DeepSearch_Tests.m */, - D8CCFC622A1520C900DE232E /* SentryCrashBinaryImageCacheTests.m */, F48F74572E5F52C2009D4E7D /* SentryCrashBinaryImageCacheTests.swift */, 63FE71F620DA66EB00CDBAE8 /* FileBasedTestCase.h */, 63FE71D920DA66E700CDBAE8 /* FileBasedTestCase.m */, @@ -6130,7 +6127,6 @@ D480F9DB2DE47AF2009A0594 /* SentryScopePersistentStoreTests.swift in Sources */, F4DC35582E1FFE1F0077CE89 /* SentryVideoFrameProcessorTests.swift in Sources */, 7BC6EC18255C44540059822A /* SentryDebugMetaTests.swift in Sources */, - D8CCFC632A1520C900DE232E /* SentryCrashBinaryImageCacheTests.m in Sources */, A811D867248E2770008A41EA /* SentrySystemEventBreadcrumbsTest.swift in Sources */, 7B82D54924E2A2D400EE670F /* SentryIdTests.swift in Sources */, 623FD9062D3FA9C800803EDA /* NSNumberDecodableWrapperTests.swift in Sources */, diff --git a/Sources/Sentry/include/HybridPublic/SentryBinaryImageCacheCallbacks.h b/Sources/Sentry/include/SentryBinaryImageCacheCallbacks.h similarity index 61% rename from Sources/Sentry/include/HybridPublic/SentryBinaryImageCacheCallbacks.h rename to Sources/Sentry/include/SentryBinaryImageCacheCallbacks.h index c966ef3e076..9d714a22b4e 100644 --- a/Sources/Sentry/include/HybridPublic/SentryBinaryImageCacheCallbacks.h +++ b/Sources/Sentry/include/SentryBinaryImageCacheCallbacks.h @@ -1,6 +1,11 @@ -#import "SentryCrashDynamicLinker.h" #import +#if __has_include() +# import +#else +# import "SentryCrashDynamicLinker.h" +#endif + #ifdef __cplusplus extern "C" { #endif diff --git a/Sources/SentryCrash/Recording/SentryCrashBinaryImageCache.h b/Sources/Sentry/include/SentryCrashBinaryImageCache.h similarity index 100% rename from Sources/SentryCrash/Recording/SentryCrashBinaryImageCache.h rename to Sources/Sentry/include/SentryCrashBinaryImageCache.h diff --git a/Sources/SentryCrash/Recording/Tools/SentryCrashDynamicLinker.h b/Sources/Sentry/include/SentryCrashDynamicLinker.h similarity index 100% rename from Sources/SentryCrash/Recording/Tools/SentryCrashDynamicLinker.h rename to Sources/Sentry/include/SentryCrashDynamicLinker.h diff --git a/Sources/SentryCrash/Recording/Tools/SentryCrashUUIDConversion.h b/Sources/Sentry/include/SentryCrashUUIDConversion.h similarity index 100% rename from Sources/SentryCrash/Recording/Tools/SentryCrashUUIDConversion.h rename to Sources/Sentry/include/SentryCrashUUIDConversion.h diff --git a/Tests/SentryTests/SentryCrash/SentryCrashBinaryImageCacheTests.m b/Tests/SentryTests/SentryCrash/SentryCrashBinaryImageCacheTests.m deleted file mode 100644 index 4a9f63f9cef..00000000000 --- a/Tests/SentryTests/SentryCrash/SentryCrashBinaryImageCacheTests.m +++ /dev/null @@ -1,305 +0,0 @@ -#import "SentryCrashBinaryImageCache.h" -#import "SentryCrashDynamicLinker+Test.h" -#import "SentryCrashWrapper.h" -#import "SentryDependencyContainer.h" -#import - -#include -#include - -// Exposing test only functions from `SentryCrashBinaryImageCache.m` -void sentry_setRegisterFuncForAddImage(void *addFunction); -void sentry_setRegisterFuncForRemoveImage(void *removeFunction); -void sentry_resetFuncForAddRemoveImage(void); -void sentry_setFuncForBeforeAdd(void (*callback)(void)); - -static void (*addBinaryImage)(const struct mach_header *mh, intptr_t vmaddr_slide); -static void (*removeBinaryImage)(const struct mach_header *mh, intptr_t vmaddr_slide); -static NSMutableArray *mach_headers_test_cache; -static NSMutableArray *mach_headers_expect_array; - -static void -sentry_register_func_for_add_image( - void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide)) -{ - addBinaryImage = func; - - if (mach_headers_expect_array) { - // Skipping first item which is dyld and already included when starting the cache - for (NSUInteger i = 1; i < mach_headers_expect_array.count; i++) { - NSValue *header = mach_headers_expect_array[i]; - func(header.pointerValue, 0); - } - } -} - -static void -sentry_register_func_for_remove_image( - void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide)) -{ - removeBinaryImage = func; -} - -static void -cacheMachHeaders(const struct mach_header *mh, __unused intptr_t vmaddr_slide) -{ - [mach_headers_test_cache addObject:[NSValue valueWithPointer:mh]]; -} - -static void -countNumberOfImagesInCache(__unused SentryCrashBinaryImage *image, void *context) -{ - int *counter = context; - (*counter)++; -} - -static void -addBinaryImageToArray(SentryCrashBinaryImage *image, void *context) -{ - NSMutableArray *array = (__bridge NSMutableArray *)context; - [array addObject:[NSValue valueWithPointer:image]]; -} - -dispatch_semaphore_t delaySemaphore = NULL; -dispatch_semaphore_t delayCalled = NULL; -static void -delayAddBinaryImage(void) -{ - if (delayCalled) { - dispatch_semaphore_signal(delayCalled); - } - if (delaySemaphore) { - dispatch_semaphore_wait(delaySemaphore, DISPATCH_TIME_FOREVER); - } -} - -@interface SentryCrashBinaryImageCacheTests : XCTestCase - -@end - -@implementation SentryCrashBinaryImageCacheTests - -+ (void)setUp -{ - // Create a test cache of actual binary images to be used during tests. - mach_headers_test_cache = [NSMutableArray array]; - - // Manually include dyld - sentrycrashdl_initialize(); - [mach_headers_test_cache addObject:[NSValue valueWithPointer:sentryDyldHeader]]; - _dyld_register_func_for_add_image(&cacheMachHeaders); -} - -- (void)setUp -{ - sentry_setRegisterFuncForAddImage(&sentry_register_func_for_add_image); - sentry_setRegisterFuncForRemoveImage(&sentry_register_func_for_remove_image); - - // Copying the first 5 images from the temporary list. - // 5 is a magic number. - mach_headers_expect_array = - [mach_headers_test_cache subarrayWithRange:NSMakeRange(0, 5)].mutableCopy; -} - -- (void)tearDown -{ - sentrycrashdl_clearDyld(); - sentry_resetFuncForAddRemoveImage(); - sentrycrashbic_stopCache(); - sentry_setFuncForBeforeAdd(NULL); - [SentryDependencyContainer reset]; -} - -- (void)testStartCache -{ - [[SentryCrashWrapper sharedInstance] startBinaryImageCache]; - [self assertBinaryImageCacheLength:5]; -} - -- (void)testStartCacheTwice -{ - sentrycrashbic_startCache(); - [self assertBinaryImageCacheLength:5]; - - sentrycrashbic_startCache(); - [self assertBinaryImageCacheLength:5]; -} - -- (void)testStopCache -{ - sentrycrashbic_startCache(); - [self assertBinaryImageCacheLength:5]; - sentrycrashbic_stopCache(); - [self assertBinaryImageCacheLength:0]; -} - -- (void)testStopCacheTwice -{ - sentrycrashbic_startCache(); - [self assertBinaryImageCacheLength:5]; - sentrycrashbic_stopCache(); - [self assertBinaryImageCacheLength:0]; - sentrycrashbic_stopCache(); - [self assertBinaryImageCacheLength:0]; -} - -- (void)testAddNewImage -{ - sentrycrashbic_startCache(); - [self assertBinaryImageCacheLength:5]; - - addBinaryImage([mach_headers_test_cache[5] pointerValue], 0); - mach_headers_expect_array = - [mach_headers_test_cache subarrayWithRange:NSMakeRange(0, 6)].mutableCopy; - [self assertBinaryImageCacheLength:6]; - [self assertCachedBinaryImages]; - - addBinaryImage([mach_headers_test_cache[6] pointerValue], 0); - mach_headers_expect_array = - [mach_headers_test_cache subarrayWithRange:NSMakeRange(0, 7)].mutableCopy; - [self assertBinaryImageCacheLength:7]; - [self assertCachedBinaryImages]; -} - -- (void)testAddInvalidHeader -{ - sentrycrashbic_startCache(); - [self assertBinaryImageCacheLength:5]; - - addBinaryImage(0, 0); - [self assertBinaryImageCacheLength:5]; -} - -- (void)testAddNewImageAfterStopping -{ - sentrycrashbic_startCache(); - [self assertBinaryImageCacheLength:5]; - - sentrycrashbic_stopCache(); - addBinaryImage([mach_headers_test_cache[6] pointerValue], 0); - [self assertBinaryImageCacheLength:0]; -} - -- (void)testRemoveImageFromTail -{ - sentrycrashbic_startCache(); - [self assertBinaryImageCacheLength:5]; - - removeBinaryImage([mach_headers_expect_array[4] pointerValue], 0); - [self assertBinaryImageCacheLength:4]; - [self assertCachedBinaryImages]; - - removeBinaryImage([mach_headers_expect_array[3] pointerValue], 0); - [self assertBinaryImageCacheLength:3]; - [self assertCachedBinaryImages]; -} - -- (void)testRemoveImageFromBeginning -{ - sentrycrashbic_startCache(); - [self assertBinaryImageCacheLength:5]; - - removeBinaryImage([mach_headers_expect_array[0] pointerValue], 0); - [self assertBinaryImageCacheLength:4]; - [mach_headers_expect_array removeObjectAtIndex:0]; - [self assertCachedBinaryImages]; - - removeBinaryImage([mach_headers_expect_array[0] pointerValue], 0); - [self assertBinaryImageCacheLength:3]; - [mach_headers_expect_array removeObjectAtIndex:0]; - [self assertCachedBinaryImages]; -} - -- (void)testRemoveImageAddAgain -{ - // Use index 1 since we can't dynamically insert dyld image (`dladdr` returns null) - int indexToRemove = 1; - - sentrycrashbic_startCache(); - [self assertBinaryImageCacheLength:5]; - - removeBinaryImage([mach_headers_expect_array[indexToRemove] pointerValue], 0); - [self assertBinaryImageCacheLength:4]; - - NSValue *removeItem = mach_headers_expect_array[indexToRemove]; - [mach_headers_expect_array removeObjectAtIndex:indexToRemove]; - [self assertCachedBinaryImages]; - - addBinaryImage(removeItem.pointerValue, 0); - [self assertBinaryImageCacheLength:5]; - [mach_headers_expect_array insertObject:removeItem atIndex:4]; - [self assertCachedBinaryImages]; -} - -- (void)testAddBinaryImageInParallel -{ - sentrycrashbic_startCache(); - dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); - - // Guard against underflow when mach_headers_test_cache.count < 5 - // because otherwise the expectedFulfillmentCount for the test expectation will be negative. - NSInteger taskCount = mach_headers_test_cache.count - 5; - if (taskCount <= 0) { - XCTFail(@"Expected a positive task count, but got %ld", taskCount); - return; - } - - XCTestExpectation *expectation = - [self expectationWithDescription:@"Add binary images in parallel"]; - expectation.expectedFulfillmentCount = taskCount; - - for (NSUInteger i = 5; i < mach_headers_test_cache.count; i++) { - dispatch_async(queue, ^{ - addBinaryImage([mach_headers_test_cache[i] pointerValue], 0); - [expectation fulfill]; - }); - } - - [self waitForExpectations:@[ expectation ] timeout:5.0]; - - [self assertBinaryImageCacheLength:(int)mach_headers_test_cache.count]; -} - -- (void)testCloseCacheWhileAdding -{ - sentrycrashbic_startCache(); - sentry_setFuncForBeforeAdd(&delayAddBinaryImage); - delaySemaphore = dispatch_semaphore_create(0); - delayCalled = dispatch_semaphore_create(0); - - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), - ^{ addBinaryImage([mach_headers_test_cache[6] pointerValue], 0); }); - - intptr_t result - = dispatch_semaphore_wait(delayCalled, dispatch_time(DISPATCH_TIME_NOW, 5 * NSEC_PER_SEC)); - sentrycrashbic_stopCache(); - dispatch_semaphore_signal(delaySemaphore); - [self assertBinaryImageCacheLength:0]; - XCTAssertEqual(result, 0); -} - -- (void)assertBinaryImageCacheLength:(int)expected -{ - int counter = 0; - sentrycrashbic_iterateOverImages(countNumberOfImagesInCache, &counter); - XCTAssertEqual(counter, expected); -} - -- (void)assertCachedBinaryImages -{ - NSArray *cached = [self binaryImageCacheToArray]; - for (NSUInteger i = 0; i < cached.count; i++) { - SentryCrashBinaryImage *binaryImage = [cached[i] pointerValue]; - struct mach_header *header = [mach_headers_expect_array[i] pointerValue]; - XCTAssertEqual(binaryImage->address, (uint64_t)header); - } -} - -- (NSArray *)binaryImageCacheToArray -{ - NSMutableArray *result = [NSMutableArray array]; - sentrycrashbic_iterateOverImages(addBinaryImageToArray, (__bridge void *)(result)); - return result; -} - -@end From 271710173777ba1d352338428c61a36466819b1a Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Wed, 27 Aug 2025 14:46:36 -0300 Subject: [PATCH 04/14] Update sdk json --- sdk_api.json | 992 ++++++++++++++++++++++++++++++++++++++++++++++++ sdk_api_V9.json | 992 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1984 insertions(+) diff --git a/sdk_api.json b/sdk_api.json index 31d6948f49b..af39896f969 100644 --- a/sdk_api.json +++ b/sdk_api.json @@ -57116,6 +57116,998 @@ } ] }, + { + "kind": "TypeDecl", + "name": "SentryBinaryImageInfo", + "printedName": "SentryBinaryImageInfo", + "children": [ + { + "kind": "Var", + "name": "name", + "printedName": "name", + "children": [ + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + } + ], + "declKind": "Var", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(py)name", + "mangledName": "$s6Sentry0A15BinaryImageInfoC4nameSSvp", + "moduleName": "Sentry", + "declAttributes": [ + "ObjC", + "HasStorage" + ], + "hasStorage": true, + "accessors": [ + { + "kind": "Accessor", + "name": "Get", + "printedName": "Get()", + "children": [ + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + } + ], + "declKind": "Accessor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)name", + "mangledName": "$s6Sentry0A15BinaryImageInfoC4nameSSvg", + "moduleName": "Sentry", + "implicit": true, + "declAttributes": [ + "ObjC" + ], + "accessorKind": "get" + }, + { + "kind": "Accessor", + "name": "Set", + "printedName": "Set()", + "children": [ + { + "kind": "TypeNominal", + "name": "Void", + "printedName": "()" + }, + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + } + ], + "declKind": "Accessor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)setName:", + "mangledName": "$s6Sentry0A15BinaryImageInfoC4nameSSvs", + "moduleName": "Sentry", + "implicit": true, + "declAttributes": [ + "ObjC" + ], + "accessorKind": "set" + } + ] + }, + { + "kind": "Var", + "name": "uuid", + "printedName": "uuid", + "children": [ + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "Swift.String?", + "children": [ + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + } + ], + "usr": "s:Sq" + } + ], + "declKind": "Var", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(py)uuid", + "mangledName": "$s6Sentry0A15BinaryImageInfoC4uuidSSSgvp", + "moduleName": "Sentry", + "declAttributes": [ + "HasInitialValue", + "ObjC", + "HasStorage" + ], + "hasStorage": true, + "accessors": [ + { + "kind": "Accessor", + "name": "Get", + "printedName": "Get()", + "children": [ + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "Swift.String?", + "children": [ + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + } + ], + "usr": "s:Sq" + } + ], + "declKind": "Accessor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)uuid", + "mangledName": "$s6Sentry0A15BinaryImageInfoC4uuidSSSgvg", + "moduleName": "Sentry", + "implicit": true, + "declAttributes": [ + "ObjC" + ], + "accessorKind": "get" + }, + { + "kind": "Accessor", + "name": "Set", + "printedName": "Set()", + "children": [ + { + "kind": "TypeNominal", + "name": "Void", + "printedName": "()" + }, + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "Swift.String?", + "children": [ + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + } + ], + "usr": "s:Sq" + } + ], + "declKind": "Accessor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)setUuid:", + "mangledName": "$s6Sentry0A15BinaryImageInfoC4uuidSSSgvs", + "moduleName": "Sentry", + "implicit": true, + "declAttributes": [ + "ObjC" + ], + "accessorKind": "set" + } + ] + }, + { + "kind": "Var", + "name": "vmAddress", + "printedName": "vmAddress", + "children": [ + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Var", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(py)vmAddress", + "mangledName": "$s6Sentry0A15BinaryImageInfoC9vmAddresss6UInt64Vvp", + "moduleName": "Sentry", + "declAttributes": [ + "ObjC", + "HasStorage" + ], + "hasStorage": true, + "accessors": [ + { + "kind": "Accessor", + "name": "Get", + "printedName": "Get()", + "children": [ + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Accessor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)vmAddress", + "mangledName": "$s6Sentry0A15BinaryImageInfoC9vmAddresss6UInt64Vvg", + "moduleName": "Sentry", + "implicit": true, + "declAttributes": [ + "ObjC" + ], + "accessorKind": "get" + }, + { + "kind": "Accessor", + "name": "Set", + "printedName": "Set()", + "children": [ + { + "kind": "TypeNominal", + "name": "Void", + "printedName": "()" + }, + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Accessor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)setVmAddress:", + "mangledName": "$s6Sentry0A15BinaryImageInfoC9vmAddresss6UInt64Vvs", + "moduleName": "Sentry", + "implicit": true, + "declAttributes": [ + "ObjC" + ], + "accessorKind": "set" + } + ] + }, + { + "kind": "Var", + "name": "address", + "printedName": "address", + "children": [ + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Var", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(py)address", + "mangledName": "$s6Sentry0A15BinaryImageInfoC7addresss6UInt64Vvp", + "moduleName": "Sentry", + "declAttributes": [ + "ObjC", + "HasStorage" + ], + "hasStorage": true, + "accessors": [ + { + "kind": "Accessor", + "name": "Get", + "printedName": "Get()", + "children": [ + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Accessor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)address", + "mangledName": "$s6Sentry0A15BinaryImageInfoC7addresss6UInt64Vvg", + "moduleName": "Sentry", + "implicit": true, + "declAttributes": [ + "ObjC" + ], + "accessorKind": "get" + }, + { + "kind": "Accessor", + "name": "Set", + "printedName": "Set()", + "children": [ + { + "kind": "TypeNominal", + "name": "Void", + "printedName": "()" + }, + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Accessor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)setAddress:", + "mangledName": "$s6Sentry0A15BinaryImageInfoC7addresss6UInt64Vvs", + "moduleName": "Sentry", + "implicit": true, + "declAttributes": [ + "ObjC" + ], + "accessorKind": "set" + } + ] + }, + { + "kind": "Var", + "name": "size", + "printedName": "size", + "children": [ + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Var", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(py)size", + "mangledName": "$s6Sentry0A15BinaryImageInfoC4sizes6UInt64Vvp", + "moduleName": "Sentry", + "declAttributes": [ + "ObjC", + "HasStorage" + ], + "hasStorage": true, + "accessors": [ + { + "kind": "Accessor", + "name": "Get", + "printedName": "Get()", + "children": [ + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Accessor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)size", + "mangledName": "$s6Sentry0A15BinaryImageInfoC4sizes6UInt64Vvg", + "moduleName": "Sentry", + "implicit": true, + "declAttributes": [ + "ObjC" + ], + "accessorKind": "get" + }, + { + "kind": "Accessor", + "name": "Set", + "printedName": "Set()", + "children": [ + { + "kind": "TypeNominal", + "name": "Void", + "printedName": "()" + }, + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Accessor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)setSize:", + "mangledName": "$s6Sentry0A15BinaryImageInfoC4sizes6UInt64Vvs", + "moduleName": "Sentry", + "implicit": true, + "declAttributes": [ + "ObjC" + ], + "accessorKind": "set" + } + ] + }, + { + "kind": "Constructor", + "name": "init", + "printedName": "init(name:uuid:vmAddress:address:size:)", + "children": [ + { + "kind": "TypeNominal", + "name": "SentryBinaryImageInfo", + "printedName": "Sentry.SentryBinaryImageInfo", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo" + }, + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + }, + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "Swift.String?", + "children": [ + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + } + ], + "usr": "s:Sq" + }, + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + }, + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + }, + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Constructor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)initWithName:uuid:vmAddress:address:size:", + "mangledName": "$s6Sentry0A15BinaryImageInfoC4name4uuid9vmAddress7address4sizeACSS_SSSgs6UInt64VA2Ktcfc", + "moduleName": "Sentry", + "objc_name": "initWithName:uuid:vmAddress:address:size:", + "declAttributes": [ + "ObjC" + ], + "init_kind": "Designated" + } + ], + "declKind": "Class", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo", + "mangledName": "$s6Sentry0A15BinaryImageInfoC", + "moduleName": "Sentry", + "objc_name": "SentryBinaryImageInfo", + "declAttributes": [ + "ObjC" + ], + "superclassUsr": "c:objc(cs)NSObject", + "superclassNames": [ + "ObjectiveC.NSObject" + ], + "conformances": [ + { + "kind": "Conformance", + "name": "Copyable", + "printedName": "Copyable", + "usr": "s:s8CopyableP", + "mangledName": "$ss8CopyableP" + }, + { + "kind": "Conformance", + "name": "Escapable", + "printedName": "Escapable", + "usr": "s:s9EscapableP", + "mangledName": "$ss9EscapableP" + }, + { + "kind": "Conformance", + "name": "NSObjectProtocol", + "printedName": "NSObjectProtocol", + "usr": "c:objc(pl)NSObject" + }, + { + "kind": "Conformance", + "name": "Equatable", + "printedName": "Equatable", + "usr": "s:SQ", + "mangledName": "$sSQ" + }, + { + "kind": "Conformance", + "name": "Hashable", + "printedName": "Hashable", + "usr": "s:SH", + "mangledName": "$sSH" + }, + { + "kind": "Conformance", + "name": "CVarArg", + "printedName": "CVarArg", + "usr": "s:s7CVarArgP", + "mangledName": "$ss7CVarArgP" + }, + { + "kind": "Conformance", + "name": "CustomStringConvertible", + "printedName": "CustomStringConvertible", + "usr": "s:s23CustomStringConvertibleP", + "mangledName": "$ss23CustomStringConvertibleP" + }, + { + "kind": "Conformance", + "name": "CustomDebugStringConvertible", + "printedName": "CustomDebugStringConvertible", + "usr": "s:s28CustomDebugStringConvertibleP", + "mangledName": "$ss28CustomDebugStringConvertibleP" + } + ] + }, + { + "kind": "TypeDecl", + "name": "SentryBinaryImageCache", + "printedName": "SentryBinaryImageCache", + "children": [ + { + "kind": "Var", + "name": "cache", + "printedName": "cache", + "children": [ + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "[Sentry.SentryBinaryImageInfo]?", + "children": [ + { + "kind": "TypeNominal", + "name": "Array", + "printedName": "[Sentry.SentryBinaryImageInfo]", + "children": [ + { + "kind": "TypeNominal", + "name": "SentryBinaryImageInfo", + "printedName": "Sentry.SentryBinaryImageInfo", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo" + } + ], + "usr": "s:Sa" + } + ], + "usr": "s:Sq" + } + ], + "declKind": "Var", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(py)cache", + "mangledName": "$s6Sentry0A16BinaryImageCacheC5cacheSayAA0abC4InfoCGSgvp", + "moduleName": "Sentry", + "declAttributes": [ + "ObjC" + ], + "accessors": [ + { + "kind": "Accessor", + "name": "Get", + "printedName": "Get()", + "children": [ + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "[Sentry.SentryBinaryImageInfo]?", + "children": [ + { + "kind": "TypeNominal", + "name": "Array", + "printedName": "[Sentry.SentryBinaryImageInfo]", + "children": [ + { + "kind": "TypeNominal", + "name": "SentryBinaryImageInfo", + "printedName": "Sentry.SentryBinaryImageInfo", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo" + } + ], + "usr": "s:Sa" + } + ], + "usr": "s:Sq" + } + ], + "declKind": "Accessor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)cache", + "mangledName": "$s6Sentry0A16BinaryImageCacheC5cacheSayAA0abC4InfoCGSgvg", + "moduleName": "Sentry", + "declAttributes": [ + "ObjC" + ], + "accessorKind": "get" + } + ] + }, + { + "kind": "Constructor", + "name": "init", + "printedName": "init()", + "children": [ + { + "kind": "TypeNominal", + "name": "SentryBinaryImageCache", + "printedName": "Sentry.SentryBinaryImageCache", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache" + } + ], + "declKind": "Constructor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)init", + "mangledName": "$s6Sentry0A16BinaryImageCacheCACycfc", + "moduleName": "Sentry", + "overriding": true, + "objc_name": "init", + "declAttributes": [ + "ObjC", + "Dynamic", + "Override" + ], + "init_kind": "Designated" + }, + { + "kind": "Function", + "name": "stop", + "printedName": "stop()", + "children": [ + { + "kind": "TypeNominal", + "name": "Void", + "printedName": "()" + } + ], + "declKind": "Func", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)stop", + "mangledName": "$s6Sentry0A16BinaryImageCacheC4stopyyF", + "moduleName": "Sentry", + "declAttributes": [ + "ObjC" + ], + "funcSelfKind": "NonMutating" + }, + { + "kind": "Function", + "name": "binaryImageAdded", + "printedName": "binaryImageAdded(imageName:vmAddress:address:size:uuid:)", + "children": [ + { + "kind": "TypeNominal", + "name": "Void", + "printedName": "()" + }, + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "Swift.UnsafePointer?", + "children": [ + { + "kind": "TypeNominal", + "name": "UnsafePointer", + "printedName": "Swift.UnsafePointer", + "children": [ + { + "kind": "TypeNameAlias", + "name": "CChar", + "printedName": "Swift.CChar", + "children": [ + { + "kind": "TypeNominal", + "name": "Int8", + "printedName": "Swift.Int8", + "usr": "s:s4Int8V" + } + ] + } + ], + "usr": "s:SP" + } + ], + "usr": "s:Sq" + }, + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + }, + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + }, + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + }, + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "Swift.UnsafePointer?", + "children": [ + { + "kind": "TypeNominal", + "name": "UnsafePointer", + "printedName": "Swift.UnsafePointer", + "children": [ + { + "kind": "TypeNominal", + "name": "UInt8", + "printedName": "Swift.UInt8", + "usr": "s:s5UInt8V" + } + ], + "usr": "s:SP" + } + ], + "usr": "s:Sq" + } + ], + "declKind": "Func", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)binaryImageAdded:vmAddress:address:size:uuid:", + "mangledName": "$s6Sentry0A16BinaryImageCacheC06binaryC5Added9imageName9vmAddress7address4size4uuidySPys4Int8VGSg_s6UInt64VA2OSPys5UInt8VGSgtF", + "moduleName": "Sentry", + "objc_name": "binaryImageAdded:vmAddress:address:size:uuid:", + "declAttributes": [ + "ObjC" + ], + "funcSelfKind": "NonMutating" + }, + { + "kind": "Function", + "name": "convertUUID", + "printedName": "convertUUID(_:)", + "children": [ + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "Swift.String?", + "children": [ + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + } + ], + "usr": "s:Sq" + }, + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "Swift.UnsafePointer?", + "children": [ + { + "kind": "TypeNominal", + "name": "UnsafePointer", + "printedName": "Swift.UnsafePointer", + "children": [ + { + "kind": "TypeNominal", + "name": "UInt8", + "printedName": "Swift.UInt8", + "usr": "s:s5UInt8V" + } + ], + "usr": "s:SP" + } + ], + "usr": "s:Sq" + } + ], + "declKind": "Func", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(cm)convertUUID:", + "mangledName": "$s6Sentry0A16BinaryImageCacheC11convertUUIDySSSgSPys5UInt8VGSgFZ", + "moduleName": "Sentry", + "static": true, + "declAttributes": [ + "Final", + "ObjC" + ], + "funcSelfKind": "NonMutating" + }, + { + "kind": "Function", + "name": "binaryImageRemoved", + "printedName": "binaryImageRemoved(_:)", + "children": [ + { + "kind": "TypeNominal", + "name": "Void", + "printedName": "()" + }, + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Func", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)binaryImageRemoved:", + "mangledName": "$s6Sentry0A16BinaryImageCacheC06binaryC7Removedyys6UInt64VF", + "moduleName": "Sentry", + "declAttributes": [ + "ObjC" + ], + "funcSelfKind": "NonMutating" + }, + { + "kind": "Function", + "name": "imageByAddress", + "printedName": "imageByAddress(_:)", + "children": [ + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "Sentry.SentryBinaryImageInfo?", + "children": [ + { + "kind": "TypeNominal", + "name": "SentryBinaryImageInfo", + "printedName": "Sentry.SentryBinaryImageInfo", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo" + } + ], + "usr": "s:Sq" + }, + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Func", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)imageByAddress:", + "mangledName": "$s6Sentry0A16BinaryImageCacheC14imageByAddressyAA0abC4InfoCSgs6UInt64VF", + "moduleName": "Sentry", + "declAttributes": [ + "ObjC" + ], + "funcSelfKind": "NonMutating" + }, + { + "kind": "Function", + "name": "imagePathsFor", + "printedName": "imagePathsFor(inAppInclude:)", + "children": [ + { + "kind": "TypeNominal", + "name": "Set", + "printedName": "Swift.Set", + "children": [ + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + } + ], + "usr": "s:Sh" + }, + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + } + ], + "declKind": "Func", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)imagePathsForInAppInclude:", + "mangledName": "$s6Sentry0A16BinaryImageCacheC13imagePathsFor12inAppIncludeShySSGSS_tF", + "moduleName": "Sentry", + "objc_name": "imagePathsForInAppInclude:", + "declAttributes": [ + "ObjC" + ], + "funcSelfKind": "NonMutating" + }, + { + "kind": "Function", + "name": "getAllBinaryImages", + "printedName": "getAllBinaryImages()", + "children": [ + { + "kind": "TypeNominal", + "name": "Array", + "printedName": "[Sentry.SentryBinaryImageInfo]", + "children": [ + { + "kind": "TypeNominal", + "name": "SentryBinaryImageInfo", + "printedName": "Sentry.SentryBinaryImageInfo", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo" + } + ], + "usr": "s:Sa" + } + ], + "declKind": "Func", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)getAllBinaryImages", + "mangledName": "$s6Sentry0A16BinaryImageCacheC06getAllB6ImagesSayAA0abC4InfoCGyF", + "moduleName": "Sentry", + "declAttributes": [ + "ObjC" + ], + "funcSelfKind": "NonMutating" + } + ], + "declKind": "Class", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache", + "mangledName": "$s6Sentry0A16BinaryImageCacheC", + "moduleName": "Sentry", + "objc_name": "SentryBinaryImageCache", + "declAttributes": [ + "ObjC" + ], + "superclassUsr": "c:objc(cs)NSObject", + "inheritsConvenienceInitializers": true, + "superclassNames": [ + "ObjectiveC.NSObject" + ], + "conformances": [ + { + "kind": "Conformance", + "name": "Copyable", + "printedName": "Copyable", + "usr": "s:s8CopyableP", + "mangledName": "$ss8CopyableP" + }, + { + "kind": "Conformance", + "name": "Escapable", + "printedName": "Escapable", + "usr": "s:s9EscapableP", + "mangledName": "$ss9EscapableP" + }, + { + "kind": "Conformance", + "name": "NSObjectProtocol", + "printedName": "NSObjectProtocol", + "usr": "c:objc(pl)NSObject" + }, + { + "kind": "Conformance", + "name": "Equatable", + "printedName": "Equatable", + "usr": "s:SQ", + "mangledName": "$sSQ" + }, + { + "kind": "Conformance", + "name": "Hashable", + "printedName": "Hashable", + "usr": "s:SH", + "mangledName": "$sSH" + }, + { + "kind": "Conformance", + "name": "CVarArg", + "printedName": "CVarArg", + "usr": "s:s7CVarArgP", + "mangledName": "$ss7CVarArgP" + }, + { + "kind": "Conformance", + "name": "CustomStringConvertible", + "printedName": "CustomStringConvertible", + "usr": "s:s23CustomStringConvertibleP", + "mangledName": "$ss23CustomStringConvertibleP" + }, + { + "kind": "Conformance", + "name": "CustomDebugStringConvertible", + "printedName": "CustomDebugStringConvertible", + "usr": "s:s28CustomDebugStringConvertibleP", + "mangledName": "$ss28CustomDebugStringConvertibleP" + } + ] + }, { "kind": "TypeDecl", "name": "SentryRedactRegionType", diff --git a/sdk_api_V9.json b/sdk_api_V9.json index c298cafa12c..8e828d6e896 100644 --- a/sdk_api_V9.json +++ b/sdk_api_V9.json @@ -53644,6 +53644,998 @@ } ] }, + { + "kind": "TypeDecl", + "name": "SentryBinaryImageInfo", + "printedName": "SentryBinaryImageInfo", + "children": [ + { + "kind": "Var", + "name": "name", + "printedName": "name", + "children": [ + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + } + ], + "declKind": "Var", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(py)name", + "mangledName": "$s6Sentry0A15BinaryImageInfoC4nameSSvp", + "moduleName": "Sentry", + "declAttributes": [ + "ObjC", + "HasStorage" + ], + "hasStorage": true, + "accessors": [ + { + "kind": "Accessor", + "name": "Get", + "printedName": "Get()", + "children": [ + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + } + ], + "declKind": "Accessor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)name", + "mangledName": "$s6Sentry0A15BinaryImageInfoC4nameSSvg", + "moduleName": "Sentry", + "implicit": true, + "declAttributes": [ + "ObjC" + ], + "accessorKind": "get" + }, + { + "kind": "Accessor", + "name": "Set", + "printedName": "Set()", + "children": [ + { + "kind": "TypeNominal", + "name": "Void", + "printedName": "()" + }, + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + } + ], + "declKind": "Accessor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)setName:", + "mangledName": "$s6Sentry0A15BinaryImageInfoC4nameSSvs", + "moduleName": "Sentry", + "implicit": true, + "declAttributes": [ + "ObjC" + ], + "accessorKind": "set" + } + ] + }, + { + "kind": "Var", + "name": "uuid", + "printedName": "uuid", + "children": [ + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "Swift.String?", + "children": [ + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + } + ], + "usr": "s:Sq" + } + ], + "declKind": "Var", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(py)uuid", + "mangledName": "$s6Sentry0A15BinaryImageInfoC4uuidSSSgvp", + "moduleName": "Sentry", + "declAttributes": [ + "HasInitialValue", + "ObjC", + "HasStorage" + ], + "hasStorage": true, + "accessors": [ + { + "kind": "Accessor", + "name": "Get", + "printedName": "Get()", + "children": [ + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "Swift.String?", + "children": [ + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + } + ], + "usr": "s:Sq" + } + ], + "declKind": "Accessor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)uuid", + "mangledName": "$s6Sentry0A15BinaryImageInfoC4uuidSSSgvg", + "moduleName": "Sentry", + "implicit": true, + "declAttributes": [ + "ObjC" + ], + "accessorKind": "get" + }, + { + "kind": "Accessor", + "name": "Set", + "printedName": "Set()", + "children": [ + { + "kind": "TypeNominal", + "name": "Void", + "printedName": "()" + }, + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "Swift.String?", + "children": [ + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + } + ], + "usr": "s:Sq" + } + ], + "declKind": "Accessor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)setUuid:", + "mangledName": "$s6Sentry0A15BinaryImageInfoC4uuidSSSgvs", + "moduleName": "Sentry", + "implicit": true, + "declAttributes": [ + "ObjC" + ], + "accessorKind": "set" + } + ] + }, + { + "kind": "Var", + "name": "vmAddress", + "printedName": "vmAddress", + "children": [ + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Var", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(py)vmAddress", + "mangledName": "$s6Sentry0A15BinaryImageInfoC9vmAddresss6UInt64Vvp", + "moduleName": "Sentry", + "declAttributes": [ + "ObjC", + "HasStorage" + ], + "hasStorage": true, + "accessors": [ + { + "kind": "Accessor", + "name": "Get", + "printedName": "Get()", + "children": [ + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Accessor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)vmAddress", + "mangledName": "$s6Sentry0A15BinaryImageInfoC9vmAddresss6UInt64Vvg", + "moduleName": "Sentry", + "implicit": true, + "declAttributes": [ + "ObjC" + ], + "accessorKind": "get" + }, + { + "kind": "Accessor", + "name": "Set", + "printedName": "Set()", + "children": [ + { + "kind": "TypeNominal", + "name": "Void", + "printedName": "()" + }, + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Accessor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)setVmAddress:", + "mangledName": "$s6Sentry0A15BinaryImageInfoC9vmAddresss6UInt64Vvs", + "moduleName": "Sentry", + "implicit": true, + "declAttributes": [ + "ObjC" + ], + "accessorKind": "set" + } + ] + }, + { + "kind": "Var", + "name": "address", + "printedName": "address", + "children": [ + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Var", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(py)address", + "mangledName": "$s6Sentry0A15BinaryImageInfoC7addresss6UInt64Vvp", + "moduleName": "Sentry", + "declAttributes": [ + "ObjC", + "HasStorage" + ], + "hasStorage": true, + "accessors": [ + { + "kind": "Accessor", + "name": "Get", + "printedName": "Get()", + "children": [ + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Accessor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)address", + "mangledName": "$s6Sentry0A15BinaryImageInfoC7addresss6UInt64Vvg", + "moduleName": "Sentry", + "implicit": true, + "declAttributes": [ + "ObjC" + ], + "accessorKind": "get" + }, + { + "kind": "Accessor", + "name": "Set", + "printedName": "Set()", + "children": [ + { + "kind": "TypeNominal", + "name": "Void", + "printedName": "()" + }, + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Accessor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)setAddress:", + "mangledName": "$s6Sentry0A15BinaryImageInfoC7addresss6UInt64Vvs", + "moduleName": "Sentry", + "implicit": true, + "declAttributes": [ + "ObjC" + ], + "accessorKind": "set" + } + ] + }, + { + "kind": "Var", + "name": "size", + "printedName": "size", + "children": [ + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Var", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(py)size", + "mangledName": "$s6Sentry0A15BinaryImageInfoC4sizes6UInt64Vvp", + "moduleName": "Sentry", + "declAttributes": [ + "ObjC", + "HasStorage" + ], + "hasStorage": true, + "accessors": [ + { + "kind": "Accessor", + "name": "Get", + "printedName": "Get()", + "children": [ + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Accessor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)size", + "mangledName": "$s6Sentry0A15BinaryImageInfoC4sizes6UInt64Vvg", + "moduleName": "Sentry", + "implicit": true, + "declAttributes": [ + "ObjC" + ], + "accessorKind": "get" + }, + { + "kind": "Accessor", + "name": "Set", + "printedName": "Set()", + "children": [ + { + "kind": "TypeNominal", + "name": "Void", + "printedName": "()" + }, + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Accessor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)setSize:", + "mangledName": "$s6Sentry0A15BinaryImageInfoC4sizes6UInt64Vvs", + "moduleName": "Sentry", + "implicit": true, + "declAttributes": [ + "ObjC" + ], + "accessorKind": "set" + } + ] + }, + { + "kind": "Constructor", + "name": "init", + "printedName": "init(name:uuid:vmAddress:address:size:)", + "children": [ + { + "kind": "TypeNominal", + "name": "SentryBinaryImageInfo", + "printedName": "Sentry.SentryBinaryImageInfo", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo" + }, + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + }, + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "Swift.String?", + "children": [ + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + } + ], + "usr": "s:Sq" + }, + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + }, + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + }, + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Constructor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)initWithName:uuid:vmAddress:address:size:", + "mangledName": "$s6Sentry0A15BinaryImageInfoC4name4uuid9vmAddress7address4sizeACSS_SSSgs6UInt64VA2Ktcfc", + "moduleName": "Sentry", + "objc_name": "initWithName:uuid:vmAddress:address:size:", + "declAttributes": [ + "ObjC" + ], + "init_kind": "Designated" + } + ], + "declKind": "Class", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo", + "mangledName": "$s6Sentry0A15BinaryImageInfoC", + "moduleName": "Sentry", + "objc_name": "SentryBinaryImageInfo", + "declAttributes": [ + "ObjC" + ], + "superclassUsr": "c:objc(cs)NSObject", + "superclassNames": [ + "ObjectiveC.NSObject" + ], + "conformances": [ + { + "kind": "Conformance", + "name": "Copyable", + "printedName": "Copyable", + "usr": "s:s8CopyableP", + "mangledName": "$ss8CopyableP" + }, + { + "kind": "Conformance", + "name": "Escapable", + "printedName": "Escapable", + "usr": "s:s9EscapableP", + "mangledName": "$ss9EscapableP" + }, + { + "kind": "Conformance", + "name": "NSObjectProtocol", + "printedName": "NSObjectProtocol", + "usr": "c:objc(pl)NSObject" + }, + { + "kind": "Conformance", + "name": "Equatable", + "printedName": "Equatable", + "usr": "s:SQ", + "mangledName": "$sSQ" + }, + { + "kind": "Conformance", + "name": "Hashable", + "printedName": "Hashable", + "usr": "s:SH", + "mangledName": "$sSH" + }, + { + "kind": "Conformance", + "name": "CVarArg", + "printedName": "CVarArg", + "usr": "s:s7CVarArgP", + "mangledName": "$ss7CVarArgP" + }, + { + "kind": "Conformance", + "name": "CustomStringConvertible", + "printedName": "CustomStringConvertible", + "usr": "s:s23CustomStringConvertibleP", + "mangledName": "$ss23CustomStringConvertibleP" + }, + { + "kind": "Conformance", + "name": "CustomDebugStringConvertible", + "printedName": "CustomDebugStringConvertible", + "usr": "s:s28CustomDebugStringConvertibleP", + "mangledName": "$ss28CustomDebugStringConvertibleP" + } + ] + }, + { + "kind": "TypeDecl", + "name": "SentryBinaryImageCache", + "printedName": "SentryBinaryImageCache", + "children": [ + { + "kind": "Var", + "name": "cache", + "printedName": "cache", + "children": [ + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "[Sentry.SentryBinaryImageInfo]?", + "children": [ + { + "kind": "TypeNominal", + "name": "Array", + "printedName": "[Sentry.SentryBinaryImageInfo]", + "children": [ + { + "kind": "TypeNominal", + "name": "SentryBinaryImageInfo", + "printedName": "Sentry.SentryBinaryImageInfo", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo" + } + ], + "usr": "s:Sa" + } + ], + "usr": "s:Sq" + } + ], + "declKind": "Var", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(py)cache", + "mangledName": "$s6Sentry0A16BinaryImageCacheC5cacheSayAA0abC4InfoCGSgvp", + "moduleName": "Sentry", + "declAttributes": [ + "ObjC" + ], + "accessors": [ + { + "kind": "Accessor", + "name": "Get", + "printedName": "Get()", + "children": [ + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "[Sentry.SentryBinaryImageInfo]?", + "children": [ + { + "kind": "TypeNominal", + "name": "Array", + "printedName": "[Sentry.SentryBinaryImageInfo]", + "children": [ + { + "kind": "TypeNominal", + "name": "SentryBinaryImageInfo", + "printedName": "Sentry.SentryBinaryImageInfo", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo" + } + ], + "usr": "s:Sa" + } + ], + "usr": "s:Sq" + } + ], + "declKind": "Accessor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)cache", + "mangledName": "$s6Sentry0A16BinaryImageCacheC5cacheSayAA0abC4InfoCGSgvg", + "moduleName": "Sentry", + "declAttributes": [ + "ObjC" + ], + "accessorKind": "get" + } + ] + }, + { + "kind": "Constructor", + "name": "init", + "printedName": "init()", + "children": [ + { + "kind": "TypeNominal", + "name": "SentryBinaryImageCache", + "printedName": "Sentry.SentryBinaryImageCache", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache" + } + ], + "declKind": "Constructor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)init", + "mangledName": "$s6Sentry0A16BinaryImageCacheCACycfc", + "moduleName": "Sentry", + "overriding": true, + "objc_name": "init", + "declAttributes": [ + "ObjC", + "Dynamic", + "Override" + ], + "init_kind": "Designated" + }, + { + "kind": "Function", + "name": "stop", + "printedName": "stop()", + "children": [ + { + "kind": "TypeNominal", + "name": "Void", + "printedName": "()" + } + ], + "declKind": "Func", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)stop", + "mangledName": "$s6Sentry0A16BinaryImageCacheC4stopyyF", + "moduleName": "Sentry", + "declAttributes": [ + "ObjC" + ], + "funcSelfKind": "NonMutating" + }, + { + "kind": "Function", + "name": "binaryImageAdded", + "printedName": "binaryImageAdded(imageName:vmAddress:address:size:uuid:)", + "children": [ + { + "kind": "TypeNominal", + "name": "Void", + "printedName": "()" + }, + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "Swift.UnsafePointer?", + "children": [ + { + "kind": "TypeNominal", + "name": "UnsafePointer", + "printedName": "Swift.UnsafePointer", + "children": [ + { + "kind": "TypeNameAlias", + "name": "CChar", + "printedName": "Swift.CChar", + "children": [ + { + "kind": "TypeNominal", + "name": "Int8", + "printedName": "Swift.Int8", + "usr": "s:s4Int8V" + } + ] + } + ], + "usr": "s:SP" + } + ], + "usr": "s:Sq" + }, + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + }, + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + }, + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + }, + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "Swift.UnsafePointer?", + "children": [ + { + "kind": "TypeNominal", + "name": "UnsafePointer", + "printedName": "Swift.UnsafePointer", + "children": [ + { + "kind": "TypeNominal", + "name": "UInt8", + "printedName": "Swift.UInt8", + "usr": "s:s5UInt8V" + } + ], + "usr": "s:SP" + } + ], + "usr": "s:Sq" + } + ], + "declKind": "Func", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)binaryImageAdded:vmAddress:address:size:uuid:", + "mangledName": "$s6Sentry0A16BinaryImageCacheC06binaryC5Added9imageName9vmAddress7address4size4uuidySPys4Int8VGSg_s6UInt64VA2OSPys5UInt8VGSgtF", + "moduleName": "Sentry", + "objc_name": "binaryImageAdded:vmAddress:address:size:uuid:", + "declAttributes": [ + "ObjC" + ], + "funcSelfKind": "NonMutating" + }, + { + "kind": "Function", + "name": "convertUUID", + "printedName": "convertUUID(_:)", + "children": [ + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "Swift.String?", + "children": [ + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + } + ], + "usr": "s:Sq" + }, + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "Swift.UnsafePointer?", + "children": [ + { + "kind": "TypeNominal", + "name": "UnsafePointer", + "printedName": "Swift.UnsafePointer", + "children": [ + { + "kind": "TypeNominal", + "name": "UInt8", + "printedName": "Swift.UInt8", + "usr": "s:s5UInt8V" + } + ], + "usr": "s:SP" + } + ], + "usr": "s:Sq" + } + ], + "declKind": "Func", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(cm)convertUUID:", + "mangledName": "$s6Sentry0A16BinaryImageCacheC11convertUUIDySSSgSPys5UInt8VGSgFZ", + "moduleName": "Sentry", + "static": true, + "declAttributes": [ + "Final", + "ObjC" + ], + "funcSelfKind": "NonMutating" + }, + { + "kind": "Function", + "name": "binaryImageRemoved", + "printedName": "binaryImageRemoved(_:)", + "children": [ + { + "kind": "TypeNominal", + "name": "Void", + "printedName": "()" + }, + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Func", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)binaryImageRemoved:", + "mangledName": "$s6Sentry0A16BinaryImageCacheC06binaryC7Removedyys6UInt64VF", + "moduleName": "Sentry", + "declAttributes": [ + "ObjC" + ], + "funcSelfKind": "NonMutating" + }, + { + "kind": "Function", + "name": "imageByAddress", + "printedName": "imageByAddress(_:)", + "children": [ + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "Sentry.SentryBinaryImageInfo?", + "children": [ + { + "kind": "TypeNominal", + "name": "SentryBinaryImageInfo", + "printedName": "Sentry.SentryBinaryImageInfo", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo" + } + ], + "usr": "s:Sq" + }, + { + "kind": "TypeNominal", + "name": "UInt64", + "printedName": "Swift.UInt64", + "usr": "s:s6UInt64V" + } + ], + "declKind": "Func", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)imageByAddress:", + "mangledName": "$s6Sentry0A16BinaryImageCacheC14imageByAddressyAA0abC4InfoCSgs6UInt64VF", + "moduleName": "Sentry", + "declAttributes": [ + "ObjC" + ], + "funcSelfKind": "NonMutating" + }, + { + "kind": "Function", + "name": "imagePathsFor", + "printedName": "imagePathsFor(inAppInclude:)", + "children": [ + { + "kind": "TypeNominal", + "name": "Set", + "printedName": "Swift.Set", + "children": [ + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + } + ], + "usr": "s:Sh" + }, + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + } + ], + "declKind": "Func", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)imagePathsForInAppInclude:", + "mangledName": "$s6Sentry0A16BinaryImageCacheC13imagePathsFor12inAppIncludeShySSGSS_tF", + "moduleName": "Sentry", + "objc_name": "imagePathsForInAppInclude:", + "declAttributes": [ + "ObjC" + ], + "funcSelfKind": "NonMutating" + }, + { + "kind": "Function", + "name": "getAllBinaryImages", + "printedName": "getAllBinaryImages()", + "children": [ + { + "kind": "TypeNominal", + "name": "Array", + "printedName": "[Sentry.SentryBinaryImageInfo]", + "children": [ + { + "kind": "TypeNominal", + "name": "SentryBinaryImageInfo", + "printedName": "Sentry.SentryBinaryImageInfo", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo" + } + ], + "usr": "s:Sa" + } + ], + "declKind": "Func", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)getAllBinaryImages", + "mangledName": "$s6Sentry0A16BinaryImageCacheC06getAllB6ImagesSayAA0abC4InfoCGyF", + "moduleName": "Sentry", + "declAttributes": [ + "ObjC" + ], + "funcSelfKind": "NonMutating" + } + ], + "declKind": "Class", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache", + "mangledName": "$s6Sentry0A16BinaryImageCacheC", + "moduleName": "Sentry", + "objc_name": "SentryBinaryImageCache", + "declAttributes": [ + "ObjC" + ], + "superclassUsr": "c:objc(cs)NSObject", + "inheritsConvenienceInitializers": true, + "superclassNames": [ + "ObjectiveC.NSObject" + ], + "conformances": [ + { + "kind": "Conformance", + "name": "Copyable", + "printedName": "Copyable", + "usr": "s:s8CopyableP", + "mangledName": "$ss8CopyableP" + }, + { + "kind": "Conformance", + "name": "Escapable", + "printedName": "Escapable", + "usr": "s:s9EscapableP", + "mangledName": "$ss9EscapableP" + }, + { + "kind": "Conformance", + "name": "NSObjectProtocol", + "printedName": "NSObjectProtocol", + "usr": "c:objc(pl)NSObject" + }, + { + "kind": "Conformance", + "name": "Equatable", + "printedName": "Equatable", + "usr": "s:SQ", + "mangledName": "$sSQ" + }, + { + "kind": "Conformance", + "name": "Hashable", + "printedName": "Hashable", + "usr": "s:SH", + "mangledName": "$sSH" + }, + { + "kind": "Conformance", + "name": "CVarArg", + "printedName": "CVarArg", + "usr": "s:s7CVarArgP", + "mangledName": "$ss7CVarArgP" + }, + { + "kind": "Conformance", + "name": "CustomStringConvertible", + "printedName": "CustomStringConvertible", + "usr": "s:s23CustomStringConvertibleP", + "mangledName": "$ss23CustomStringConvertibleP" + }, + { + "kind": "Conformance", + "name": "CustomDebugStringConvertible", + "printedName": "CustomDebugStringConvertible", + "usr": "s:s28CustomDebugStringConvertibleP", + "mangledName": "$ss28CustomDebugStringConvertibleP" + } + ] + }, { "kind": "TypeDecl", "name": "SentryRedactRegionType", From af8a727f8573cd249ed6b2fca45a789a6a24bbdf Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Wed, 27 Aug 2025 16:57:48 -0300 Subject: [PATCH 05/14] Use `SentryDependencyContainerSwiftHelper` for the dispatchQueueWrapper --- Sentry.xcodeproj/project.pbxproj | 16 +- .../Sentry/SentryBinaryImageCacheCallbacks.m | 30 -- .../SentryDependencyContainerSwiftHelper.m | 10 + Sources/Sentry/SentrySDKInternal.m | 4 +- .../include/SentryBinaryImageCacheCallbacks.h | 19 - .../SentryDependencyContainerSwiftHelper.h | 4 + Sources/Sentry/include/SentryPrivate.h | 1 - .../Core/Helper/SentryBinaryImageCache.swift | 36 +- ...SentryUIViewControllerSwizzlingTests.swift | 3 +- .../SentryBinaryImageCacheTests.swift | 9 +- .../SentryCrashBinaryImageCacheTests.m | 331 +++++++++++++++++ .../SentryCrashBinaryImageCacheTests.swift | 348 ------------------ .../SentryCrashStackEntryMapperTests.swift | 3 +- .../SentryDebugImageProviderTests.swift | 3 +- 14 files changed, 384 insertions(+), 433 deletions(-) delete mode 100644 Sources/Sentry/SentryBinaryImageCacheCallbacks.m delete mode 100644 Sources/Sentry/include/SentryBinaryImageCacheCallbacks.h create mode 100644 Tests/SentryTests/SentryCrash/SentryCrashBinaryImageCacheTests.m delete mode 100644 Tests/SentryTests/SentryCrash/SentryCrashBinaryImageCacheTests.swift diff --git a/Sentry.xcodeproj/project.pbxproj b/Sentry.xcodeproj/project.pbxproj index 228b0ddcba8..f0df008187e 100644 --- a/Sentry.xcodeproj/project.pbxproj +++ b/Sentry.xcodeproj/project.pbxproj @@ -939,8 +939,6 @@ D855B3E827D652AF00BCED76 /* SentryCoreDataTrackingIntegrationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = D855B3E727D652AF00BCED76 /* SentryCoreDataTrackingIntegrationTest.swift */; }; D855B3EA27D652C700BCED76 /* TestCoreDataStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = D855B3E927D652C700BCED76 /* TestCoreDataStack.swift */; }; D85852BA27EDDC5900C6D8AE /* SentryUIApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = D85852B827EDDC5900C6D8AE /* SentryUIApplication.m */; }; - D858FA662A29EAB3002A3503 /* SentryBinaryImageCacheCallbacks.h in Headers */ = {isa = PBXBuildFile; fileRef = D858FA642A29EAB3002A3503 /* SentryBinaryImageCacheCallbacks.h */; settings = {ATTRIBUTES = (Private, ); }; }; - D858FA672A29EAB3002A3503 /* SentryBinaryImageCacheCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = D858FA652A29EAB3002A3503 /* SentryBinaryImageCacheCallbacks.m */; }; D859696B27BECD8F0036A46E /* SentryCoreDataTrackingIntegration.m in Sources */ = {isa = PBXBuildFile; fileRef = D859696927BECD8F0036A46E /* SentryCoreDataTrackingIntegration.m */; }; D859696F27BECDA20036A46E /* SentryCoreDataTracker.m in Sources */ = {isa = PBXBuildFile; fileRef = D859696D27BECDA20036A46E /* SentryCoreDataTracker.m */; }; D859697327BECDD20036A46E /* SentryCoreDataSwizzling.m in Sources */ = {isa = PBXBuildFile; fileRef = D859697127BECDD20036A46E /* SentryCoreDataSwizzling.m */; }; @@ -1041,7 +1039,7 @@ F458D1172E186DF20028273E /* SentryScopePersistentStore+Fingerprint.swift in Sources */ = {isa = PBXBuildFile; fileRef = F458D1162E186DF20028273E /* SentryScopePersistentStore+Fingerprint.swift */; }; F458D1192E186E000028273E /* SentryScopePersistentStore+Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = F458D1182E186E000028273E /* SentryScopePersistentStore+Extras.swift */; }; F46DA6C32E1DBCA000DF6E3B /* SentryScopePersistentStore+Helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = F46DA6C22E1DBCA000DF6E3B /* SentryScopePersistentStore+Helper.swift */; }; - F48F74582E5F52C2009D4E7D /* SentryCrashBinaryImageCacheTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F48F74572E5F52C2009D4E7D /* SentryCrashBinaryImageCacheTests.swift */; }; + F48F74F32E5F9959009D4E7D /* SentryCrashBinaryImageCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F48F74F22E5F9959009D4E7D /* SentryCrashBinaryImageCacheTests.m */; }; F49236EB2E5E4B2F00663673 /* SentryBinaryImageCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = F49236EA2E5E4B2F00663673 /* SentryBinaryImageCache.swift */; }; F49D41982DEA27AF00D9244E /* SentryUseNSExceptionCallstackWrapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F49D41972DEA27AF00D9244E /* SentryUseNSExceptionCallstackWrapperTests.swift */; }; F49D419A2DEA2FB000D9244E /* SentryCrashExceptionApplicationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F49D41992DEA2FB000D9244E /* SentryCrashExceptionApplicationTests.swift */; }; @@ -2275,8 +2273,6 @@ D855B3E927D652C700BCED76 /* TestCoreDataStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestCoreDataStack.swift; sourceTree = ""; }; D85790282976A69F00C6AC1F /* TestDebugImageProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestDebugImageProvider.swift; sourceTree = ""; }; D85852B827EDDC5900C6D8AE /* SentryUIApplication.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryUIApplication.m; sourceTree = ""; }; - D858FA642A29EAB3002A3503 /* SentryBinaryImageCacheCallbacks.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryBinaryImageCacheCallbacks.h; path = include/SentryBinaryImageCacheCallbacks.h; sourceTree = ""; }; - D858FA652A29EAB3002A3503 /* SentryBinaryImageCacheCallbacks.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryBinaryImageCacheCallbacks.m; sourceTree = ""; }; D859696927BECD8F0036A46E /* SentryCoreDataTrackingIntegration.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryCoreDataTrackingIntegration.m; sourceTree = ""; }; D859696D27BECDA20036A46E /* SentryCoreDataTracker.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryCoreDataTracker.m; sourceTree = ""; }; D859697127BECDD20036A46E /* SentryCoreDataSwizzling.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryCoreDataSwizzling.m; sourceTree = ""; }; @@ -2388,7 +2384,7 @@ F458D1162E186DF20028273E /* SentryScopePersistentStore+Fingerprint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SentryScopePersistentStore+Fingerprint.swift"; sourceTree = ""; }; F458D1182E186E000028273E /* SentryScopePersistentStore+Extras.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SentryScopePersistentStore+Extras.swift"; sourceTree = ""; }; F46DA6C22E1DBCA000DF6E3B /* SentryScopePersistentStore+Helper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SentryScopePersistentStore+Helper.swift"; sourceTree = ""; }; - F48F74572E5F52C2009D4E7D /* SentryCrashBinaryImageCacheTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryCrashBinaryImageCacheTests.swift; sourceTree = ""; }; + F48F74F22E5F9959009D4E7D /* SentryCrashBinaryImageCacheTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryCrashBinaryImageCacheTests.m; sourceTree = ""; }; F49236EA2E5E4B2F00663673 /* SentryBinaryImageCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryBinaryImageCache.swift; sourceTree = ""; }; F49D41972DEA27AF00D9244E /* SentryUseNSExceptionCallstackWrapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUseNSExceptionCallstackWrapperTests.swift; sourceTree = ""; }; F49D41992DEA2FB000D9244E /* SentryCrashExceptionApplicationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryCrashExceptionApplicationTests.swift; sourceTree = ""; }; @@ -2955,8 +2951,6 @@ FAB359992E05D8080083D5E3 /* SentryEventSwiftHelper.m */, 33042A0B29DAF5F400C60085 /* SentryExtraContextProvider.h */, 33042A0C29DAF79A00C60085 /* SentryExtraContextProvider.m */, - D858FA642A29EAB3002A3503 /* SentryBinaryImageCacheCallbacks.h */, - D858FA652A29EAB3002A3503 /* SentryBinaryImageCacheCallbacks.m */, D8739D152BEEA33F007D2F66 /* SentryLevelHelper.h */, D8739D162BEEA33F007D2F66 /* SentryLevelHelper.m */, F452438B2DE65BC0003E8F50 /* SentryUseNSExceptionCallstackWrapper.h */, @@ -3291,9 +3285,9 @@ 63FE71D220DA66C500CDBAE8 /* SentryCrash */ = { isa = PBXGroup; children = ( + F48F74F22E5F9959009D4E7D /* SentryCrashBinaryImageCacheTests.m */, F4AACD602E01ACE800DDDD1E /* SentryCrashDynamicLinkerTests.m */, 63FE71F120DA66EA00CDBAE8 /* Container+DeepSearch_Tests.m */, - F48F74572E5F52C2009D4E7D /* SentryCrashBinaryImageCacheTests.swift */, 63FE71F620DA66EB00CDBAE8 /* FileBasedTestCase.h */, 63FE71D920DA66E700CDBAE8 /* FileBasedTestCase.m */, 84EB21952BF01CEA00EDDA28 /* SentryCrashInstallationTests.swift */, @@ -4985,7 +4979,6 @@ 8E4A037825F6F52100000D77 /* SentrySampleDecision.h in Headers */, 63FE717920DA4C1100CDBAE8 /* SentryCrashReportStore.h in Headers */, 0AAE202128ED9BCC00D0CD80 /* SentryReachability.h in Headers */, - D858FA662A29EAB3002A3503 /* SentryBinaryImageCacheCallbacks.h in Headers */, A839D89824864B80003B7AFD /* SentrySystemEventBreadcrumbs.h in Headers */, 7B14089624878F090035403D /* SentryCrashStackEntryMapper.h in Headers */, 63FE714920DA4C1100CDBAE8 /* SentryCrashStackCursor_Backtrace.h in Headers */, @@ -5682,7 +5675,6 @@ D473ACD72D8090FC000F1CC6 /* FileManager+SentryTracing.swift in Sources */, D4AF00212D2E92FD00F5F3D7 /* SentryNSFileManagerSwizzling.m in Sources */, 639FCFA91EBC80CC00778193 /* SentryFrame.m in Sources */, - D858FA672A29EAB3002A3503 /* SentryBinaryImageCacheCallbacks.m in Sources */, 8E564AEA267AF22600FE117D /* SentryNetworkTracker.m in Sources */, 15360CED2433A15500112302 /* SentryInstallation.m in Sources */, D8370B6A273DF1E900F66E2D /* SentryNSURLSessionTaskSearch.m in Sources */, @@ -6088,7 +6080,6 @@ 7B6C5ED6264E62CA0010D138 /* SentryTransactionTests.swift in Sources */, D81FDF12280EA1060045E0E4 /* SentryScreenShotTests.swift in Sources */, D8019910286B089000C277F0 /* SentryCrashReportSinkTests.swift in Sources */, - F48F74582E5F52C2009D4E7D /* SentryCrashBinaryImageCacheTests.swift in Sources */, D885266427739D01001269FC /* SentryFileIOTrackingIntegrationTests.swift in Sources */, 7BBD18992449DE9D00427C76 /* TestRateLimits.swift in Sources */, 7B04A9AB24EA5F8D00E710B1 /* SentryUserTests.swift in Sources */, @@ -6126,6 +6117,7 @@ D46712622DCD059900D4074A /* SentryRedactDefaultOptionsTests.swift in Sources */, D480F9DB2DE47AF2009A0594 /* SentryScopePersistentStoreTests.swift in Sources */, F4DC35582E1FFE1F0077CE89 /* SentryVideoFrameProcessorTests.swift in Sources */, + F48F74F32E5F9959009D4E7D /* SentryCrashBinaryImageCacheTests.m in Sources */, 7BC6EC18255C44540059822A /* SentryDebugMetaTests.swift in Sources */, A811D867248E2770008A41EA /* SentrySystemEventBreadcrumbsTest.swift in Sources */, 7B82D54924E2A2D400EE670F /* SentryIdTests.swift in Sources */, diff --git a/Sources/Sentry/SentryBinaryImageCacheCallbacks.m b/Sources/Sentry/SentryBinaryImageCacheCallbacks.m deleted file mode 100644 index c0a9c4f699b..00000000000 --- a/Sources/Sentry/SentryBinaryImageCacheCallbacks.m +++ /dev/null @@ -1,30 +0,0 @@ -#import "SentryBinaryImageCacheCallbacks.h" -#import "SentryDependencyContainer.h" -#import "SentryInternalDefines.h" -#import "SentrySwift.h" - -// Used to call SentryDependencyContainer, since it isn't available to swift yet -void -binaryImageWasAdded(const SentryCrashBinaryImage *_Nullable image) -{ - if (image == NULL) { - SENTRY_LOG_WARN(@"The image is NULL. Can't add NULL to cache."); - return; - } - [SentryDependencyContainer.sharedInstance.binaryImageCache binaryImageAdded:image->name - vmAddress:image->vmAddress - address:image->address - size:image->size - uuid:image->uuid]; -} - -// Used to call SentryDependencyContainer, since it isn't available to swift yet -void -binaryImageWasRemoved(const SentryCrashBinaryImage *_Nullable image) -{ - if (image == NULL) { - SENTRY_LOG_WARN(@"The image is NULL. Can't remove it from the cache."); - return; - } - [SentryDependencyContainer.sharedInstance.binaryImageCache binaryImageRemoved:image->address]; -} diff --git a/Sources/Sentry/SentryDependencyContainerSwiftHelper.m b/Sources/Sentry/SentryDependencyContainerSwiftHelper.m index 8a6edaddd8d..606e8fd7c27 100644 --- a/Sources/Sentry/SentryDependencyContainerSwiftHelper.m +++ b/Sources/Sentry/SentryDependencyContainerSwiftHelper.m @@ -30,4 +30,14 @@ + (SentryHub *)currentHub return SentrySDKInternal.currentHub; } ++ (SentryDispatchQueueWrapper *)dispatchQueueWrapper +{ + return SentryDependencyContainer.sharedInstance.dispatchQueueWrapper; +} + ++ (SentryBinaryImageCache *)binaryImageCache +{ + return SentryDependencyContainer.sharedInstance.binaryImageCache; +} + @end diff --git a/Sources/Sentry/SentrySDKInternal.m b/Sources/Sentry/SentrySDKInternal.m index 81d82a0d1b5..1388c1844ba 100644 --- a/Sources/Sentry/SentrySDKInternal.m +++ b/Sources/Sentry/SentrySDKInternal.m @@ -286,9 +286,7 @@ + (void)startWithOptions:(SentryOptions *)options [SentrySDKInternal setCurrentHub:hub]; [SentryCrashWrapper.sharedInstance startBinaryImageCache]; - [SentryDependencyContainer.sharedInstance.binaryImageCache - start:options.debug - dispatchQueueWrapper:SentryDependencyContainer.sharedInstance.dispatchQueueWrapper]; + [SentryDependencyContainer.sharedInstance.binaryImageCache start:options.debug]; [SentrySDKInternal installIntegrations]; diff --git a/Sources/Sentry/include/SentryBinaryImageCacheCallbacks.h b/Sources/Sentry/include/SentryBinaryImageCacheCallbacks.h deleted file mode 100644 index 9d714a22b4e..00000000000 --- a/Sources/Sentry/include/SentryBinaryImageCacheCallbacks.h +++ /dev/null @@ -1,19 +0,0 @@ -#import - -#if __has_include() -# import -#else -# import "SentryCrashDynamicLinker.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -void binaryImageWasAdded(const SentryCrashBinaryImage *_Nullable image); - -void binaryImageWasRemoved(const SentryCrashBinaryImage *_Nullable image); - -#ifdef __cplusplus -} -#endif diff --git a/Sources/Sentry/include/SentryDependencyContainerSwiftHelper.h b/Sources/Sentry/include/SentryDependencyContainerSwiftHelper.h index 7572abdc3d2..3f006363031 100644 --- a/Sources/Sentry/include/SentryDependencyContainerSwiftHelper.h +++ b/Sources/Sentry/include/SentryDependencyContainerSwiftHelper.h @@ -7,6 +7,8 @@ @protocol SentryObjCRuntimeWrapper; @class SentryHub; +@class SentryDispatchQueueWrapper; +@class SentryBinaryImageCache; NS_ASSUME_NONNULL_BEGIN @@ -25,6 +27,8 @@ NS_ASSUME_NONNULL_BEGIN + (void)dispatchSyncOnMainQueue:(void (^)(void))block; + (id)objcRuntimeWrapper; + (SentryHub *)currentHub; ++ (SentryDispatchQueueWrapper *)dispatchQueueWrapper; ++ (SentryBinaryImageCache *)binaryImageCache; @end diff --git a/Sources/Sentry/include/SentryPrivate.h b/Sources/Sentry/include/SentryPrivate.h index 5af46a02d3e..fabd337c304 100644 --- a/Sources/Sentry/include/SentryPrivate.h +++ b/Sources/Sentry/include/SentryPrivate.h @@ -1,7 +1,6 @@ // Sentry internal headers that are needed for swift code; you cannot import headers that depend on // public interfaces here #import "NSLocale+Sentry.h" -#import "SentryBinaryImageCacheCallbacks.h" #import "SentryCrashBinaryImageCache.h" #import "SentryCrashDynamicLinker.h" #import "SentryCrashExceptionApplicationHelper.h" diff --git a/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift b/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift index c2475ee8b95..2dadbfc358a 100644 --- a/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift +++ b/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift @@ -30,17 +30,11 @@ public class SentryBinaryImageCache: NSObject { private var isDebug: Bool = false // Use a recursive lock to allow the same thread to enter again private let lock = NSRecursiveLock() - private var dispatchQueueWrapper: SentryDispatchQueueWrapper! - @objc public override init() { - self.isDebug = false - } - - @_spi(Private) @objc public func start(_ isDebug: Bool, dispatchQueueWrapper: SentryDispatchQueueWrapper) { + @_spi(Private) @objc public func start(_ isDebug: Bool) { lock.synchronized { self.isDebug = isDebug self.cache = [] - self.dispatchQueueWrapper = dispatchQueueWrapper sentrycrashbic_registerAddedCallback(binaryImageWasAdded) sentrycrashbic_registerRemovedCallback(binaryImageWasRemoved) } @@ -104,7 +98,7 @@ public class SentryBinaryImageCache: NSObject { LoadValidator.checkForDuplicatedSDK(imageName: nameString, imageAddress: NSNumber(value: newImage.address), imageSize: NSNumber(value: newImage.size), - dispatchQueueWrapper: dispatchQueueWrapper) + dispatchQueueWrapper: SentryDependencyContainerSwiftHelper.dispatchQueueWrapper()) } } @@ -178,5 +172,31 @@ public class SentryBinaryImageCache: NSObject { lock.synchronized { return cache ?? [] } + } +} + +// MARK: - C Callback Functions + +private func binaryImageWasAdded(_ image: UnsafePointer?) { + guard let image = image else { + SentrySDKLog.warning("The image is NULL. Can't add NULL to cache.") + return } + + SentryDependencyContainerSwiftHelper.binaryImageCache().binaryImageAdded( + imageName: image.pointee.name, + vmAddress: image.pointee.vmAddress, + address: image.pointee.address, + size: image.pointee.size, + uuid: image.pointee.uuid + ) +} + +private func binaryImageWasRemoved(_ image: UnsafePointer?) { + guard let image = image else { + SentrySDKLog.warning("The image is NULL. Can't remove it from the cache.") + return + } + + SentryDependencyContainerSwiftHelper.binaryImageCache().binaryImageRemoved(image.pointee.address) } diff --git a/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerSwizzlingTests.swift b/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerSwizzlingTests.swift index 707be20da5b..ac847e98cf4 100644 --- a/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerSwizzlingTests.swift +++ b/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerSwizzlingTests.swift @@ -205,8 +205,7 @@ class SentryUIViewControllerSwizzlingTests: XCTestCase { let debugDylib = "\(imageName).debug.dylib" let image = createCrashBinaryImage(0, name: debugDylib) - let dispatchQueueWrapper = TestSentryDispatchQueueWrapper() - SentryDependencyContainer.sharedInstance().binaryImageCache.start(false, dispatchQueueWrapper: dispatchQueueWrapper) + SentryDependencyContainer.sharedInstance().binaryImageCache.start(false) SentryDependencyContainer.sharedInstance().binaryImageCache.binaryImageAdded(imageName: image.name, vmAddress: image.vmAddress, address: image.address, diff --git a/Tests/SentryTests/SentryBinaryImageCacheTests.swift b/Tests/SentryTests/SentryBinaryImageCacheTests.swift index cc24376fc2c..277a63d5c47 100644 --- a/Tests/SentryTests/SentryBinaryImageCacheTests.swift +++ b/Tests/SentryTests/SentryBinaryImageCacheTests.swift @@ -9,8 +9,7 @@ class SentryBinaryImageCacheTests: XCTestCase { override func setUp() { super.setUp() - let dispatchQueueWrapper = TestSentryDispatchQueueWrapper() - sut.start(false, dispatchQueueWrapper: dispatchQueueWrapper) + sut.start(false) } override func tearDown() { @@ -198,7 +197,6 @@ class SentryBinaryImageCacheTests: XCTestCase { let expectation = expectation(description: "Add images on background thread") expectation.expectedFulfillmentCount = count - let dispatchQueueWrapper = TestSentryDispatchQueueWrapper() for i in 0.. + +#include +#include + +// Exposing test only functions from `SentryCrashBinaryImageCache.m` +void sentry_setRegisterFuncForAddImage(void *addFunction); +void sentry_setRegisterFuncForRemoveImage(void *removeFunction); +void sentry_resetFuncForAddRemoveImage(void); +void sentry_setFuncForBeforeAdd(void (*callback)(void)); + +static void (*addBinaryImage)(const struct mach_header *mh, intptr_t vmaddr_slide); +static void (*removeBinaryImage)(const struct mach_header *mh, intptr_t vmaddr_slide); +static NSMutableArray *mach_headers_test_cache; +static NSMutableArray *mach_headers_expect_array; + +static void +sentry_register_func_for_add_image( + void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide)) +{ + addBinaryImage = func; + + if (mach_headers_expect_array) { + // Skipping first item which is dyld and already included when starting the cache + for (NSUInteger i = 1; i < mach_headers_expect_array.count; i++) { + NSValue *header = mach_headers_expect_array[i]; + func(header.pointerValue, 0); + } + } +} + +static void +sentry_register_func_for_remove_image( + void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide)) +{ + removeBinaryImage = func; +} + +static void +cacheMachHeaders(const struct mach_header *mh, __unused intptr_t vmaddr_slide) +{ + [mach_headers_test_cache addObject:[NSValue valueWithPointer:mh]]; +} + +static void +countNumberOfImagesInCache(__unused SentryCrashBinaryImage *image, void *context) +{ + int *counter = context; + (*counter)++; +} + +static void +addBinaryImageToArray(SentryCrashBinaryImage *image, void *context) +{ + NSMutableArray *array = (__bridge NSMutableArray *)context; + [array addObject:[NSValue valueWithPointer:image]]; +} + +dispatch_semaphore_t delaySemaphore = NULL; +dispatch_semaphore_t delayCalled = NULL; +static void +delayAddBinaryImage(void) +{ + if (delayCalled) { + dispatch_semaphore_signal(delayCalled); + } + if (delaySemaphore) { + dispatch_semaphore_wait(delaySemaphore, DISPATCH_TIME_FOREVER); + } +} + +@interface SentryCrashBinaryImageCacheTests : XCTestCase + +@end + +@implementation SentryCrashBinaryImageCacheTests + ++ (void)setUp +{ + // Create a test cache of actual binary images to be used during tests. + mach_headers_test_cache = [NSMutableArray array]; + + // Manually include dyld + sentrycrashdl_initialize(); + [mach_headers_test_cache addObject:[NSValue valueWithPointer:sentryDyldHeader]]; + _dyld_register_func_for_add_image(&cacheMachHeaders); +} + +- (void)setUp +{ + sentry_setRegisterFuncForAddImage(&sentry_register_func_for_add_image); + sentry_setRegisterFuncForRemoveImage(&sentry_register_func_for_remove_image); + + // Copying the first 5 images from the temporary list. + // 5 is a magic number. + mach_headers_expect_array = + [mach_headers_test_cache subarrayWithRange:NSMakeRange(0, 5)].mutableCopy; +} + +- (void)tearDown +{ + sentrycrashdl_clearDyld(); + sentry_resetFuncForAddRemoveImage(); + sentrycrashbic_stopCache(); + sentry_setFuncForBeforeAdd(NULL); + [SentryDependencyContainer reset]; +} + +- (void)testStartCache +{ + [[SentryCrashWrapper sharedInstance] startBinaryImageCache]; + [self assertBinaryImageCacheLength:5]; +} + +- (void)testStartCacheTwice +{ + sentrycrashbic_startCache(); + [self assertBinaryImageCacheLength:5]; + + sentrycrashbic_startCache(); + [self assertBinaryImageCacheLength:5]; +} + +- (void)testStopCache +{ + sentrycrashbic_startCache(); + [self assertBinaryImageCacheLength:5]; + sentrycrashbic_stopCache(); + [self assertBinaryImageCacheLength:0]; +} + +- (void)testStopCacheTwice +{ + sentrycrashbic_startCache(); + [self assertBinaryImageCacheLength:5]; + sentrycrashbic_stopCache(); + [self assertBinaryImageCacheLength:0]; + sentrycrashbic_stopCache(); + [self assertBinaryImageCacheLength:0]; +} + +- (void)testAddNewImage +{ + sentrycrashbic_startCache(); + [self assertBinaryImageCacheLength:5]; + + addBinaryImage([mach_headers_test_cache[5] pointerValue], 0); + mach_headers_expect_array = + [mach_headers_test_cache subarrayWithRange:NSMakeRange(0, 6)].mutableCopy; + [self assertBinaryImageCacheLength:6]; + [self assertCachedBinaryImages]; + + addBinaryImage([mach_headers_test_cache[6] pointerValue], 0); + mach_headers_expect_array = + [mach_headers_test_cache subarrayWithRange:NSMakeRange(0, 7)].mutableCopy; + [self assertBinaryImageCacheLength:7]; + [self assertCachedBinaryImages]; +} + +- (void)testAddInvalidHeader +{ + sentrycrashbic_startCache(); + [self assertBinaryImageCacheLength:5]; + + addBinaryImage(0, 0); + [self assertBinaryImageCacheLength:5]; +} + +- (void)testAddNewImageAfterStopping +{ + sentrycrashbic_startCache(); + [self assertBinaryImageCacheLength:5]; + + sentrycrashbic_stopCache(); + addBinaryImage([mach_headers_test_cache[6] pointerValue], 0); + [self assertBinaryImageCacheLength:0]; +} + +- (void)testRemoveImageFromTail +{ + sentrycrashbic_startCache(); + [self assertBinaryImageCacheLength:5]; + + removeBinaryImage([mach_headers_expect_array[4] pointerValue], 0); + [self assertBinaryImageCacheLength:4]; + [self assertCachedBinaryImages]; + + removeBinaryImage([mach_headers_expect_array[3] pointerValue], 0); + [self assertBinaryImageCacheLength:3]; + [self assertCachedBinaryImages]; +} + +- (void)testRemoveImageFromBeginning +{ + sentrycrashbic_startCache(); + [self assertBinaryImageCacheLength:5]; + + removeBinaryImage([mach_headers_expect_array[0] pointerValue], 0); + [self assertBinaryImageCacheLength:4]; + [mach_headers_expect_array removeObjectAtIndex:0]; + [self assertCachedBinaryImages]; + + removeBinaryImage([mach_headers_expect_array[0] pointerValue], 0); + [self assertBinaryImageCacheLength:3]; + [mach_headers_expect_array removeObjectAtIndex:0]; + [self assertCachedBinaryImages]; +} + +- (void)testRemoveImageAddAgain +{ + // Use index 1 since we can't dynamically insert dyld image (`dladdr` returns null) + int indexToRemove = 1; + + sentrycrashbic_startCache(); + [self assertBinaryImageCacheLength:5]; + + removeBinaryImage([mach_headers_expect_array[indexToRemove] pointerValue], 0); + [self assertBinaryImageCacheLength:4]; + + NSValue *removeItem = mach_headers_expect_array[indexToRemove]; + [mach_headers_expect_array removeObjectAtIndex:indexToRemove]; + [self assertCachedBinaryImages]; + + addBinaryImage(removeItem.pointerValue, 0); + [self assertBinaryImageCacheLength:5]; + [mach_headers_expect_array insertObject:removeItem atIndex:4]; + [self assertCachedBinaryImages]; +} + +- (void)testAddBinaryImageInParallel +{ + sentrycrashbic_startCache(); + dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); + + // Guard against underflow when mach_headers_test_cache.count < 5 + // because otherwise the expectedFulfillmentCount for the test expectation will be negative. + NSInteger taskCount = mach_headers_test_cache.count - 5; + if (taskCount <= 0) { + XCTFail(@"Expected a positive task count, but got %ld", taskCount); + return; + } + + XCTestExpectation *expectation = + [self expectationWithDescription:@"Add binary images in parallel"]; + expectation.expectedFulfillmentCount = taskCount; + + for (NSUInteger i = 5; i < mach_headers_test_cache.count; i++) { + dispatch_async(queue, ^{ + addBinaryImage([mach_headers_test_cache[i] pointerValue], 0); + [expectation fulfill]; + }); + } + + [self waitForExpectations:@[ expectation ] timeout:5.0]; + + [self assertBinaryImageCacheLength:(int)mach_headers_test_cache.count]; +} + +- (void)testCloseCacheWhileAdding +{ + sentrycrashbic_startCache(); + sentry_setFuncForBeforeAdd(&delayAddBinaryImage); + delaySemaphore = dispatch_semaphore_create(0); + delayCalled = dispatch_semaphore_create(0); + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), + ^{ addBinaryImage([mach_headers_test_cache[6] pointerValue], 0); }); + + intptr_t result + = dispatch_semaphore_wait(delayCalled, dispatch_time(DISPATCH_TIME_NOW, 5 * NSEC_PER_SEC)); + sentrycrashbic_stopCache(); + dispatch_semaphore_signal(delaySemaphore); + [self assertBinaryImageCacheLength:0]; + XCTAssertEqual(result, 0); +} + +// Adding a SentryBinaryImageCache test inside +// SentryCrashBinaryImageCache to test integration between both +// because is easier to control SentryCrashBinaryImageCache in an objc test +- (void)testSentryBinaryImageCacheIntegration +{ + sentrycrashbic_startCache(); + + SentryBinaryImageCache *imageCache = SentryDependencyContainer.sharedInstance.binaryImageCache; + [imageCache start:false]; + // by calling start, SentryBinaryImageCache will register a callback with + // `SentryCrashBinaryImageCache` that should be called for every image already cached. + XCTAssertEqual(5, imageCache.cache.count); + + addBinaryImage([mach_headers_test_cache[5] pointerValue], 0); + XCTAssertEqual(6, imageCache.cache.count); + + removeBinaryImage([mach_headers_expect_array[1] pointerValue], 0); + removeBinaryImage([mach_headers_expect_array[2] pointerValue], 0); + XCTAssertEqual(4, imageCache.cache.count); + [imageCache stop]; + + addBinaryImage([mach_headers_test_cache[6] pointerValue], 0); + XCTAssertNil(imageCache.cache); +} + +- (void)assertBinaryImageCacheLength:(int)expected +{ + int counter = 0; + sentrycrashbic_iterateOverImages(countNumberOfImagesInCache, &counter); + XCTAssertEqual(counter, expected); +} + +- (void)assertCachedBinaryImages +{ + NSArray *cached = [self binaryImageCacheToArray]; + for (NSUInteger i = 0; i < cached.count; i++) { + SentryCrashBinaryImage *binaryImage = [cached[i] pointerValue]; + struct mach_header *header = [mach_headers_expect_array[i] pointerValue]; + XCTAssertEqual(binaryImage->address, (uint64_t)header); + } +} + +- (NSArray *)binaryImageCacheToArray +{ + NSMutableArray *result = [NSMutableArray array]; + sentrycrashbic_iterateOverImages(addBinaryImageToArray, (__bridge void *)(result)); + return result; +} + +@end diff --git a/Tests/SentryTests/SentryCrash/SentryCrashBinaryImageCacheTests.swift b/Tests/SentryTests/SentryCrash/SentryCrashBinaryImageCacheTests.swift deleted file mode 100644 index 0227ed28f03..00000000000 --- a/Tests/SentryTests/SentryCrash/SentryCrashBinaryImageCacheTests.swift +++ /dev/null @@ -1,348 +0,0 @@ -import MachO -@_spi(Private) @testable import Sentry -@_spi(Private) @testable import SentryTestUtils -import XCTest - -// Import C functions from the SentryCrashBinaryImageCache -// These are test-only functions exposed from the implementation -@_silgen_name("sentry_setRegisterFuncForAddImage") -func sentry_setRegisterFuncForAddImage(_ addFunction: UnsafeMutableRawPointer?) - -@_silgen_name("sentry_setRegisterFuncForRemoveImage") -func sentry_setRegisterFuncForRemoveImage(_ removeFunction: UnsafeMutableRawPointer?) - -@_silgen_name("sentry_resetFuncForAddRemoveImage") -func sentry_resetFuncForAddRemoveImage() - -@_silgen_name("sentry_setFuncForBeforeAdd") -func sentry_setFuncForBeforeAdd(_ callback: (@convention(c) () -> Void)?) - -@_silgen_name("sentrycrashbic_iterateOverImages") -func sentrycrashbic_iterateOverImages(_ callback: (@convention(c) (UnsafeMutablePointer, UnsafeMutableRawPointer?) -> Void)?, _ context: UnsafeMutableRawPointer?) - -@_silgen_name("sentrycrashdl_clearDyld") -func sentrycrashdl_clearDyld() - -// Global variables to mirror the Objective-C implementation -private var addBinaryImageFunc: (@convention(c) (UnsafePointer?, Int) -> Void)? -private var removeBinaryImageFunc: (@convention(c) (UnsafePointer?, Int) -> Void)? -private var machHeadersTestCache: [UnsafeRawPointer] = [] -private var machHeadersExpectArray: [UnsafeRawPointer] = [] - -// Semaphores for testing parallel operations -private var delaySemaphore: DispatchSemaphore? -private var delayCalled: DispatchSemaphore? - -// C callback functions -private let sentryRegisterFuncForAddImage: @convention(c) ((@convention(c) (UnsafePointer?, Int) -> Void)?) -> Void = -{ function in - addBinaryImageFunc = function - - if !machHeadersExpectArray.isEmpty { - // Skip first item which is dyld and already included when starting the cache - for i in 1..?, Int) -> Void)?) -> Void = { function in - removeBinaryImageFunc = function -} - -private let cacheMachHeaders: @convention(c) (UnsafePointer?, Int) -> Void = { mh, _ in - guard let mh = mh else { return } - machHeadersTestCache.append(UnsafeRawPointer(mh)) -} - -private let countNumberOfImagesInCache: @convention(c) (UnsafeMutablePointer, UnsafeMutableRawPointer?) -> Void = { _, context in - guard let context = context else { return } - let counter = context.assumingMemoryBound(to: Int.self) - counter.pointee += 1 -} - -private let addBinaryImageToArray: @convention(c) (UnsafeMutablePointer, UnsafeMutableRawPointer?) -> Void = { image, context in - guard let context = context else { return } - let array = Unmanaged.fromOpaque(context).takeUnretainedValue() - array.add(NSValue(pointer: image)) -} - -private let delayAddBinaryImage: @convention(c) () -> Void = { - if let delayCalled = delayCalled { - delayCalled.signal() - } - if let delaySemaphore = delaySemaphore { - delaySemaphore.wait() - } -} - -class SentryCrashBinaryImageCacheTests: XCTestCase { - - override class func setUp() { - super.setUp() - // Create a test cache of actual binary images to be used during tests - machHeadersTestCache = [] - - // Manually include dyld - sentrycrashdl_initialize() - if let dyldHeader = sentryDyldHeader { - machHeadersTestCache.append(UnsafeRawPointer(dyldHeader)) - } - _dyld_register_func_for_add_image(cacheMachHeaders) - } - - override func setUp() { - super.setUp() - sentry_setRegisterFuncForAddImage(unsafeBitCast(sentryRegisterFuncForAddImage, to: UnsafeMutableRawPointer.self)) - sentry_setRegisterFuncForRemoveImage(unsafeBitCast(sentryRegisterFuncForRemoveImage, to: UnsafeMutableRawPointer.self)) - - // Copy the first 5 images from the temporary list - // 5 is a magic number from the original implementation - let endIndex = min(5, machHeadersTestCache.count) - machHeadersExpectArray = Array(machHeadersTestCache[0.. 5 { - let header = machHeadersTestCache[5].assumingMemoryBound(to: mach_header.self) - addBinaryImageFunc?(header, 0) - machHeadersExpectArray = Array(machHeadersTestCache[0..<6]) - assertBinaryImageCacheLength(6) - assertCachedBinaryImages() - } - - if machHeadersTestCache.count > 6 { - let header = machHeadersTestCache[6].assumingMemoryBound(to: mach_header.self) - addBinaryImageFunc?(header, 0) - machHeadersExpectArray = Array(machHeadersTestCache[0..<7]) - assertBinaryImageCacheLength(7) - assertCachedBinaryImages() - } - } - - func testAddInvalidHeader() { - sentrycrashbic_startCache() - assertBinaryImageCacheLength(5) - - addBinaryImageFunc?(nil, 0) - assertBinaryImageCacheLength(5) - } - - func testAddNewImageAfterStopping() { - sentrycrashbic_startCache() - assertBinaryImageCacheLength(5) - - sentrycrashbic_stopCache() - if machHeadersTestCache.count > 6 { - let header = machHeadersTestCache[6].assumingMemoryBound(to: mach_header.self) - addBinaryImageFunc?(header, 0) - } - assertBinaryImageCacheLength(0) - } - - func testRemoveImageFromTail() { - sentrycrashbic_startCache() - assertBinaryImageCacheLength(5) - - let header4 = machHeadersExpectArray[4].assumingMemoryBound(to: mach_header.self) - removeBinaryImageFunc?(header4, 0) - assertBinaryImageCacheLength(4) - assertCachedBinaryImages() - - let header3 = machHeadersExpectArray[3].assumingMemoryBound(to: mach_header.self) - removeBinaryImageFunc?(header3, 0) - assertBinaryImageCacheLength(3) - assertCachedBinaryImages() - } - - func testRemoveImageFromBeginning() { - sentrycrashbic_startCache() - assertBinaryImageCacheLength(5) - - let header0 = machHeadersExpectArray[0].assumingMemoryBound(to: mach_header.self) - removeBinaryImageFunc?(header0, 0) - assertBinaryImageCacheLength(4) - machHeadersExpectArray.removeFirst() - assertCachedBinaryImages() - - let newHeader0 = machHeadersExpectArray[0].assumingMemoryBound(to: mach_header.self) - removeBinaryImageFunc?(newHeader0, 0) - assertBinaryImageCacheLength(3) - machHeadersExpectArray.removeFirst() - assertCachedBinaryImages() - } - - func testRemoveImageAddAgain() { - // Use index 1 since we can't dynamically insert dyld image (`dladdr` returns null) - let indexToRemove = 1 - - sentrycrashbic_startCache() - assertBinaryImageCacheLength(5) - - let headerToRemove = machHeadersExpectArray[indexToRemove].assumingMemoryBound(to: mach_header.self) - removeBinaryImageFunc?(headerToRemove, 0) - assertBinaryImageCacheLength(4) - - let removeItem = machHeadersExpectArray[indexToRemove] - machHeadersExpectArray.remove(at: indexToRemove) - assertCachedBinaryImages() - - addBinaryImageFunc?(removeItem.assumingMemoryBound(to: mach_header.self), 0) - assertBinaryImageCacheLength(5) - machHeadersExpectArray.insert(removeItem, at: 4) - assertCachedBinaryImages() - } - - func testAddBinaryImageInParallel() { - sentrycrashbic_startCache() - let queue = DispatchQueue.global(qos: .default) - - // Guard against underflow when machHeadersTestCache.count < 5 - let taskCount = machHeadersTestCache.count - 5 - guard taskCount > 0 else { - XCTFail("Expected a positive task count, but got \(taskCount)") - return - } - - let expectation = self.expectation(description: "Add binary images in parallel") - expectation.expectedFulfillmentCount = taskCount - - for i in 5.. 6 { - let header = machHeadersTestCache[6].assumingMemoryBound(to: mach_header.self) - addBinaryImageFunc?(header, 0) - } - } - - let result = delayCalled?.wait(timeout: .now() + 5) - sentrycrashbic_stopCache() - delaySemaphore?.signal() - assertBinaryImageCacheLength(0) - XCTAssertEqual(result, .success) - } - - // Adding a SentryBinaryImageCache test inside SentryCrashBinaryImageCache to test integration - // The test is in Swift because of some classes are not available to Objective-C - func testSentryBinaryImageCacheIntegration() { - sentrycrashbic_startCache() - - let imageCache = SentryDependencyContainer.sharedInstance().binaryImageCache - let dispatchQueueWrapper = TestSentryDispatchQueueWrapper() - imageCache.start(false, dispatchQueueWrapper: dispatchQueueWrapper) - // By calling start, SentryBinaryImageCache will register a callback with - // `SentryCrashBinaryImageCache` that should be called for every image already cached. - XCTAssertEqual(5, imageCache.cache?.count ?? 0) - - if machHeadersTestCache.count > 5 { - let header = machHeadersTestCache[5].assumingMemoryBound(to: mach_header.self) - addBinaryImageFunc?(header, 0) - XCTAssertEqual(6, imageCache.cache?.count ?? 0) - } - - if machHeadersExpectArray.count > 1 { - let header1 = machHeadersExpectArray[1].assumingMemoryBound(to: mach_header.self) - removeBinaryImageFunc?(header1, 0) - } - - if machHeadersExpectArray.count > 2 { - let header2 = machHeadersExpectArray[2].assumingMemoryBound(to: mach_header.self) - removeBinaryImageFunc?(header2, 0) - } - - XCTAssertEqual(4, imageCache.cache?.count ?? 0) - imageCache.stop() - - if machHeadersTestCache.count > 6 { - let header = machHeadersTestCache[6].assumingMemoryBound(to: mach_header.self) - addBinaryImageFunc?(header, 0) - } - XCTAssertNil(imageCache.cache) - } - - // MARK: - Helper Methods - - private func assertBinaryImageCacheLength(_ expected: Int) { - var counter = 0 - withUnsafeMutablePointer(to: &counter) { counterPtr in - sentrycrashbic_iterateOverImages(countNumberOfImagesInCache, UnsafeMutableRawPointer(counterPtr)) - } - XCTAssertEqual(counter, expected) - } - - private func assertCachedBinaryImages() { - let cached = binaryImageCacheToArray() - for i in 0.. NSArray { - let result = NSMutableArray() - let unmanagedArray = Unmanaged.passUnretained(result) - sentrycrashbic_iterateOverImages(addBinaryImageToArray, unmanagedArray.toOpaque()) - return result - } -} diff --git a/Tests/SentryTests/SentryCrash/SentryCrashStackEntryMapperTests.swift b/Tests/SentryTests/SentryCrash/SentryCrashStackEntryMapperTests.swift index c95fb067d33..ab4afee4b42 100644 --- a/Tests/SentryTests/SentryCrash/SentryCrashStackEntryMapperTests.swift +++ b/Tests/SentryTests/SentryCrash/SentryCrashStackEntryMapperTests.swift @@ -87,8 +87,7 @@ class SentryCrashStackEntryMapperTests: XCTestCase { func testImageFromCache() { let image = createCrashBinaryImage(2_488_998_912) - let dispatchQueueWrapper = TestSentryDispatchQueueWrapper() - SentryDependencyContainer.sharedInstance().binaryImageCache.start(false, dispatchQueueWrapper: dispatchQueueWrapper) + SentryDependencyContainer.sharedInstance().binaryImageCache.start(false) SentryDependencyContainer.sharedInstance().binaryImageCache.binaryImageAdded(imageName: image.name, vmAddress: image.vmAddress, address: image.address, diff --git a/Tests/SentryTests/SentryCrash/SentryDebugImageProviderTests.swift b/Tests/SentryTests/SentryCrash/SentryDebugImageProviderTests.swift index eddfb69174e..631f9a4a463 100644 --- a/Tests/SentryTests/SentryCrash/SentryDebugImageProviderTests.swift +++ b/Tests/SentryTests/SentryCrash/SentryDebugImageProviderTests.swift @@ -18,11 +18,10 @@ class SentryDebugImageProviderTests: XCTestCase { func getSut(images: [SentryCrashBinaryImage] = []) -> SentryDebugImageProvider { let imageProvider = TestSentryCrashBinaryImageProvider() - let dispatchQueueWrapper = TestSentryDispatchQueueWrapper() imageProvider.imageCount = images.count imageProvider.binaryImage = images - cache.start(false, dispatchQueueWrapper: dispatchQueueWrapper) + cache.start(false) for image in images { cache.binaryImageAdded(imageName: image.name, vmAddress: image.vmAddress, From 8e3673cae28ea6589904c3aa978470eecd6de0db Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Wed, 27 Aug 2025 16:59:23 -0300 Subject: [PATCH 06/14] Update SDK api json --- sdk_api.json | 50 ++++++++++++++++++++++++------------------------- sdk_api_V9.json | 50 ++++++++++++++++++++++++------------------------- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/sdk_api.json b/sdk_api.json index af39896f969..f1c080b2028 100644 --- a/sdk_api.json +++ b/sdk_api.json @@ -57722,31 +57722,6 @@ } ] }, - { - "kind": "Constructor", - "name": "init", - "printedName": "init()", - "children": [ - { - "kind": "TypeNominal", - "name": "SentryBinaryImageCache", - "printedName": "Sentry.SentryBinaryImageCache", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache" - } - ], - "declKind": "Constructor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)init", - "mangledName": "$s6Sentry0A16BinaryImageCacheCACycfc", - "moduleName": "Sentry", - "overriding": true, - "objc_name": "init", - "declAttributes": [ - "ObjC", - "Dynamic", - "Override" - ], - "init_kind": "Designated" - }, { "kind": "Function", "name": "stop", @@ -58035,6 +58010,31 @@ "ObjC" ], "funcSelfKind": "NonMutating" + }, + { + "kind": "Constructor", + "name": "init", + "printedName": "init()", + "children": [ + { + "kind": "TypeNominal", + "name": "SentryBinaryImageCache", + "printedName": "Sentry.SentryBinaryImageCache", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache" + } + ], + "declKind": "Constructor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)init", + "mangledName": "$s6Sentry0A16BinaryImageCacheCACycfc", + "moduleName": "Sentry", + "overriding": true, + "objc_name": "init", + "declAttributes": [ + "ObjC", + "Dynamic", + "Override" + ], + "init_kind": "Designated" } ], "declKind": "Class", diff --git a/sdk_api_V9.json b/sdk_api_V9.json index 8e828d6e896..3d2d5614fa0 100644 --- a/sdk_api_V9.json +++ b/sdk_api_V9.json @@ -54250,31 +54250,6 @@ } ] }, - { - "kind": "Constructor", - "name": "init", - "printedName": "init()", - "children": [ - { - "kind": "TypeNominal", - "name": "SentryBinaryImageCache", - "printedName": "Sentry.SentryBinaryImageCache", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache" - } - ], - "declKind": "Constructor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)init", - "mangledName": "$s6Sentry0A16BinaryImageCacheCACycfc", - "moduleName": "Sentry", - "overriding": true, - "objc_name": "init", - "declAttributes": [ - "ObjC", - "Dynamic", - "Override" - ], - "init_kind": "Designated" - }, { "kind": "Function", "name": "stop", @@ -54563,6 +54538,31 @@ "ObjC" ], "funcSelfKind": "NonMutating" + }, + { + "kind": "Constructor", + "name": "init", + "printedName": "init()", + "children": [ + { + "kind": "TypeNominal", + "name": "SentryBinaryImageCache", + "printedName": "Sentry.SentryBinaryImageCache", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache" + } + ], + "declKind": "Constructor", + "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)init", + "mangledName": "$s6Sentry0A16BinaryImageCacheCACycfc", + "moduleName": "Sentry", + "overriding": true, + "objc_name": "init", + "declAttributes": [ + "ObjC", + "Dynamic", + "Override" + ], + "init_kind": "Designated" } ], "declKind": "Class", From f7239aa0b7bd97d6b8ba26386165b30ec0efa0eb Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Wed, 27 Aug 2025 17:54:41 -0300 Subject: [PATCH 07/14] Revert to use binary image callbacks in C --- Sentry.xcodeproj/project.pbxproj | 8 +++++ .../Sentry/SentryBinaryImageCacheCallbacks.m | 30 +++++++++++++++++++ .../SentryDependencyContainerSwiftHelper.m | 10 ------- .../SentryBinaryImageCacheCallbacks.h | 14 +++++++++ .../SentryDependencyContainerSwiftHelper.h | 4 --- Sources/Sentry/include/SentryPrivate.h | 1 + .../SentryBinaryImageCacheCallbacks.h | 14 +++++++++ .../SentryBinaryImageCacheCallbacks.m | 30 +++++++++++++++++++ .../Core/Helper/SentryBinaryImageCache.swift | 28 +---------------- 9 files changed, 98 insertions(+), 41 deletions(-) create mode 100644 Sources/Sentry/SentryBinaryImageCacheCallbacks.m create mode 100644 Sources/Sentry/include/HybridPublic/SentryBinaryImageCacheCallbacks.h create mode 100644 Sources/SentryCrash/Recording/SentryBinaryImageCacheCallbacks.h create mode 100644 Sources/SentryCrash/Recording/SentryBinaryImageCacheCallbacks.m diff --git a/Sentry.xcodeproj/project.pbxproj b/Sentry.xcodeproj/project.pbxproj index f0df008187e..4af31ba6a38 100644 --- a/Sentry.xcodeproj/project.pbxproj +++ b/Sentry.xcodeproj/project.pbxproj @@ -1040,6 +1040,8 @@ F458D1192E186E000028273E /* SentryScopePersistentStore+Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = F458D1182E186E000028273E /* SentryScopePersistentStore+Extras.swift */; }; F46DA6C32E1DBCA000DF6E3B /* SentryScopePersistentStore+Helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = F46DA6C22E1DBCA000DF6E3B /* SentryScopePersistentStore+Helper.swift */; }; F48F74F32E5F9959009D4E7D /* SentryCrashBinaryImageCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F48F74F22E5F9959009D4E7D /* SentryCrashBinaryImageCacheTests.m */; }; + F48F75712E5FA630009D4E7D /* SentryBinaryImageCacheCallbacks.m in Sources */ = {isa = PBXBuildFile; fileRef = F48F75702E5FA630009D4E7D /* SentryBinaryImageCacheCallbacks.m */; }; + F48F75732E5FA649009D4E7D /* SentryBinaryImageCacheCallbacks.h in Headers */ = {isa = PBXBuildFile; fileRef = F48F75722E5FA649009D4E7D /* SentryBinaryImageCacheCallbacks.h */; }; F49236EB2E5E4B2F00663673 /* SentryBinaryImageCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = F49236EA2E5E4B2F00663673 /* SentryBinaryImageCache.swift */; }; F49D41982DEA27AF00D9244E /* SentryUseNSExceptionCallstackWrapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F49D41972DEA27AF00D9244E /* SentryUseNSExceptionCallstackWrapperTests.swift */; }; F49D419A2DEA2FB000D9244E /* SentryCrashExceptionApplicationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F49D41992DEA2FB000D9244E /* SentryCrashExceptionApplicationTests.swift */; }; @@ -2385,6 +2387,8 @@ F458D1182E186E000028273E /* SentryScopePersistentStore+Extras.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SentryScopePersistentStore+Extras.swift"; sourceTree = ""; }; F46DA6C22E1DBCA000DF6E3B /* SentryScopePersistentStore+Helper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SentryScopePersistentStore+Helper.swift"; sourceTree = ""; }; F48F74F22E5F9959009D4E7D /* SentryCrashBinaryImageCacheTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryCrashBinaryImageCacheTests.m; sourceTree = ""; }; + F48F75702E5FA630009D4E7D /* SentryBinaryImageCacheCallbacks.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryBinaryImageCacheCallbacks.m; sourceTree = ""; }; + F48F75722E5FA649009D4E7D /* SentryBinaryImageCacheCallbacks.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SentryBinaryImageCacheCallbacks.h; sourceTree = ""; }; F49236EA2E5E4B2F00663673 /* SentryBinaryImageCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryBinaryImageCache.swift; sourceTree = ""; }; F49D41972DEA27AF00D9244E /* SentryUseNSExceptionCallstackWrapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUseNSExceptionCallstackWrapperTests.swift; sourceTree = ""; }; F49D41992DEA2FB000D9244E /* SentryCrashExceptionApplicationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryCrashExceptionApplicationTests.swift; sourceTree = ""; }; @@ -3157,6 +3161,8 @@ 63FE6FE920DA4C1000CDBAE8 /* Recording */ = { isa = PBXGroup; children = ( + F48F75722E5FA649009D4E7D /* SentryBinaryImageCacheCallbacks.h */, + F48F75702E5FA630009D4E7D /* SentryBinaryImageCacheCallbacks.m */, 63FE704B20DA4C1000CDBAE8 /* SentryCrash.h */, 63FE704120DA4C1000CDBAE8 /* SentryCrash.m */, 63FE704920DA4C1000CDBAE8 /* SentryCrashC.h */, @@ -4991,6 +4997,7 @@ 84AF45A629A7FFA500FBB177 /* SentryProfiledTracerConcurrency.h in Headers */, 7B2A70DB27D607CF008B0D15 /* SentryThreadWrapper.h in Headers */, 8EAE980B261E9F530073B6B3 /* SentryPerformanceTracker.h in Headers */, + F48F75732E5FA649009D4E7D /* SentryBinaryImageCacheCallbacks.h in Headers */, 63FE718520DA4C1100CDBAE8 /* SentryCrashC.h in Headers */, 8EA1ED0D2669028C00E62B98 /* SentryUIViewControllerSwizzling.h in Headers */, D820CDB82BB1895F00BA339D /* SentrySessionReplayIntegration.h in Headers */, @@ -5794,6 +5801,7 @@ FA4C32972DF7513F001D7B00 /* SentryExperimentalOptions.swift in Sources */, FA67DD152DDBD4EA00896B02 /* UrlSanitized.swift in Sources */, FA67DD162DDBD4EA00896B02 /* SentryViewPhotographer.swift in Sources */, + F48F75712E5FA630009D4E7D /* SentryBinaryImageCacheCallbacks.m in Sources */, FA67DD182DDBD4EA00896B02 /* UIImageHelper.swift in Sources */, FA67DD192DDBD4EA00896B02 /* SwizzleClassNameExclude.swift in Sources */, 7B2A70DD27D6083D008B0D15 /* SentryThreadWrapper.m in Sources */, diff --git a/Sources/Sentry/SentryBinaryImageCacheCallbacks.m b/Sources/Sentry/SentryBinaryImageCacheCallbacks.m new file mode 100644 index 00000000000..c0a9c4f699b --- /dev/null +++ b/Sources/Sentry/SentryBinaryImageCacheCallbacks.m @@ -0,0 +1,30 @@ +#import "SentryBinaryImageCacheCallbacks.h" +#import "SentryDependencyContainer.h" +#import "SentryInternalDefines.h" +#import "SentrySwift.h" + +// Used to call SentryDependencyContainer, since it isn't available to swift yet +void +binaryImageWasAdded(const SentryCrashBinaryImage *_Nullable image) +{ + if (image == NULL) { + SENTRY_LOG_WARN(@"The image is NULL. Can't add NULL to cache."); + return; + } + [SentryDependencyContainer.sharedInstance.binaryImageCache binaryImageAdded:image->name + vmAddress:image->vmAddress + address:image->address + size:image->size + uuid:image->uuid]; +} + +// Used to call SentryDependencyContainer, since it isn't available to swift yet +void +binaryImageWasRemoved(const SentryCrashBinaryImage *_Nullable image) +{ + if (image == NULL) { + SENTRY_LOG_WARN(@"The image is NULL. Can't remove it from the cache."); + return; + } + [SentryDependencyContainer.sharedInstance.binaryImageCache binaryImageRemoved:image->address]; +} diff --git a/Sources/Sentry/SentryDependencyContainerSwiftHelper.m b/Sources/Sentry/SentryDependencyContainerSwiftHelper.m index 606e8fd7c27..8a6edaddd8d 100644 --- a/Sources/Sentry/SentryDependencyContainerSwiftHelper.m +++ b/Sources/Sentry/SentryDependencyContainerSwiftHelper.m @@ -30,14 +30,4 @@ + (SentryHub *)currentHub return SentrySDKInternal.currentHub; } -+ (SentryDispatchQueueWrapper *)dispatchQueueWrapper -{ - return SentryDependencyContainer.sharedInstance.dispatchQueueWrapper; -} - -+ (SentryBinaryImageCache *)binaryImageCache -{ - return SentryDependencyContainer.sharedInstance.binaryImageCache; -} - @end diff --git a/Sources/Sentry/include/HybridPublic/SentryBinaryImageCacheCallbacks.h b/Sources/Sentry/include/HybridPublic/SentryBinaryImageCacheCallbacks.h new file mode 100644 index 00000000000..c966ef3e076 --- /dev/null +++ b/Sources/Sentry/include/HybridPublic/SentryBinaryImageCacheCallbacks.h @@ -0,0 +1,14 @@ +#import "SentryCrashDynamicLinker.h" +#import + +#ifdef __cplusplus +extern "C" { +#endif + +void binaryImageWasAdded(const SentryCrashBinaryImage *_Nullable image); + +void binaryImageWasRemoved(const SentryCrashBinaryImage *_Nullable image); + +#ifdef __cplusplus +} +#endif diff --git a/Sources/Sentry/include/SentryDependencyContainerSwiftHelper.h b/Sources/Sentry/include/SentryDependencyContainerSwiftHelper.h index 3f006363031..7572abdc3d2 100644 --- a/Sources/Sentry/include/SentryDependencyContainerSwiftHelper.h +++ b/Sources/Sentry/include/SentryDependencyContainerSwiftHelper.h @@ -7,8 +7,6 @@ @protocol SentryObjCRuntimeWrapper; @class SentryHub; -@class SentryDispatchQueueWrapper; -@class SentryBinaryImageCache; NS_ASSUME_NONNULL_BEGIN @@ -27,8 +25,6 @@ NS_ASSUME_NONNULL_BEGIN + (void)dispatchSyncOnMainQueue:(void (^)(void))block; + (id)objcRuntimeWrapper; + (SentryHub *)currentHub; -+ (SentryDispatchQueueWrapper *)dispatchQueueWrapper; -+ (SentryBinaryImageCache *)binaryImageCache; @end diff --git a/Sources/Sentry/include/SentryPrivate.h b/Sources/Sentry/include/SentryPrivate.h index fabd337c304..5af46a02d3e 100644 --- a/Sources/Sentry/include/SentryPrivate.h +++ b/Sources/Sentry/include/SentryPrivate.h @@ -1,6 +1,7 @@ // Sentry internal headers that are needed for swift code; you cannot import headers that depend on // public interfaces here #import "NSLocale+Sentry.h" +#import "SentryBinaryImageCacheCallbacks.h" #import "SentryCrashBinaryImageCache.h" #import "SentryCrashDynamicLinker.h" #import "SentryCrashExceptionApplicationHelper.h" diff --git a/Sources/SentryCrash/Recording/SentryBinaryImageCacheCallbacks.h b/Sources/SentryCrash/Recording/SentryBinaryImageCacheCallbacks.h new file mode 100644 index 00000000000..c966ef3e076 --- /dev/null +++ b/Sources/SentryCrash/Recording/SentryBinaryImageCacheCallbacks.h @@ -0,0 +1,14 @@ +#import "SentryCrashDynamicLinker.h" +#import + +#ifdef __cplusplus +extern "C" { +#endif + +void binaryImageWasAdded(const SentryCrashBinaryImage *_Nullable image); + +void binaryImageWasRemoved(const SentryCrashBinaryImage *_Nullable image); + +#ifdef __cplusplus +} +#endif diff --git a/Sources/SentryCrash/Recording/SentryBinaryImageCacheCallbacks.m b/Sources/SentryCrash/Recording/SentryBinaryImageCacheCallbacks.m new file mode 100644 index 00000000000..c0a9c4f699b --- /dev/null +++ b/Sources/SentryCrash/Recording/SentryBinaryImageCacheCallbacks.m @@ -0,0 +1,30 @@ +#import "SentryBinaryImageCacheCallbacks.h" +#import "SentryDependencyContainer.h" +#import "SentryInternalDefines.h" +#import "SentrySwift.h" + +// Used to call SentryDependencyContainer, since it isn't available to swift yet +void +binaryImageWasAdded(const SentryCrashBinaryImage *_Nullable image) +{ + if (image == NULL) { + SENTRY_LOG_WARN(@"The image is NULL. Can't add NULL to cache."); + return; + } + [SentryDependencyContainer.sharedInstance.binaryImageCache binaryImageAdded:image->name + vmAddress:image->vmAddress + address:image->address + size:image->size + uuid:image->uuid]; +} + +// Used to call SentryDependencyContainer, since it isn't available to swift yet +void +binaryImageWasRemoved(const SentryCrashBinaryImage *_Nullable image) +{ + if (image == NULL) { + SENTRY_LOG_WARN(@"The image is NULL. Can't remove it from the cache."); + return; + } + [SentryDependencyContainer.sharedInstance.binaryImageCache binaryImageRemoved:image->address]; +} diff --git a/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift b/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift index 2dadbfc358a..dc3413a4c77 100644 --- a/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift +++ b/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift @@ -98,7 +98,7 @@ public class SentryBinaryImageCache: NSObject { LoadValidator.checkForDuplicatedSDK(imageName: nameString, imageAddress: NSNumber(value: newImage.address), imageSize: NSNumber(value: newImage.size), - dispatchQueueWrapper: SentryDependencyContainerSwiftHelper.dispatchQueueWrapper()) + dispatchQueueWrapper: Dependencies.dispatchQueueWrapper) } } @@ -174,29 +174,3 @@ public class SentryBinaryImageCache: NSObject { } } } - -// MARK: - C Callback Functions - -private func binaryImageWasAdded(_ image: UnsafePointer?) { - guard let image = image else { - SentrySDKLog.warning("The image is NULL. Can't add NULL to cache.") - return - } - - SentryDependencyContainerSwiftHelper.binaryImageCache().binaryImageAdded( - imageName: image.pointee.name, - vmAddress: image.pointee.vmAddress, - address: image.pointee.address, - size: image.pointee.size, - uuid: image.pointee.uuid - ) -} - -private func binaryImageWasRemoved(_ image: UnsafePointer?) { - guard let image = image else { - SentrySDKLog.warning("The image is NULL. Can't remove it from the cache.") - return - } - - SentryDependencyContainerSwiftHelper.binaryImageCache().binaryImageRemoved(image.pointee.address) -} From 435c91c7c9333d8c801a718aa999757b589fe1bd Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Wed, 27 Aug 2025 17:59:58 -0300 Subject: [PATCH 08/14] Move `SentryBinaryImageCacheCallbacks` to include folder --- .../include/{HybridPublic => }/SentryBinaryImageCacheCallbacks.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Sources/Sentry/include/{HybridPublic => }/SentryBinaryImageCacheCallbacks.h (100%) diff --git a/Sources/Sentry/include/HybridPublic/SentryBinaryImageCacheCallbacks.h b/Sources/Sentry/include/SentryBinaryImageCacheCallbacks.h similarity index 100% rename from Sources/Sentry/include/HybridPublic/SentryBinaryImageCacheCallbacks.h rename to Sources/Sentry/include/SentryBinaryImageCacheCallbacks.h From 7005d2db9ef8503cbc995f3b42751e38a20e9868 Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Wed, 27 Aug 2025 18:08:54 -0300 Subject: [PATCH 09/14] Fix duplicate files --- Sentry.xcodeproj/project.pbxproj | 2 +- .../Sentry/SentryBinaryImageCacheCallbacks.m | 30 ------------------- .../SentryBinaryImageCacheCallbacks.h | 14 --------- 3 files changed, 1 insertion(+), 45 deletions(-) delete mode 100644 Sources/Sentry/SentryBinaryImageCacheCallbacks.m delete mode 100644 Sources/SentryCrash/Recording/SentryBinaryImageCacheCallbacks.h diff --git a/Sentry.xcodeproj/project.pbxproj b/Sentry.xcodeproj/project.pbxproj index 4af31ba6a38..663c7de7547 100644 --- a/Sentry.xcodeproj/project.pbxproj +++ b/Sentry.xcodeproj/project.pbxproj @@ -2388,7 +2388,7 @@ F46DA6C22E1DBCA000DF6E3B /* SentryScopePersistentStore+Helper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SentryScopePersistentStore+Helper.swift"; sourceTree = ""; }; F48F74F22E5F9959009D4E7D /* SentryCrashBinaryImageCacheTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryCrashBinaryImageCacheTests.m; sourceTree = ""; }; F48F75702E5FA630009D4E7D /* SentryBinaryImageCacheCallbacks.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryBinaryImageCacheCallbacks.m; sourceTree = ""; }; - F48F75722E5FA649009D4E7D /* SentryBinaryImageCacheCallbacks.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SentryBinaryImageCacheCallbacks.h; sourceTree = ""; }; + F48F75722E5FA649009D4E7D /* SentryBinaryImageCacheCallbacks.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryBinaryImageCacheCallbacks.h; path = ../../Sentry/include/SentryBinaryImageCacheCallbacks.h; sourceTree = ""; }; F49236EA2E5E4B2F00663673 /* SentryBinaryImageCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryBinaryImageCache.swift; sourceTree = ""; }; F49D41972DEA27AF00D9244E /* SentryUseNSExceptionCallstackWrapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUseNSExceptionCallstackWrapperTests.swift; sourceTree = ""; }; F49D41992DEA2FB000D9244E /* SentryCrashExceptionApplicationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryCrashExceptionApplicationTests.swift; sourceTree = ""; }; diff --git a/Sources/Sentry/SentryBinaryImageCacheCallbacks.m b/Sources/Sentry/SentryBinaryImageCacheCallbacks.m deleted file mode 100644 index c0a9c4f699b..00000000000 --- a/Sources/Sentry/SentryBinaryImageCacheCallbacks.m +++ /dev/null @@ -1,30 +0,0 @@ -#import "SentryBinaryImageCacheCallbacks.h" -#import "SentryDependencyContainer.h" -#import "SentryInternalDefines.h" -#import "SentrySwift.h" - -// Used to call SentryDependencyContainer, since it isn't available to swift yet -void -binaryImageWasAdded(const SentryCrashBinaryImage *_Nullable image) -{ - if (image == NULL) { - SENTRY_LOG_WARN(@"The image is NULL. Can't add NULL to cache."); - return; - } - [SentryDependencyContainer.sharedInstance.binaryImageCache binaryImageAdded:image->name - vmAddress:image->vmAddress - address:image->address - size:image->size - uuid:image->uuid]; -} - -// Used to call SentryDependencyContainer, since it isn't available to swift yet -void -binaryImageWasRemoved(const SentryCrashBinaryImage *_Nullable image) -{ - if (image == NULL) { - SENTRY_LOG_WARN(@"The image is NULL. Can't remove it from the cache."); - return; - } - [SentryDependencyContainer.sharedInstance.binaryImageCache binaryImageRemoved:image->address]; -} diff --git a/Sources/SentryCrash/Recording/SentryBinaryImageCacheCallbacks.h b/Sources/SentryCrash/Recording/SentryBinaryImageCacheCallbacks.h deleted file mode 100644 index c966ef3e076..00000000000 --- a/Sources/SentryCrash/Recording/SentryBinaryImageCacheCallbacks.h +++ /dev/null @@ -1,14 +0,0 @@ -#import "SentryCrashDynamicLinker.h" -#import - -#ifdef __cplusplus -extern "C" { -#endif - -void binaryImageWasAdded(const SentryCrashBinaryImage *_Nullable image); - -void binaryImageWasRemoved(const SentryCrashBinaryImage *_Nullable image); - -#ifdef __cplusplus -} -#endif From 24f25fc73183da44dc085fdb30a68915893145e2 Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Thu, 28 Aug 2025 09:51:49 -0300 Subject: [PATCH 10/14] Use `@_spi(Private)` and `final` for --- .../Core/Helper/SentryBinaryImageCache.swift | 4 +- sdk_api.json | 992 ------------------ sdk_api_V9.json | 992 ------------------ 3 files changed, 2 insertions(+), 1986 deletions(-) diff --git a/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift b/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift index dc3413a4c77..8da4ac77802 100644 --- a/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift +++ b/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift @@ -2,7 +2,7 @@ import Foundation @objc(SentryBinaryImageInfo) -public class SentryBinaryImageInfo: NSObject { +@_spi(Private) public final class SentryBinaryImageInfo: NSObject { @objc public var name: String @objc public var uuid: String? @objc public var vmAddress: UInt64 @@ -25,7 +25,7 @@ public class SentryBinaryImageInfo: NSObject { * performance. */ @objc(SentryBinaryImageCache) -public class SentryBinaryImageCache: NSObject { +@_spi(Private) public final class SentryBinaryImageCache: NSObject { @objc public internal(set) var cache: [SentryBinaryImageInfo]? private var isDebug: Bool = false // Use a recursive lock to allow the same thread to enter again diff --git a/sdk_api.json b/sdk_api.json index f1c080b2028..31d6948f49b 100644 --- a/sdk_api.json +++ b/sdk_api.json @@ -57116,998 +57116,6 @@ } ] }, - { - "kind": "TypeDecl", - "name": "SentryBinaryImageInfo", - "printedName": "SentryBinaryImageInfo", - "children": [ - { - "kind": "Var", - "name": "name", - "printedName": "name", - "children": [ - { - "kind": "TypeNominal", - "name": "String", - "printedName": "Swift.String", - "usr": "s:SS" - } - ], - "declKind": "Var", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(py)name", - "mangledName": "$s6Sentry0A15BinaryImageInfoC4nameSSvp", - "moduleName": "Sentry", - "declAttributes": [ - "ObjC", - "HasStorage" - ], - "hasStorage": true, - "accessors": [ - { - "kind": "Accessor", - "name": "Get", - "printedName": "Get()", - "children": [ - { - "kind": "TypeNominal", - "name": "String", - "printedName": "Swift.String", - "usr": "s:SS" - } - ], - "declKind": "Accessor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)name", - "mangledName": "$s6Sentry0A15BinaryImageInfoC4nameSSvg", - "moduleName": "Sentry", - "implicit": true, - "declAttributes": [ - "ObjC" - ], - "accessorKind": "get" - }, - { - "kind": "Accessor", - "name": "Set", - "printedName": "Set()", - "children": [ - { - "kind": "TypeNominal", - "name": "Void", - "printedName": "()" - }, - { - "kind": "TypeNominal", - "name": "String", - "printedName": "Swift.String", - "usr": "s:SS" - } - ], - "declKind": "Accessor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)setName:", - "mangledName": "$s6Sentry0A15BinaryImageInfoC4nameSSvs", - "moduleName": "Sentry", - "implicit": true, - "declAttributes": [ - "ObjC" - ], - "accessorKind": "set" - } - ] - }, - { - "kind": "Var", - "name": "uuid", - "printedName": "uuid", - "children": [ - { - "kind": "TypeNominal", - "name": "Optional", - "printedName": "Swift.String?", - "children": [ - { - "kind": "TypeNominal", - "name": "String", - "printedName": "Swift.String", - "usr": "s:SS" - } - ], - "usr": "s:Sq" - } - ], - "declKind": "Var", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(py)uuid", - "mangledName": "$s6Sentry0A15BinaryImageInfoC4uuidSSSgvp", - "moduleName": "Sentry", - "declAttributes": [ - "HasInitialValue", - "ObjC", - "HasStorage" - ], - "hasStorage": true, - "accessors": [ - { - "kind": "Accessor", - "name": "Get", - "printedName": "Get()", - "children": [ - { - "kind": "TypeNominal", - "name": "Optional", - "printedName": "Swift.String?", - "children": [ - { - "kind": "TypeNominal", - "name": "String", - "printedName": "Swift.String", - "usr": "s:SS" - } - ], - "usr": "s:Sq" - } - ], - "declKind": "Accessor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)uuid", - "mangledName": "$s6Sentry0A15BinaryImageInfoC4uuidSSSgvg", - "moduleName": "Sentry", - "implicit": true, - "declAttributes": [ - "ObjC" - ], - "accessorKind": "get" - }, - { - "kind": "Accessor", - "name": "Set", - "printedName": "Set()", - "children": [ - { - "kind": "TypeNominal", - "name": "Void", - "printedName": "()" - }, - { - "kind": "TypeNominal", - "name": "Optional", - "printedName": "Swift.String?", - "children": [ - { - "kind": "TypeNominal", - "name": "String", - "printedName": "Swift.String", - "usr": "s:SS" - } - ], - "usr": "s:Sq" - } - ], - "declKind": "Accessor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)setUuid:", - "mangledName": "$s6Sentry0A15BinaryImageInfoC4uuidSSSgvs", - "moduleName": "Sentry", - "implicit": true, - "declAttributes": [ - "ObjC" - ], - "accessorKind": "set" - } - ] - }, - { - "kind": "Var", - "name": "vmAddress", - "printedName": "vmAddress", - "children": [ - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Var", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(py)vmAddress", - "mangledName": "$s6Sentry0A15BinaryImageInfoC9vmAddresss6UInt64Vvp", - "moduleName": "Sentry", - "declAttributes": [ - "ObjC", - "HasStorage" - ], - "hasStorage": true, - "accessors": [ - { - "kind": "Accessor", - "name": "Get", - "printedName": "Get()", - "children": [ - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Accessor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)vmAddress", - "mangledName": "$s6Sentry0A15BinaryImageInfoC9vmAddresss6UInt64Vvg", - "moduleName": "Sentry", - "implicit": true, - "declAttributes": [ - "ObjC" - ], - "accessorKind": "get" - }, - { - "kind": "Accessor", - "name": "Set", - "printedName": "Set()", - "children": [ - { - "kind": "TypeNominal", - "name": "Void", - "printedName": "()" - }, - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Accessor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)setVmAddress:", - "mangledName": "$s6Sentry0A15BinaryImageInfoC9vmAddresss6UInt64Vvs", - "moduleName": "Sentry", - "implicit": true, - "declAttributes": [ - "ObjC" - ], - "accessorKind": "set" - } - ] - }, - { - "kind": "Var", - "name": "address", - "printedName": "address", - "children": [ - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Var", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(py)address", - "mangledName": "$s6Sentry0A15BinaryImageInfoC7addresss6UInt64Vvp", - "moduleName": "Sentry", - "declAttributes": [ - "ObjC", - "HasStorage" - ], - "hasStorage": true, - "accessors": [ - { - "kind": "Accessor", - "name": "Get", - "printedName": "Get()", - "children": [ - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Accessor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)address", - "mangledName": "$s6Sentry0A15BinaryImageInfoC7addresss6UInt64Vvg", - "moduleName": "Sentry", - "implicit": true, - "declAttributes": [ - "ObjC" - ], - "accessorKind": "get" - }, - { - "kind": "Accessor", - "name": "Set", - "printedName": "Set()", - "children": [ - { - "kind": "TypeNominal", - "name": "Void", - "printedName": "()" - }, - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Accessor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)setAddress:", - "mangledName": "$s6Sentry0A15BinaryImageInfoC7addresss6UInt64Vvs", - "moduleName": "Sentry", - "implicit": true, - "declAttributes": [ - "ObjC" - ], - "accessorKind": "set" - } - ] - }, - { - "kind": "Var", - "name": "size", - "printedName": "size", - "children": [ - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Var", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(py)size", - "mangledName": "$s6Sentry0A15BinaryImageInfoC4sizes6UInt64Vvp", - "moduleName": "Sentry", - "declAttributes": [ - "ObjC", - "HasStorage" - ], - "hasStorage": true, - "accessors": [ - { - "kind": "Accessor", - "name": "Get", - "printedName": "Get()", - "children": [ - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Accessor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)size", - "mangledName": "$s6Sentry0A15BinaryImageInfoC4sizes6UInt64Vvg", - "moduleName": "Sentry", - "implicit": true, - "declAttributes": [ - "ObjC" - ], - "accessorKind": "get" - }, - { - "kind": "Accessor", - "name": "Set", - "printedName": "Set()", - "children": [ - { - "kind": "TypeNominal", - "name": "Void", - "printedName": "()" - }, - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Accessor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)setSize:", - "mangledName": "$s6Sentry0A15BinaryImageInfoC4sizes6UInt64Vvs", - "moduleName": "Sentry", - "implicit": true, - "declAttributes": [ - "ObjC" - ], - "accessorKind": "set" - } - ] - }, - { - "kind": "Constructor", - "name": "init", - "printedName": "init(name:uuid:vmAddress:address:size:)", - "children": [ - { - "kind": "TypeNominal", - "name": "SentryBinaryImageInfo", - "printedName": "Sentry.SentryBinaryImageInfo", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo" - }, - { - "kind": "TypeNominal", - "name": "String", - "printedName": "Swift.String", - "usr": "s:SS" - }, - { - "kind": "TypeNominal", - "name": "Optional", - "printedName": "Swift.String?", - "children": [ - { - "kind": "TypeNominal", - "name": "String", - "printedName": "Swift.String", - "usr": "s:SS" - } - ], - "usr": "s:Sq" - }, - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - }, - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - }, - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Constructor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)initWithName:uuid:vmAddress:address:size:", - "mangledName": "$s6Sentry0A15BinaryImageInfoC4name4uuid9vmAddress7address4sizeACSS_SSSgs6UInt64VA2Ktcfc", - "moduleName": "Sentry", - "objc_name": "initWithName:uuid:vmAddress:address:size:", - "declAttributes": [ - "ObjC" - ], - "init_kind": "Designated" - } - ], - "declKind": "Class", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo", - "mangledName": "$s6Sentry0A15BinaryImageInfoC", - "moduleName": "Sentry", - "objc_name": "SentryBinaryImageInfo", - "declAttributes": [ - "ObjC" - ], - "superclassUsr": "c:objc(cs)NSObject", - "superclassNames": [ - "ObjectiveC.NSObject" - ], - "conformances": [ - { - "kind": "Conformance", - "name": "Copyable", - "printedName": "Copyable", - "usr": "s:s8CopyableP", - "mangledName": "$ss8CopyableP" - }, - { - "kind": "Conformance", - "name": "Escapable", - "printedName": "Escapable", - "usr": "s:s9EscapableP", - "mangledName": "$ss9EscapableP" - }, - { - "kind": "Conformance", - "name": "NSObjectProtocol", - "printedName": "NSObjectProtocol", - "usr": "c:objc(pl)NSObject" - }, - { - "kind": "Conformance", - "name": "Equatable", - "printedName": "Equatable", - "usr": "s:SQ", - "mangledName": "$sSQ" - }, - { - "kind": "Conformance", - "name": "Hashable", - "printedName": "Hashable", - "usr": "s:SH", - "mangledName": "$sSH" - }, - { - "kind": "Conformance", - "name": "CVarArg", - "printedName": "CVarArg", - "usr": "s:s7CVarArgP", - "mangledName": "$ss7CVarArgP" - }, - { - "kind": "Conformance", - "name": "CustomStringConvertible", - "printedName": "CustomStringConvertible", - "usr": "s:s23CustomStringConvertibleP", - "mangledName": "$ss23CustomStringConvertibleP" - }, - { - "kind": "Conformance", - "name": "CustomDebugStringConvertible", - "printedName": "CustomDebugStringConvertible", - "usr": "s:s28CustomDebugStringConvertibleP", - "mangledName": "$ss28CustomDebugStringConvertibleP" - } - ] - }, - { - "kind": "TypeDecl", - "name": "SentryBinaryImageCache", - "printedName": "SentryBinaryImageCache", - "children": [ - { - "kind": "Var", - "name": "cache", - "printedName": "cache", - "children": [ - { - "kind": "TypeNominal", - "name": "Optional", - "printedName": "[Sentry.SentryBinaryImageInfo]?", - "children": [ - { - "kind": "TypeNominal", - "name": "Array", - "printedName": "[Sentry.SentryBinaryImageInfo]", - "children": [ - { - "kind": "TypeNominal", - "name": "SentryBinaryImageInfo", - "printedName": "Sentry.SentryBinaryImageInfo", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo" - } - ], - "usr": "s:Sa" - } - ], - "usr": "s:Sq" - } - ], - "declKind": "Var", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(py)cache", - "mangledName": "$s6Sentry0A16BinaryImageCacheC5cacheSayAA0abC4InfoCGSgvp", - "moduleName": "Sentry", - "declAttributes": [ - "ObjC" - ], - "accessors": [ - { - "kind": "Accessor", - "name": "Get", - "printedName": "Get()", - "children": [ - { - "kind": "TypeNominal", - "name": "Optional", - "printedName": "[Sentry.SentryBinaryImageInfo]?", - "children": [ - { - "kind": "TypeNominal", - "name": "Array", - "printedName": "[Sentry.SentryBinaryImageInfo]", - "children": [ - { - "kind": "TypeNominal", - "name": "SentryBinaryImageInfo", - "printedName": "Sentry.SentryBinaryImageInfo", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo" - } - ], - "usr": "s:Sa" - } - ], - "usr": "s:Sq" - } - ], - "declKind": "Accessor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)cache", - "mangledName": "$s6Sentry0A16BinaryImageCacheC5cacheSayAA0abC4InfoCGSgvg", - "moduleName": "Sentry", - "declAttributes": [ - "ObjC" - ], - "accessorKind": "get" - } - ] - }, - { - "kind": "Function", - "name": "stop", - "printedName": "stop()", - "children": [ - { - "kind": "TypeNominal", - "name": "Void", - "printedName": "()" - } - ], - "declKind": "Func", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)stop", - "mangledName": "$s6Sentry0A16BinaryImageCacheC4stopyyF", - "moduleName": "Sentry", - "declAttributes": [ - "ObjC" - ], - "funcSelfKind": "NonMutating" - }, - { - "kind": "Function", - "name": "binaryImageAdded", - "printedName": "binaryImageAdded(imageName:vmAddress:address:size:uuid:)", - "children": [ - { - "kind": "TypeNominal", - "name": "Void", - "printedName": "()" - }, - { - "kind": "TypeNominal", - "name": "Optional", - "printedName": "Swift.UnsafePointer?", - "children": [ - { - "kind": "TypeNominal", - "name": "UnsafePointer", - "printedName": "Swift.UnsafePointer", - "children": [ - { - "kind": "TypeNameAlias", - "name": "CChar", - "printedName": "Swift.CChar", - "children": [ - { - "kind": "TypeNominal", - "name": "Int8", - "printedName": "Swift.Int8", - "usr": "s:s4Int8V" - } - ] - } - ], - "usr": "s:SP" - } - ], - "usr": "s:Sq" - }, - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - }, - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - }, - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - }, - { - "kind": "TypeNominal", - "name": "Optional", - "printedName": "Swift.UnsafePointer?", - "children": [ - { - "kind": "TypeNominal", - "name": "UnsafePointer", - "printedName": "Swift.UnsafePointer", - "children": [ - { - "kind": "TypeNominal", - "name": "UInt8", - "printedName": "Swift.UInt8", - "usr": "s:s5UInt8V" - } - ], - "usr": "s:SP" - } - ], - "usr": "s:Sq" - } - ], - "declKind": "Func", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)binaryImageAdded:vmAddress:address:size:uuid:", - "mangledName": "$s6Sentry0A16BinaryImageCacheC06binaryC5Added9imageName9vmAddress7address4size4uuidySPys4Int8VGSg_s6UInt64VA2OSPys5UInt8VGSgtF", - "moduleName": "Sentry", - "objc_name": "binaryImageAdded:vmAddress:address:size:uuid:", - "declAttributes": [ - "ObjC" - ], - "funcSelfKind": "NonMutating" - }, - { - "kind": "Function", - "name": "convertUUID", - "printedName": "convertUUID(_:)", - "children": [ - { - "kind": "TypeNominal", - "name": "Optional", - "printedName": "Swift.String?", - "children": [ - { - "kind": "TypeNominal", - "name": "String", - "printedName": "Swift.String", - "usr": "s:SS" - } - ], - "usr": "s:Sq" - }, - { - "kind": "TypeNominal", - "name": "Optional", - "printedName": "Swift.UnsafePointer?", - "children": [ - { - "kind": "TypeNominal", - "name": "UnsafePointer", - "printedName": "Swift.UnsafePointer", - "children": [ - { - "kind": "TypeNominal", - "name": "UInt8", - "printedName": "Swift.UInt8", - "usr": "s:s5UInt8V" - } - ], - "usr": "s:SP" - } - ], - "usr": "s:Sq" - } - ], - "declKind": "Func", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(cm)convertUUID:", - "mangledName": "$s6Sentry0A16BinaryImageCacheC11convertUUIDySSSgSPys5UInt8VGSgFZ", - "moduleName": "Sentry", - "static": true, - "declAttributes": [ - "Final", - "ObjC" - ], - "funcSelfKind": "NonMutating" - }, - { - "kind": "Function", - "name": "binaryImageRemoved", - "printedName": "binaryImageRemoved(_:)", - "children": [ - { - "kind": "TypeNominal", - "name": "Void", - "printedName": "()" - }, - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Func", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)binaryImageRemoved:", - "mangledName": "$s6Sentry0A16BinaryImageCacheC06binaryC7Removedyys6UInt64VF", - "moduleName": "Sentry", - "declAttributes": [ - "ObjC" - ], - "funcSelfKind": "NonMutating" - }, - { - "kind": "Function", - "name": "imageByAddress", - "printedName": "imageByAddress(_:)", - "children": [ - { - "kind": "TypeNominal", - "name": "Optional", - "printedName": "Sentry.SentryBinaryImageInfo?", - "children": [ - { - "kind": "TypeNominal", - "name": "SentryBinaryImageInfo", - "printedName": "Sentry.SentryBinaryImageInfo", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo" - } - ], - "usr": "s:Sq" - }, - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Func", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)imageByAddress:", - "mangledName": "$s6Sentry0A16BinaryImageCacheC14imageByAddressyAA0abC4InfoCSgs6UInt64VF", - "moduleName": "Sentry", - "declAttributes": [ - "ObjC" - ], - "funcSelfKind": "NonMutating" - }, - { - "kind": "Function", - "name": "imagePathsFor", - "printedName": "imagePathsFor(inAppInclude:)", - "children": [ - { - "kind": "TypeNominal", - "name": "Set", - "printedName": "Swift.Set", - "children": [ - { - "kind": "TypeNominal", - "name": "String", - "printedName": "Swift.String", - "usr": "s:SS" - } - ], - "usr": "s:Sh" - }, - { - "kind": "TypeNominal", - "name": "String", - "printedName": "Swift.String", - "usr": "s:SS" - } - ], - "declKind": "Func", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)imagePathsForInAppInclude:", - "mangledName": "$s6Sentry0A16BinaryImageCacheC13imagePathsFor12inAppIncludeShySSGSS_tF", - "moduleName": "Sentry", - "objc_name": "imagePathsForInAppInclude:", - "declAttributes": [ - "ObjC" - ], - "funcSelfKind": "NonMutating" - }, - { - "kind": "Function", - "name": "getAllBinaryImages", - "printedName": "getAllBinaryImages()", - "children": [ - { - "kind": "TypeNominal", - "name": "Array", - "printedName": "[Sentry.SentryBinaryImageInfo]", - "children": [ - { - "kind": "TypeNominal", - "name": "SentryBinaryImageInfo", - "printedName": "Sentry.SentryBinaryImageInfo", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo" - } - ], - "usr": "s:Sa" - } - ], - "declKind": "Func", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)getAllBinaryImages", - "mangledName": "$s6Sentry0A16BinaryImageCacheC06getAllB6ImagesSayAA0abC4InfoCGyF", - "moduleName": "Sentry", - "declAttributes": [ - "ObjC" - ], - "funcSelfKind": "NonMutating" - }, - { - "kind": "Constructor", - "name": "init", - "printedName": "init()", - "children": [ - { - "kind": "TypeNominal", - "name": "SentryBinaryImageCache", - "printedName": "Sentry.SentryBinaryImageCache", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache" - } - ], - "declKind": "Constructor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)init", - "mangledName": "$s6Sentry0A16BinaryImageCacheCACycfc", - "moduleName": "Sentry", - "overriding": true, - "objc_name": "init", - "declAttributes": [ - "ObjC", - "Dynamic", - "Override" - ], - "init_kind": "Designated" - } - ], - "declKind": "Class", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache", - "mangledName": "$s6Sentry0A16BinaryImageCacheC", - "moduleName": "Sentry", - "objc_name": "SentryBinaryImageCache", - "declAttributes": [ - "ObjC" - ], - "superclassUsr": "c:objc(cs)NSObject", - "inheritsConvenienceInitializers": true, - "superclassNames": [ - "ObjectiveC.NSObject" - ], - "conformances": [ - { - "kind": "Conformance", - "name": "Copyable", - "printedName": "Copyable", - "usr": "s:s8CopyableP", - "mangledName": "$ss8CopyableP" - }, - { - "kind": "Conformance", - "name": "Escapable", - "printedName": "Escapable", - "usr": "s:s9EscapableP", - "mangledName": "$ss9EscapableP" - }, - { - "kind": "Conformance", - "name": "NSObjectProtocol", - "printedName": "NSObjectProtocol", - "usr": "c:objc(pl)NSObject" - }, - { - "kind": "Conformance", - "name": "Equatable", - "printedName": "Equatable", - "usr": "s:SQ", - "mangledName": "$sSQ" - }, - { - "kind": "Conformance", - "name": "Hashable", - "printedName": "Hashable", - "usr": "s:SH", - "mangledName": "$sSH" - }, - { - "kind": "Conformance", - "name": "CVarArg", - "printedName": "CVarArg", - "usr": "s:s7CVarArgP", - "mangledName": "$ss7CVarArgP" - }, - { - "kind": "Conformance", - "name": "CustomStringConvertible", - "printedName": "CustomStringConvertible", - "usr": "s:s23CustomStringConvertibleP", - "mangledName": "$ss23CustomStringConvertibleP" - }, - { - "kind": "Conformance", - "name": "CustomDebugStringConvertible", - "printedName": "CustomDebugStringConvertible", - "usr": "s:s28CustomDebugStringConvertibleP", - "mangledName": "$ss28CustomDebugStringConvertibleP" - } - ] - }, { "kind": "TypeDecl", "name": "SentryRedactRegionType", diff --git a/sdk_api_V9.json b/sdk_api_V9.json index 3d2d5614fa0..c298cafa12c 100644 --- a/sdk_api_V9.json +++ b/sdk_api_V9.json @@ -53644,998 +53644,6 @@ } ] }, - { - "kind": "TypeDecl", - "name": "SentryBinaryImageInfo", - "printedName": "SentryBinaryImageInfo", - "children": [ - { - "kind": "Var", - "name": "name", - "printedName": "name", - "children": [ - { - "kind": "TypeNominal", - "name": "String", - "printedName": "Swift.String", - "usr": "s:SS" - } - ], - "declKind": "Var", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(py)name", - "mangledName": "$s6Sentry0A15BinaryImageInfoC4nameSSvp", - "moduleName": "Sentry", - "declAttributes": [ - "ObjC", - "HasStorage" - ], - "hasStorage": true, - "accessors": [ - { - "kind": "Accessor", - "name": "Get", - "printedName": "Get()", - "children": [ - { - "kind": "TypeNominal", - "name": "String", - "printedName": "Swift.String", - "usr": "s:SS" - } - ], - "declKind": "Accessor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)name", - "mangledName": "$s6Sentry0A15BinaryImageInfoC4nameSSvg", - "moduleName": "Sentry", - "implicit": true, - "declAttributes": [ - "ObjC" - ], - "accessorKind": "get" - }, - { - "kind": "Accessor", - "name": "Set", - "printedName": "Set()", - "children": [ - { - "kind": "TypeNominal", - "name": "Void", - "printedName": "()" - }, - { - "kind": "TypeNominal", - "name": "String", - "printedName": "Swift.String", - "usr": "s:SS" - } - ], - "declKind": "Accessor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)setName:", - "mangledName": "$s6Sentry0A15BinaryImageInfoC4nameSSvs", - "moduleName": "Sentry", - "implicit": true, - "declAttributes": [ - "ObjC" - ], - "accessorKind": "set" - } - ] - }, - { - "kind": "Var", - "name": "uuid", - "printedName": "uuid", - "children": [ - { - "kind": "TypeNominal", - "name": "Optional", - "printedName": "Swift.String?", - "children": [ - { - "kind": "TypeNominal", - "name": "String", - "printedName": "Swift.String", - "usr": "s:SS" - } - ], - "usr": "s:Sq" - } - ], - "declKind": "Var", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(py)uuid", - "mangledName": "$s6Sentry0A15BinaryImageInfoC4uuidSSSgvp", - "moduleName": "Sentry", - "declAttributes": [ - "HasInitialValue", - "ObjC", - "HasStorage" - ], - "hasStorage": true, - "accessors": [ - { - "kind": "Accessor", - "name": "Get", - "printedName": "Get()", - "children": [ - { - "kind": "TypeNominal", - "name": "Optional", - "printedName": "Swift.String?", - "children": [ - { - "kind": "TypeNominal", - "name": "String", - "printedName": "Swift.String", - "usr": "s:SS" - } - ], - "usr": "s:Sq" - } - ], - "declKind": "Accessor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)uuid", - "mangledName": "$s6Sentry0A15BinaryImageInfoC4uuidSSSgvg", - "moduleName": "Sentry", - "implicit": true, - "declAttributes": [ - "ObjC" - ], - "accessorKind": "get" - }, - { - "kind": "Accessor", - "name": "Set", - "printedName": "Set()", - "children": [ - { - "kind": "TypeNominal", - "name": "Void", - "printedName": "()" - }, - { - "kind": "TypeNominal", - "name": "Optional", - "printedName": "Swift.String?", - "children": [ - { - "kind": "TypeNominal", - "name": "String", - "printedName": "Swift.String", - "usr": "s:SS" - } - ], - "usr": "s:Sq" - } - ], - "declKind": "Accessor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)setUuid:", - "mangledName": "$s6Sentry0A15BinaryImageInfoC4uuidSSSgvs", - "moduleName": "Sentry", - "implicit": true, - "declAttributes": [ - "ObjC" - ], - "accessorKind": "set" - } - ] - }, - { - "kind": "Var", - "name": "vmAddress", - "printedName": "vmAddress", - "children": [ - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Var", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(py)vmAddress", - "mangledName": "$s6Sentry0A15BinaryImageInfoC9vmAddresss6UInt64Vvp", - "moduleName": "Sentry", - "declAttributes": [ - "ObjC", - "HasStorage" - ], - "hasStorage": true, - "accessors": [ - { - "kind": "Accessor", - "name": "Get", - "printedName": "Get()", - "children": [ - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Accessor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)vmAddress", - "mangledName": "$s6Sentry0A15BinaryImageInfoC9vmAddresss6UInt64Vvg", - "moduleName": "Sentry", - "implicit": true, - "declAttributes": [ - "ObjC" - ], - "accessorKind": "get" - }, - { - "kind": "Accessor", - "name": "Set", - "printedName": "Set()", - "children": [ - { - "kind": "TypeNominal", - "name": "Void", - "printedName": "()" - }, - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Accessor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)setVmAddress:", - "mangledName": "$s6Sentry0A15BinaryImageInfoC9vmAddresss6UInt64Vvs", - "moduleName": "Sentry", - "implicit": true, - "declAttributes": [ - "ObjC" - ], - "accessorKind": "set" - } - ] - }, - { - "kind": "Var", - "name": "address", - "printedName": "address", - "children": [ - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Var", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(py)address", - "mangledName": "$s6Sentry0A15BinaryImageInfoC7addresss6UInt64Vvp", - "moduleName": "Sentry", - "declAttributes": [ - "ObjC", - "HasStorage" - ], - "hasStorage": true, - "accessors": [ - { - "kind": "Accessor", - "name": "Get", - "printedName": "Get()", - "children": [ - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Accessor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)address", - "mangledName": "$s6Sentry0A15BinaryImageInfoC7addresss6UInt64Vvg", - "moduleName": "Sentry", - "implicit": true, - "declAttributes": [ - "ObjC" - ], - "accessorKind": "get" - }, - { - "kind": "Accessor", - "name": "Set", - "printedName": "Set()", - "children": [ - { - "kind": "TypeNominal", - "name": "Void", - "printedName": "()" - }, - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Accessor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)setAddress:", - "mangledName": "$s6Sentry0A15BinaryImageInfoC7addresss6UInt64Vvs", - "moduleName": "Sentry", - "implicit": true, - "declAttributes": [ - "ObjC" - ], - "accessorKind": "set" - } - ] - }, - { - "kind": "Var", - "name": "size", - "printedName": "size", - "children": [ - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Var", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(py)size", - "mangledName": "$s6Sentry0A15BinaryImageInfoC4sizes6UInt64Vvp", - "moduleName": "Sentry", - "declAttributes": [ - "ObjC", - "HasStorage" - ], - "hasStorage": true, - "accessors": [ - { - "kind": "Accessor", - "name": "Get", - "printedName": "Get()", - "children": [ - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Accessor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)size", - "mangledName": "$s6Sentry0A15BinaryImageInfoC4sizes6UInt64Vvg", - "moduleName": "Sentry", - "implicit": true, - "declAttributes": [ - "ObjC" - ], - "accessorKind": "get" - }, - { - "kind": "Accessor", - "name": "Set", - "printedName": "Set()", - "children": [ - { - "kind": "TypeNominal", - "name": "Void", - "printedName": "()" - }, - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Accessor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)setSize:", - "mangledName": "$s6Sentry0A15BinaryImageInfoC4sizes6UInt64Vvs", - "moduleName": "Sentry", - "implicit": true, - "declAttributes": [ - "ObjC" - ], - "accessorKind": "set" - } - ] - }, - { - "kind": "Constructor", - "name": "init", - "printedName": "init(name:uuid:vmAddress:address:size:)", - "children": [ - { - "kind": "TypeNominal", - "name": "SentryBinaryImageInfo", - "printedName": "Sentry.SentryBinaryImageInfo", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo" - }, - { - "kind": "TypeNominal", - "name": "String", - "printedName": "Swift.String", - "usr": "s:SS" - }, - { - "kind": "TypeNominal", - "name": "Optional", - "printedName": "Swift.String?", - "children": [ - { - "kind": "TypeNominal", - "name": "String", - "printedName": "Swift.String", - "usr": "s:SS" - } - ], - "usr": "s:Sq" - }, - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - }, - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - }, - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Constructor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo(im)initWithName:uuid:vmAddress:address:size:", - "mangledName": "$s6Sentry0A15BinaryImageInfoC4name4uuid9vmAddress7address4sizeACSS_SSSgs6UInt64VA2Ktcfc", - "moduleName": "Sentry", - "objc_name": "initWithName:uuid:vmAddress:address:size:", - "declAttributes": [ - "ObjC" - ], - "init_kind": "Designated" - } - ], - "declKind": "Class", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo", - "mangledName": "$s6Sentry0A15BinaryImageInfoC", - "moduleName": "Sentry", - "objc_name": "SentryBinaryImageInfo", - "declAttributes": [ - "ObjC" - ], - "superclassUsr": "c:objc(cs)NSObject", - "superclassNames": [ - "ObjectiveC.NSObject" - ], - "conformances": [ - { - "kind": "Conformance", - "name": "Copyable", - "printedName": "Copyable", - "usr": "s:s8CopyableP", - "mangledName": "$ss8CopyableP" - }, - { - "kind": "Conformance", - "name": "Escapable", - "printedName": "Escapable", - "usr": "s:s9EscapableP", - "mangledName": "$ss9EscapableP" - }, - { - "kind": "Conformance", - "name": "NSObjectProtocol", - "printedName": "NSObjectProtocol", - "usr": "c:objc(pl)NSObject" - }, - { - "kind": "Conformance", - "name": "Equatable", - "printedName": "Equatable", - "usr": "s:SQ", - "mangledName": "$sSQ" - }, - { - "kind": "Conformance", - "name": "Hashable", - "printedName": "Hashable", - "usr": "s:SH", - "mangledName": "$sSH" - }, - { - "kind": "Conformance", - "name": "CVarArg", - "printedName": "CVarArg", - "usr": "s:s7CVarArgP", - "mangledName": "$ss7CVarArgP" - }, - { - "kind": "Conformance", - "name": "CustomStringConvertible", - "printedName": "CustomStringConvertible", - "usr": "s:s23CustomStringConvertibleP", - "mangledName": "$ss23CustomStringConvertibleP" - }, - { - "kind": "Conformance", - "name": "CustomDebugStringConvertible", - "printedName": "CustomDebugStringConvertible", - "usr": "s:s28CustomDebugStringConvertibleP", - "mangledName": "$ss28CustomDebugStringConvertibleP" - } - ] - }, - { - "kind": "TypeDecl", - "name": "SentryBinaryImageCache", - "printedName": "SentryBinaryImageCache", - "children": [ - { - "kind": "Var", - "name": "cache", - "printedName": "cache", - "children": [ - { - "kind": "TypeNominal", - "name": "Optional", - "printedName": "[Sentry.SentryBinaryImageInfo]?", - "children": [ - { - "kind": "TypeNominal", - "name": "Array", - "printedName": "[Sentry.SentryBinaryImageInfo]", - "children": [ - { - "kind": "TypeNominal", - "name": "SentryBinaryImageInfo", - "printedName": "Sentry.SentryBinaryImageInfo", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo" - } - ], - "usr": "s:Sa" - } - ], - "usr": "s:Sq" - } - ], - "declKind": "Var", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(py)cache", - "mangledName": "$s6Sentry0A16BinaryImageCacheC5cacheSayAA0abC4InfoCGSgvp", - "moduleName": "Sentry", - "declAttributes": [ - "ObjC" - ], - "accessors": [ - { - "kind": "Accessor", - "name": "Get", - "printedName": "Get()", - "children": [ - { - "kind": "TypeNominal", - "name": "Optional", - "printedName": "[Sentry.SentryBinaryImageInfo]?", - "children": [ - { - "kind": "TypeNominal", - "name": "Array", - "printedName": "[Sentry.SentryBinaryImageInfo]", - "children": [ - { - "kind": "TypeNominal", - "name": "SentryBinaryImageInfo", - "printedName": "Sentry.SentryBinaryImageInfo", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo" - } - ], - "usr": "s:Sa" - } - ], - "usr": "s:Sq" - } - ], - "declKind": "Accessor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)cache", - "mangledName": "$s6Sentry0A16BinaryImageCacheC5cacheSayAA0abC4InfoCGSgvg", - "moduleName": "Sentry", - "declAttributes": [ - "ObjC" - ], - "accessorKind": "get" - } - ] - }, - { - "kind": "Function", - "name": "stop", - "printedName": "stop()", - "children": [ - { - "kind": "TypeNominal", - "name": "Void", - "printedName": "()" - } - ], - "declKind": "Func", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)stop", - "mangledName": "$s6Sentry0A16BinaryImageCacheC4stopyyF", - "moduleName": "Sentry", - "declAttributes": [ - "ObjC" - ], - "funcSelfKind": "NonMutating" - }, - { - "kind": "Function", - "name": "binaryImageAdded", - "printedName": "binaryImageAdded(imageName:vmAddress:address:size:uuid:)", - "children": [ - { - "kind": "TypeNominal", - "name": "Void", - "printedName": "()" - }, - { - "kind": "TypeNominal", - "name": "Optional", - "printedName": "Swift.UnsafePointer?", - "children": [ - { - "kind": "TypeNominal", - "name": "UnsafePointer", - "printedName": "Swift.UnsafePointer", - "children": [ - { - "kind": "TypeNameAlias", - "name": "CChar", - "printedName": "Swift.CChar", - "children": [ - { - "kind": "TypeNominal", - "name": "Int8", - "printedName": "Swift.Int8", - "usr": "s:s4Int8V" - } - ] - } - ], - "usr": "s:SP" - } - ], - "usr": "s:Sq" - }, - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - }, - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - }, - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - }, - { - "kind": "TypeNominal", - "name": "Optional", - "printedName": "Swift.UnsafePointer?", - "children": [ - { - "kind": "TypeNominal", - "name": "UnsafePointer", - "printedName": "Swift.UnsafePointer", - "children": [ - { - "kind": "TypeNominal", - "name": "UInt8", - "printedName": "Swift.UInt8", - "usr": "s:s5UInt8V" - } - ], - "usr": "s:SP" - } - ], - "usr": "s:Sq" - } - ], - "declKind": "Func", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)binaryImageAdded:vmAddress:address:size:uuid:", - "mangledName": "$s6Sentry0A16BinaryImageCacheC06binaryC5Added9imageName9vmAddress7address4size4uuidySPys4Int8VGSg_s6UInt64VA2OSPys5UInt8VGSgtF", - "moduleName": "Sentry", - "objc_name": "binaryImageAdded:vmAddress:address:size:uuid:", - "declAttributes": [ - "ObjC" - ], - "funcSelfKind": "NonMutating" - }, - { - "kind": "Function", - "name": "convertUUID", - "printedName": "convertUUID(_:)", - "children": [ - { - "kind": "TypeNominal", - "name": "Optional", - "printedName": "Swift.String?", - "children": [ - { - "kind": "TypeNominal", - "name": "String", - "printedName": "Swift.String", - "usr": "s:SS" - } - ], - "usr": "s:Sq" - }, - { - "kind": "TypeNominal", - "name": "Optional", - "printedName": "Swift.UnsafePointer?", - "children": [ - { - "kind": "TypeNominal", - "name": "UnsafePointer", - "printedName": "Swift.UnsafePointer", - "children": [ - { - "kind": "TypeNominal", - "name": "UInt8", - "printedName": "Swift.UInt8", - "usr": "s:s5UInt8V" - } - ], - "usr": "s:SP" - } - ], - "usr": "s:Sq" - } - ], - "declKind": "Func", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(cm)convertUUID:", - "mangledName": "$s6Sentry0A16BinaryImageCacheC11convertUUIDySSSgSPys5UInt8VGSgFZ", - "moduleName": "Sentry", - "static": true, - "declAttributes": [ - "Final", - "ObjC" - ], - "funcSelfKind": "NonMutating" - }, - { - "kind": "Function", - "name": "binaryImageRemoved", - "printedName": "binaryImageRemoved(_:)", - "children": [ - { - "kind": "TypeNominal", - "name": "Void", - "printedName": "()" - }, - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Func", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)binaryImageRemoved:", - "mangledName": "$s6Sentry0A16BinaryImageCacheC06binaryC7Removedyys6UInt64VF", - "moduleName": "Sentry", - "declAttributes": [ - "ObjC" - ], - "funcSelfKind": "NonMutating" - }, - { - "kind": "Function", - "name": "imageByAddress", - "printedName": "imageByAddress(_:)", - "children": [ - { - "kind": "TypeNominal", - "name": "Optional", - "printedName": "Sentry.SentryBinaryImageInfo?", - "children": [ - { - "kind": "TypeNominal", - "name": "SentryBinaryImageInfo", - "printedName": "Sentry.SentryBinaryImageInfo", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo" - } - ], - "usr": "s:Sq" - }, - { - "kind": "TypeNominal", - "name": "UInt64", - "printedName": "Swift.UInt64", - "usr": "s:s6UInt64V" - } - ], - "declKind": "Func", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)imageByAddress:", - "mangledName": "$s6Sentry0A16BinaryImageCacheC14imageByAddressyAA0abC4InfoCSgs6UInt64VF", - "moduleName": "Sentry", - "declAttributes": [ - "ObjC" - ], - "funcSelfKind": "NonMutating" - }, - { - "kind": "Function", - "name": "imagePathsFor", - "printedName": "imagePathsFor(inAppInclude:)", - "children": [ - { - "kind": "TypeNominal", - "name": "Set", - "printedName": "Swift.Set", - "children": [ - { - "kind": "TypeNominal", - "name": "String", - "printedName": "Swift.String", - "usr": "s:SS" - } - ], - "usr": "s:Sh" - }, - { - "kind": "TypeNominal", - "name": "String", - "printedName": "Swift.String", - "usr": "s:SS" - } - ], - "declKind": "Func", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)imagePathsForInAppInclude:", - "mangledName": "$s6Sentry0A16BinaryImageCacheC13imagePathsFor12inAppIncludeShySSGSS_tF", - "moduleName": "Sentry", - "objc_name": "imagePathsForInAppInclude:", - "declAttributes": [ - "ObjC" - ], - "funcSelfKind": "NonMutating" - }, - { - "kind": "Function", - "name": "getAllBinaryImages", - "printedName": "getAllBinaryImages()", - "children": [ - { - "kind": "TypeNominal", - "name": "Array", - "printedName": "[Sentry.SentryBinaryImageInfo]", - "children": [ - { - "kind": "TypeNominal", - "name": "SentryBinaryImageInfo", - "printedName": "Sentry.SentryBinaryImageInfo", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageInfo" - } - ], - "usr": "s:Sa" - } - ], - "declKind": "Func", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)getAllBinaryImages", - "mangledName": "$s6Sentry0A16BinaryImageCacheC06getAllB6ImagesSayAA0abC4InfoCGyF", - "moduleName": "Sentry", - "declAttributes": [ - "ObjC" - ], - "funcSelfKind": "NonMutating" - }, - { - "kind": "Constructor", - "name": "init", - "printedName": "init()", - "children": [ - { - "kind": "TypeNominal", - "name": "SentryBinaryImageCache", - "printedName": "Sentry.SentryBinaryImageCache", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache" - } - ], - "declKind": "Constructor", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache(im)init", - "mangledName": "$s6Sentry0A16BinaryImageCacheCACycfc", - "moduleName": "Sentry", - "overriding": true, - "objc_name": "init", - "declAttributes": [ - "ObjC", - "Dynamic", - "Override" - ], - "init_kind": "Designated" - } - ], - "declKind": "Class", - "usr": "c:@M@Sentry@objc(cs)SentryBinaryImageCache", - "mangledName": "$s6Sentry0A16BinaryImageCacheC", - "moduleName": "Sentry", - "objc_name": "SentryBinaryImageCache", - "declAttributes": [ - "ObjC" - ], - "superclassUsr": "c:objc(cs)NSObject", - "inheritsConvenienceInitializers": true, - "superclassNames": [ - "ObjectiveC.NSObject" - ], - "conformances": [ - { - "kind": "Conformance", - "name": "Copyable", - "printedName": "Copyable", - "usr": "s:s8CopyableP", - "mangledName": "$ss8CopyableP" - }, - { - "kind": "Conformance", - "name": "Escapable", - "printedName": "Escapable", - "usr": "s:s9EscapableP", - "mangledName": "$ss9EscapableP" - }, - { - "kind": "Conformance", - "name": "NSObjectProtocol", - "printedName": "NSObjectProtocol", - "usr": "c:objc(pl)NSObject" - }, - { - "kind": "Conformance", - "name": "Equatable", - "printedName": "Equatable", - "usr": "s:SQ", - "mangledName": "$sSQ" - }, - { - "kind": "Conformance", - "name": "Hashable", - "printedName": "Hashable", - "usr": "s:SH", - "mangledName": "$sSH" - }, - { - "kind": "Conformance", - "name": "CVarArg", - "printedName": "CVarArg", - "usr": "s:s7CVarArgP", - "mangledName": "$ss7CVarArgP" - }, - { - "kind": "Conformance", - "name": "CustomStringConvertible", - "printedName": "CustomStringConvertible", - "usr": "s:s23CustomStringConvertibleP", - "mangledName": "$ss23CustomStringConvertibleP" - }, - { - "kind": "Conformance", - "name": "CustomDebugStringConvertible", - "printedName": "CustomDebugStringConvertible", - "usr": "s:s28CustomDebugStringConvertibleP", - "mangledName": "$ss28CustomDebugStringConvertibleP" - } - ] - }, { "kind": "TypeDecl", "name": "SentryRedactRegionType", From 883d660cc827b8bf5ce80a0b5a417a9e07c568e7 Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Thu, 28 Aug 2025 10:55:49 -0300 Subject: [PATCH 11/14] Refactor `imageByAddress` method to simplify index check and update return value in `SentryBinaryImageCache` --- Sources/Swift/Core/Helper/SentryBinaryImageCache.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift b/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift index 8da4ac77802..25ac60b43c3 100644 --- a/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift +++ b/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift @@ -122,7 +122,7 @@ import Foundation @objc public func imageByAddress(_ address: UInt64) -> SentryBinaryImageInfo? { lock.synchronized { - guard let index = indexOfImage(address: address), index >= 0 else { return nil } + guard let index = indexOfImage(address: address) else { return nil } return cache?[index] } } @@ -146,7 +146,7 @@ import Foundation } } - return -1 // Address not found + return nil } @objc(imagePathsForInAppInclude:) From e2ec1d4e56f7326c697705d8f16deabf86214454 Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Thu, 28 Aug 2025 17:59:03 -0300 Subject: [PATCH 12/14] Fix PR review comments --- .../Core/Helper/SentryBinaryImageCache.swift | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift b/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift index 25ac60b43c3..2182f6c86e4 100644 --- a/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift +++ b/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift @@ -31,7 +31,7 @@ import Foundation // Use a recursive lock to allow the same thread to enter again private let lock = NSRecursiveLock() - @_spi(Private) @objc public func start(_ isDebug: Bool) { + @objc public func start(_ isDebug: Bool) { lock.synchronized { self.isDebug = isDebug self.cache = [] @@ -73,7 +73,7 @@ import Foundation ) lock.synchronized { - guard let cache = self.cache else { return } + guard var cache = self.cache else { return } // Binary search insertion to maintain sorted order by address var left = 0 @@ -89,7 +89,7 @@ import Foundation } } - self.cache?.insert(newImage, at: left) + cache.insert(newImage, at: left) } if isDebug { @@ -108,13 +108,13 @@ import Foundation var uuidBuffer = [CChar](repeating: 0, count: 37) sentrycrashdl_convertBinaryImageUUID(value, &uuidBuffer) - return String(cString: uuidBuffer) + return String(cString: uuidBuffer, encoding: .ascii) } @objc public func binaryImageRemoved(_ imageAddress: UInt64) { lock.synchronized { - guard let index = indexOfImage(address: imageAddress), index >= 0 else { return } + guard let index = indexOfImage(address: imageAddress) else { return } self.cache?.remove(at: index) } } @@ -151,9 +151,9 @@ import Foundation @objc(imagePathsForInAppInclude:) public func imagePathsFor(inAppInclude: String) -> Set { - var imagePaths = Set() - - imagePaths = lock.synchronized { + lock.synchronized { + var imagePaths = Set() + guard let cache = self.cache else { return imagePaths } for info in cache { @@ -163,8 +163,6 @@ import Foundation } return imagePaths } - - return imagePaths } @objc From 4c3e86e24e1f9f9da8d68f01e0da7c4c624c031d Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Thu, 28 Aug 2025 19:59:40 -0300 Subject: [PATCH 13/14] Revert to use `self.cache?.insert` --- Sources/Swift/Core/Helper/SentryBinaryImageCache.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift b/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift index 2182f6c86e4..238632fe836 100644 --- a/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift +++ b/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift @@ -89,7 +89,7 @@ import Foundation } } - cache.insert(newImage, at: left) + self.cache?.insert(newImage, at: left) } if isDebug { From f789978b22f0c0e299afabc8d7d2788fb5ca71f2 Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Fri, 29 Aug 2025 09:56:41 -0300 Subject: [PATCH 14/14] Revert unmutated variable to use let --- Sources/Swift/Core/Helper/SentryBinaryImageCache.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift b/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift index 238632fe836..5222801bf00 100644 --- a/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift +++ b/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift @@ -73,7 +73,7 @@ import Foundation ) lock.synchronized { - guard var cache = self.cache else { return } + guard let cache = self.cache else { return } // Binary search insertion to maintain sorted order by address var left = 0