diff --git a/Sentry.xcodeproj/project.pbxproj b/Sentry.xcodeproj/project.pbxproj index 0a84ebb6871..d769c2a359f 100644 --- a/Sentry.xcodeproj/project.pbxproj +++ b/Sentry.xcodeproj/project.pbxproj @@ -935,8 +935,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 /* SentryBinaryImageCache.h in Headers */ = {isa = PBXBuildFile; fileRef = D858FA642A29EAB3002A3503 /* SentryBinaryImageCache.h */; settings = {ATTRIBUTES = (Private, ); }; }; - D858FA672A29EAB3002A3503 /* SentryBinaryImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = D858FA652A29EAB3002A3503 /* SentryBinaryImageCache.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 */; }; @@ -1008,7 +1006,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 /* SentryBinaryImageCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D8CCFC622A1520C900DE232E /* SentryBinaryImageCacheTests.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 */; }; @@ -1038,6 +1035,10 @@ 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 */; }; + 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 */; }; F48F767C2E60B555009D4E7D /* SentryNSTimerFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = F48F767B2E60B555009D4E7D /* SentryNSTimerFactory.swift */; }; F49D41982DEA27AF00D9244E /* SentryUseNSExceptionCallstackWrapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F49D41972DEA27AF00D9244E /* SentryUseNSExceptionCallstackWrapperTests.swift */; }; F49D419A2DEA2FB000D9244E /* SentryCrashExceptionApplicationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F49D41992DEA2FB000D9244E /* SentryCrashExceptionApplicationTests.swift */; }; @@ -1534,7 +1535,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 = ""; }; @@ -1586,7 +1587,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 = ""; }; @@ -2268,8 +2269,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 /* 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 = ""; }; 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 = ""; }; @@ -2278,7 +2277,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 = ""; }; @@ -2351,7 +2350,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 /* SentryBinaryImageCacheTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryBinaryImageCacheTests.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 = ""; }; @@ -2382,6 +2380,10 @@ 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 = ""; }; + 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; name = SentryBinaryImageCacheCallbacks.h; path = ../../Sentry/include/SentryBinaryImageCacheCallbacks.h; sourceTree = ""; }; + F49236EA2E5E4B2F00663673 /* SentryBinaryImageCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryBinaryImageCache.swift; sourceTree = ""; }; F48F767B2E60B555009D4E7D /* SentryNSTimerFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryNSTimerFactory.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 = ""; }; @@ -2946,8 +2948,6 @@ FAB359992E05D8080083D5E3 /* SentryEventSwiftHelper.m */, 33042A0B29DAF5F400C60085 /* SentryExtraContextProvider.h */, 33042A0C29DAF79A00C60085 /* SentryExtraContextProvider.m */, - D858FA642A29EAB3002A3503 /* SentryBinaryImageCache.h */, - D858FA652A29EAB3002A3503 /* SentryBinaryImageCache.m */, D8739D152BEEA33F007D2F66 /* SentryLevelHelper.h */, D8739D162BEEA33F007D2F66 /* SentryLevelHelper.m */, F452438B2DE65BC0003E8F50 /* SentryUseNSExceptionCallstackWrapper.h */, @@ -3154,6 +3154,8 @@ 63FE6FE920DA4C1000CDBAE8 /* Recording */ = { isa = PBXGroup; children = ( + F48F75722E5FA649009D4E7D /* SentryBinaryImageCacheCallbacks.h */, + F48F75702E5FA630009D4E7D /* SentryBinaryImageCacheCallbacks.m */, 63FE704B20DA4C1000CDBAE8 /* SentryCrash.h */, 63FE704120DA4C1000CDBAE8 /* SentryCrash.m */, 63FE704920DA4C1000CDBAE8 /* SentryCrashC.h */, @@ -3282,9 +3284,9 @@ 63FE71D220DA66C500CDBAE8 /* SentryCrash */ = { isa = PBXGroup; children = ( + F48F74F22E5F9959009D4E7D /* SentryCrashBinaryImageCacheTests.m */, F4AACD602E01ACE800DDDD1E /* SentryCrashDynamicLinkerTests.m */, 63FE71F120DA66EA00CDBAE8 /* Container+DeepSearch_Tests.m */, - D8CCFC622A1520C900DE232E /* SentryBinaryImageCacheTests.m */, 63FE71F620DA66EB00CDBAE8 /* FileBasedTestCase.h */, 63FE71D920DA66E700CDBAE8 /* FileBasedTestCase.m */, 84EB21952BF01CEA00EDDA28 /* SentryCrashInstallationTests.swift */, @@ -4757,6 +4759,7 @@ FA67DCCC2DDBD4EA00896B02 /* Helper */ = { isa = PBXGroup; children = ( + F49236EA2E5E4B2F00663673 /* SentryBinaryImageCache.swift */, FAAB2F962E4D344F00FE8B7E /* SentryUIDeviceWrapper.swift */, FA90FAA72E06614B008CAAE8 /* SentryExtraPackages.swift */, FA67DCC82DDBD4EA00896B02 /* Log */, @@ -4975,7 +4978,6 @@ 8E4A037825F6F52100000D77 /* SentrySampleDecision.h in Headers */, 63FE717920DA4C1100CDBAE8 /* SentryCrashReportStore.h in Headers */, 0AAE202128ED9BCC00D0CD80 /* SentryReachability.h in Headers */, - D858FA662A29EAB3002A3503 /* SentryBinaryImageCache.h in Headers */, A839D89824864B80003B7AFD /* SentrySystemEventBreadcrumbs.h in Headers */, 7B14089624878F090035403D /* SentryCrashStackEntryMapper.h in Headers */, 63FE714920DA4C1100CDBAE8 /* SentryCrashStackCursor_Backtrace.h in Headers */, @@ -4988,6 +4990,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 */, @@ -5672,7 +5675,6 @@ D473ACD72D8090FC000F1CC6 /* FileManager+SentryTracing.swift in Sources */, D4AF00212D2E92FD00F5F3D7 /* SentryNSFileManagerSwizzling.m in Sources */, 639FCFA91EBC80CC00778193 /* SentryFrame.m in Sources */, - D858FA672A29EAB3002A3503 /* SentryBinaryImageCache.m in Sources */, 8E564AEA267AF22600FE117D /* SentryNetworkTracker.m in Sources */, 15360CED2433A15500112302 /* SentryInstallation.m in Sources */, D8370B6A273DF1E900F66E2D /* SentryNSURLSessionTaskSearch.m in Sources */, @@ -5791,6 +5793,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 */, @@ -5835,6 +5838,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 */, @@ -6113,8 +6117,8 @@ 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 */, - D8CCFC632A1520C900DE232E /* SentryBinaryImageCacheTests.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 adcfb473e48..d3c377a9cfb 100644 --- a/SentryTestUtils/SentryTestUtils-ObjC-BridgingHeader.h +++ b/SentryTestUtils/SentryTestUtils-ObjC-BridgingHeader.h @@ -25,7 +25,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/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 ce790cfd606..1a10502328e 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 f8b842c9d25..f86b8885b2c 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" 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/SentryBinaryImageCacheCallbacks.h b/Sources/Sentry/include/SentryBinaryImageCacheCallbacks.h new file mode 100644 index 00000000000..c966ef3e076 --- /dev/null +++ b/Sources/Sentry/include/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/SentryCrashBinaryImageCache.h b/Sources/Sentry/include/SentryCrashBinaryImageCache.h similarity index 94% rename from Sources/SentryCrash/Recording/SentryCrashBinaryImageCache.h rename to Sources/Sentry/include/SentryCrashBinaryImageCache.h index 4c8ee11db31..01fbe576b54 100644 --- a/Sources/SentryCrash/Recording/SentryCrashBinaryImageCache.h +++ b/Sources/Sentry/include/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/Sentry/include/SentryCrashDynamicLinker.h similarity index 100% rename from Sources/SentryCrash/Recording/Tools/SentryCrashDynamicLinker.h rename to Sources/Sentry/include/SentryCrashDynamicLinker.h index 44ba737b627..faf8fb529c2 100644 --- a/Sources/SentryCrash/Recording/Tools/SentryCrashDynamicLinker.h +++ b/Sources/Sentry/include/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__ 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/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/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 new file mode 100644 index 00000000000..5222801bf00 --- /dev/null +++ b/Sources/Swift/Core/Helper/SentryBinaryImageCache.swift @@ -0,0 +1,174 @@ +@_implementationOnly import _SentryPrivate +import Foundation + +@objc(SentryBinaryImageInfo) +@_spi(Private) public final 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) +@_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 + private let lock = NSRecursiveLock() + + @objc public func start(_ isDebug: Bool) { + lock.synchronized { + self.isDebug = isDebug + self.cache = [] + 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: Dependencies.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, encoding: .ascii) + } + + @objc + public func binaryImageRemoved(_ imageAddress: UInt64) { + lock.synchronized { + guard let index = indexOfImage(address: imageAddress) else { return } + self.cache?.remove(at: index) + } + } + + @objc + public func imageByAddress(_ address: UInt64) -> SentryBinaryImageInfo? { + lock.synchronized { + guard let index = indexOfImage(address: address) 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 nil + } + + @objc(imagePathsForInAppInclude:) + public func imagePathsFor(inAppInclude: String) -> Set { + lock.synchronized { + var imagePaths = Set() + + 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 + } + } + + @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..ac847e98cf4 100644 --- a/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerSwizzlingTests.swift +++ b/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerSwizzlingTests.swift @@ -204,9 +204,13 @@ class SentryUIViewControllerSwizzlingTests: XCTestCase { let debugDylib = "\(imageName).debug.dylib" - var image = createCrashBinaryImage(0, name: debugDylib) + let image = createCrashBinaryImage(0, name: debugDylib) SentryDependencyContainer.sharedInstance().binaryImageCache.start(false) - SentryDependencyContainer.sharedInstance().binaryImageCache.binaryImageAdded(&image) + 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..277a63d5c47 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 { @@ -15,112 +16,124 @@ class SentryBinaryImageCacheTests: XCTestCase { 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 +151,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 +163,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 +175,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 +187,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() { @@ -187,8 +200,8 @@ class SentryBinaryImageCacheTests: XCTestCase { 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 99% rename from Tests/SentryTests/SentryCrash/SentryBinaryImageCacheTests.m rename to Tests/SentryTests/SentryCrash/SentryCrashBinaryImageCacheTests.m index 2fdd1f9aacf..5e803368a29 100644 --- a/Tests/SentryTests/SentryCrash/SentryBinaryImageCacheTests.m +++ b/Tests/SentryTests/SentryCrash/SentryCrashBinaryImageCacheTests.m @@ -1,8 +1,8 @@ -#import "SentryBinaryImageCache+Private.h" #import "SentryCrashBinaryImageCache.h" #import "SentryCrashDynamicLinker+Test.h" #import "SentryCrashWrapper.h" #import "SentryDependencyContainer.h" +#import "SentrySwift.h" #import #include diff --git a/Tests/SentryTests/SentryCrash/SentryCrashStackEntryMapperTests.swift b/Tests/SentryTests/SentryCrash/SentryCrashStackEntryMapperTests.swift index 8f4d6fadee9..ab4afee4b42 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,13 @@ class SentryCrashStackEntryMapperTests: XCTestCase { } func testImageFromCache() { - var image = createCrashBinaryImage(2_488_998_912) + let image = createCrashBinaryImage(2_488_998_912) SentryDependencyContainer.sharedInstance().binaryImageCache.start(false) - SentryDependencyContainer.sharedInstance().binaryImageCache.binaryImageAdded(&image) + 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..631f9a4a463 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 /** @@ -22,8 +23,11 @@ class SentryDebugImageProviderTests: XCTestCase { cache.start(false) 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 82fa8c6b14b..1edf139d24a 100644 --- a/Tests/SentryTests/SentryTests-Bridging-Header.h +++ b/Tests/SentryTests/SentryTests-Bridging-Header.h @@ -186,7 +186,6 @@ #import "NSData+Unzip.h" #import "Sentry/Sentry-Swift.h" -#import "SentryBinaryImageCache+Private.h" #import "SentryCrashBinaryImageCache.h" #import "SentryDispatchFactory.h" #import "SentryDispatchSourceWrapper.h"