Skip to content

Commit b6158d3

Browse files
committed
Locally vendored helpers
1 parent a736b76 commit b6158d3

3 files changed

Lines changed: 46 additions & 7 deletions

File tree

packages/core/RNSentry.podspec

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ Pod::Spec.new do |s|
4747
s.compiler_flags = other_cflags
4848

4949
s.pod_target_xcconfig = {
50-
'DEFINES_MODULE' => 'YES',
51-
'HEADER_SEARCH_PATHS' => '$(inherited) "${PODS_ROOT}/Sentry/Sources/Sentry" "${PODS_ROOT}/Sentry/Sources/Sentry/include"'
50+
'DEFINES_MODULE' => 'YES'
5251
}
5352

5453
s.dependency 'Sentry', '9.12.1'

packages/core/ios/RNSentry+fetchNativeStack.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#import "RNSentry.h"
22
#import "RNSentryBreadcrumb.h"
3+
#import "RNSentryHexFormatter.h"
34
#import "RNSentryId.h"
4-
#import "SentryFormatter.h"
55
#import <Sentry/PrivateSentrySDKOnly.h>
66
@import Sentry;
77

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

3131
NSDictionary<NSString *, id> *_Nonnull nativeFrame = @{
3232
@"platform" : @"cocoa",
33-
@"instruction_addr" : sentry_formatHexAddress(addr),
33+
@"instruction_addr" : rnsentry_formatHexAddress(addr),
3434
@"package" : [image name],
3535
@"image_addr" : imageAddr,
3636
@"in_app" : [NSNumber numberWithBool:[appPackageName isEqualToString:[image name]]],
@@ -45,7 +45,7 @@ - (NSDictionary *)fetchNativeStackFramesBy:(NSArray<NSNumber *> *)instructionsAd
4545
NSMutableDictionary<NSString *, id> *_Nonnull symbolicated
4646
= nativeFrame.mutableCopy;
4747
symbolicated[@"symbol_addr"]
48-
= sentry_formatHexAddressUInt64((uintptr_t)symbolsBuffer.dli_saddr);
48+
= rnsentry_formatHexAddressUInt64((uintptr_t)symbolsBuffer.dli_saddr);
4949
symbolicated[@"function"] = [NSString stringWithCString:symbolsBuffer.dli_sname
5050
encoding:NSUTF8StringEncoding];
5151

@@ -57,7 +57,7 @@ - (NSDictionary *)fetchNativeStackFramesBy:(NSArray<NSNumber *> *)instructionsAd
5757
} else {
5858
[serializedFrames addObject:@{
5959
@"platform" : @"cocoa",
60-
@"instruction_addr" : sentry_formatHexAddress(addr),
60+
@"instruction_addr" : rnsentry_formatHexAddress(addr),
6161
}];
6262
}
6363
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#import <Foundation/Foundation.h>
2+
3+
// 2 for the "0x" prefix, plus 16 for the hex value, plus 1 for the null terminator.
4+
#define RN_SENTRY_HEX_ADDRESS_LENGTH 19
5+
6+
/**
7+
* Formats a 64-bit unsigned integer as a zero-padded hex address string
8+
* (e.g. @c 0x000000010f1a2b3c).
9+
*
10+
* Inlined here so we don't need to reach into sentry-cocoa's private
11+
* @c SentryFormatter.h via @c HEADER_SEARCH_PATHS. Keep behavior identical
12+
* to @c sentry_snprintfHexAddress in sentry-cocoa.
13+
*/
14+
static inline NSString *
15+
rnsentry_snprintfHexAddress(uint64_t value)
16+
{
17+
char buffer[RN_SENTRY_HEX_ADDRESS_LENGTH];
18+
snprintf(buffer, RN_SENTRY_HEX_ADDRESS_LENGTH, "0x%016llx", value);
19+
return [NSString stringWithCString:buffer encoding:NSASCIIStringEncoding];
20+
}
21+
22+
/**
23+
* Formats an @c NSNumber address as a zero-padded hex string.
24+
* Drop-in replacement for sentry-cocoa's @c sentry_formatHexAddress.
25+
*/
26+
static inline NSString *
27+
rnsentry_formatHexAddress(NSNumber *value)
28+
{
29+
return rnsentry_snprintfHexAddress([value unsignedLongLongValue]);
30+
}
31+
32+
/**
33+
* Formats a @c uint64_t address as a zero-padded hex string.
34+
* Drop-in replacement for sentry-cocoa's @c sentry_formatHexAddressUInt64.
35+
*/
36+
static inline NSString *
37+
rnsentry_formatHexAddressUInt64(uint64_t value)
38+
{
39+
return rnsentry_snprintfHexAddress(value);
40+
}

0 commit comments

Comments
 (0)