Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getDebugImagesForImageAddressesFromCache method in the HybridSDKs header #4460

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ NS_ASSUME_NONNULL_BEGIN
- (NSArray<SentryDebugMeta *> *)getDebugImagesFromCacheForThreads:(NSArray<SentryThread *> *)threads
NS_SWIFT_NAME(getDebugImagesFromCacheForThreads(threads:));

/**
* Returns a list of debug images that are being referenced in the given image addresses.
* This function uses the @c SentryBinaryImageCache which is significantly faster than @c
* SentryCrashDefaultBinaryImageProvider for retrieving binary image information.
*/
- (NSArray<SentryDebugMeta *> *)getDebugImagesForImageAddressesFromCache:
(NSSet<NSString *> *)imageAddresses
NS_SWIFT_NAME(getDebugImagesForImageAddressesFromCache(imageAddresses:));
@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,42 @@ class SentryDebugImageProviderTests: XCTestCase {

XCTAssertEqual(actual.count, 0)
}

func testGetDebugImagesForImageAddressesFromCache() throws {
let sut = fixture.getSut(images: fixture.getTestImages())

let imageAddress = "0x00000001410b1a00"

let actual = sut.getDebugImagesForImageAddressesFromCache(imageAddresses: [imageAddress])

XCTAssertEqual(actual.count, 1)
let image = try XCTUnwrap(actual.first)

XCTAssertEqual(image.debugID, "84BAEBDA-AD1A-33F4-B35D-8A45F5DAF322")
XCTAssertEqual(image.type, SentryDebugImageType)
XCTAssertEqual(image.imageVmAddress, "0x0000daf262294000")
XCTAssertEqual(image.imageAddress, "0x00000001410b1a00")
XCTAssertEqual(image.imageSize, 1_352_256)
XCTAssertEqual(image.codeFile, "UIKit")
}

func testGetDebugImagesForImageAddressesFromCache_GarbageImageAddress() throws {
let sut = fixture.getSut(images: fixture.getTestImages())

let imageAddress = "garbage"

let actual = sut.getDebugImagesForImageAddressesFromCache(imageAddresses: [imageAddress])

XCTAssertEqual(actual.count, 0)
}

func testGetDebugImagesForImageAddressesFromCache_EmptyArray() throws {
let sut = fixture.getSut(images: fixture.getTestImages())

let actual = sut.getDebugImagesForImageAddressesFromCache(imageAddresses: [])

XCTAssertEqual(actual.count, 0)
}

private static func createSentryCrashBinaryImage(
address: UInt64 = 0,
Expand Down
Loading