Skip to content
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
3 changes: 1 addition & 2 deletions packages/core/RNSentry.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ Pod::Spec.new do |s|
s.compiler_flags = other_cflags

s.pod_target_xcconfig = {
'DEFINES_MODULE' => 'YES',
'HEADER_SEARCH_PATHS' => '$(inherited) "${PODS_ROOT}/Sentry/Sources/Sentry" "${PODS_ROOT}/Sentry/Sources/Sentry/include"'
'DEFINES_MODULE' => 'YES'
}

s.dependency 'Sentry', '9.12.1'
Expand Down
10 changes: 5 additions & 5 deletions packages/core/ios/RNSentry+fetchNativeStack.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#import "RNSentry.h"
#import "RNSentryBreadcrumb.h"
#import "RNSentryHexFormatter.h"
#import "RNSentryId.h"
#import "SentryFormatter.h"
#import <Sentry/PrivateSentrySDKOnly.h>
@import Sentry;

Expand All @@ -25,12 +25,12 @@ - (NSDictionary *)fetchNativeStackFramesBy:(NSArray<NSNumber *> *)instructionsAd
SentryBinaryImageInfo *_Nullable image = [[[SentryDependencyContainer sharedInstance]
binaryImageCache] imageByAddress:[addr unsignedLongLongValue]];
if (image != nil) {
NSString *imageAddr = sentry_formatHexAddressUInt64([image address]);
NSString *imageAddr = rnsentry_formatHexAddressUInt64([image address]);
[imagesAddrToRetrieveDebugMetaImages addObject:imageAddr];

NSDictionary<NSString *, id> *_Nonnull nativeFrame = @{
@"platform" : @"cocoa",
@"instruction_addr" : sentry_formatHexAddress(addr),
@"instruction_addr" : rnsentry_formatHexAddress(addr),
@"package" : [image name],
@"image_addr" : imageAddr,
@"in_app" : [NSNumber numberWithBool:[appPackageName isEqualToString:[image name]]],
Expand All @@ -45,7 +45,7 @@ - (NSDictionary *)fetchNativeStackFramesBy:(NSArray<NSNumber *> *)instructionsAd
NSMutableDictionary<NSString *, id> *_Nonnull symbolicated
= nativeFrame.mutableCopy;
symbolicated[@"symbol_addr"]
= sentry_formatHexAddressUInt64((uintptr_t)symbolsBuffer.dli_saddr);
= rnsentry_formatHexAddressUInt64((uintptr_t)symbolsBuffer.dli_saddr);
symbolicated[@"function"] = [NSString stringWithCString:symbolsBuffer.dli_sname
encoding:NSUTF8StringEncoding];

Expand All @@ -57,7 +57,7 @@ - (NSDictionary *)fetchNativeStackFramesBy:(NSArray<NSNumber *> *)instructionsAd
} else {
[serializedFrames addObject:@{
@"platform" : @"cocoa",
@"instruction_addr" : sentry_formatHexAddress(addr),
@"instruction_addr" : rnsentry_formatHexAddress(addr),
}];
}
}
Expand Down
32 changes: 32 additions & 0 deletions packages/core/ios/RNSentryHexFormatter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#import <Foundation/Foundation.h>

// 2 for the 0x prefix, plus 16 for the hex value, plus 1 for the null terminator
#define RN_SENTRY_HEX_ADDRESS_LENGTH 19

static inline NSString *
rnsentry_snprintfHexAddress(uint64_t value)
{
char buffer[RN_SENTRY_HEX_ADDRESS_LENGTH];
snprintf(buffer, RN_SENTRY_HEX_ADDRESS_LENGTH, "0x%016llx", value);
NSString *nsString = [NSString stringWithCString:buffer encoding:NSASCIIStringEncoding];
return nsString;
}

static inline NSString *
rnsentry_formatHexAddress(NSNumber *value)
{
/*
* We observed a 41% speedup by using snprintf vs +[NSString stringWithFormat:]. In a trial
* using a profile, we observed the +[NSString stringWithFormat:] using 282ms of CPU time, vs
* 164ms of CPU time for snprintf. There is also an assumed space improvement due to not needing
* to allocate as many instances of NSString, like for the format string literal, instead only
* using stack-bound C strings.
*/
return rnsentry_snprintfHexAddress([value unsignedLongLongValue]);
}

static inline NSString *
rnsentry_formatHexAddressUInt64(uint64_t value)
{
return rnsentry_snprintfHexAddress(value);
}
Loading