Skip to content

Commit

Permalink
fix(ios): BinaryImageCache is only available from dependency container (
Browse files Browse the repository at this point in the history
  • Loading branch information
krystofwoldrich committed Sep 12, 2023
1 parent 2dc9bc2 commit 539989f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ SentrySDK (PrivateTests)
@interface SentryDependencyContainer : NSObject
+ (instancetype)sharedInstance;
@property (nonatomic, strong) SentryDebugImageProvider *debugImageProvider;
@property (nonatomic, strong) SentryBinaryImageCache *binaryImageCache;
@end
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ - (void)prepareNativeFrameMocksWithLocalSymbolication: (BOOL) debug
id sentrySDKMock = OCMClassMock([SentrySDK class]);
OCMStub([(SentrySDK*) sentrySDKMock options]).andReturn(sentryOptions);

id sentryDependencyContainerMock = OCMClassMock([SentryDependencyContainer class]);
OCMStub(ClassMethod([sentryDependencyContainerMock sharedInstance])).andReturn(sentryDependencyContainerMock);

id sentryBinaryImageInfoMockOne = OCMClassMock([SentryBinaryImageInfo class]);
OCMStub([(SentryBinaryImageInfo*) sentryBinaryImageInfoMockOne address]).andReturn([@112233 unsignedLongLongValue]);
OCMStub([sentryBinaryImageInfoMockOne name]).andReturn(@"testnameone");
Expand All @@ -198,7 +201,7 @@ - (void)prepareNativeFrameMocksWithLocalSymbolication: (BOOL) debug
OCMStub([sentryBinaryImageInfoMockTwo name]).andReturn(@"testnametwo");

id sentryBinaryImageCacheMock = OCMClassMock([SentryBinaryImageCache class]);
OCMStub(ClassMethod([sentryBinaryImageCacheMock shared])).andReturn(sentryBinaryImageCacheMock);
OCMStub([(SentryDependencyContainer*) sentryDependencyContainerMock binaryImageCache]).andReturn(sentryBinaryImageCacheMock);
OCMStub([sentryBinaryImageCacheMock imageByAddress:[@123 unsignedLongLongValue]]).andReturn(sentryBinaryImageInfoMockOne);
OCMStub([sentryBinaryImageCacheMock imageByAddress:[@456 unsignedLongLongValue]]).andReturn(sentryBinaryImageInfoMockTwo);

Expand All @@ -214,8 +217,6 @@ - (void)prepareNativeFrameMocksWithLocalSymbolication: (BOOL) debug
id sentryDebugImageProviderMock = OCMClassMock([SentryDebugImageProvider class]);
OCMStub([sentryDebugImageProviderMock getDebugImagesForAddresses:[NSSet setWithObject:@"0x000000000001b669"] isCrash:false]).andReturn(@[sentryDebugImageMock]);

id sentryDependencyContainerMock = OCMClassMock([SentryDependencyContainer class]);
OCMStub(ClassMethod([sentryDependencyContainerMock sharedInstance])).andReturn(sentryDependencyContainerMock);
OCMStub([sentryDependencyContainerMock debugImageProvider]).andReturn(sentryDebugImageProviderMock);
}

Expand Down
2 changes: 1 addition & 1 deletion ios/RNSentry.mm
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ - (NSDictionary*) fetchNativeStackFramesBy: (NSArray<NSNumber*>*)instructionsAdd
NSMutableArray<NSDictionary<NSString *, id> *> * _Nonnull serializedFrames = [[NSMutableArray alloc] init];

for (NSNumber *addr in instructionsAddr) {
SentryBinaryImageInfo * _Nullable image = [[SentryBinaryImageCache shared] imageByAddress:[addr unsignedLongLongValue]];
SentryBinaryImageInfo * _Nullable image = [[[SentryDependencyContainer sharedInstance] binaryImageCache] imageByAddress:[addr unsignedLongLongValue]];
if (image != nil) {
NSString * imageAddr = sentry_formatHexAddressUInt64([image address]);
[imagesAddrToRetrieveDebugMetaImages addObject: imageAddr];
Expand Down

0 comments on commit 539989f

Please sign in to comment.