-
-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
596ccc1
commit ee3f02e
Showing
14 changed files
with
251 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#import "SentryProfilingConditionals.h" | ||
#import <Foundation/Foundation.h> | ||
|
||
#if SENTRY_TARGET_PROFILING_SUPPORTED | ||
|
||
# import "SentryBacktrace.hpp" | ||
|
||
using namespace sentry::profiling; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
Backtrace mockBacktrace(thread::TIDType threadID, const int threadPriority, | ||
const char *_Nullable threadName, std::uint64_t queueAddress, std::string queueLabel, | ||
std::vector<std::uintptr_t> addresses); | ||
|
||
NS_ASSUME_NONNULL_END | ||
|
||
#endif // SENTRY_TARGET_PROFILING_SUPPORTED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#import "SentryProfilerMocks.h" | ||
|
||
#if SENTRY_TARGET_PROFILING_SUPPORTED | ||
|
||
Backtrace | ||
mockBacktrace(thread::TIDType threadID, const int threadPriority, const char *threadName, | ||
std::uint64_t queueAddress, std::string queueLabel, std::vector<std::uintptr_t> addresses) | ||
{ | ||
ThreadMetadata threadMetadata; | ||
if (threadName != nullptr) { | ||
threadMetadata.name = threadName; | ||
} | ||
threadMetadata.threadID = threadID; | ||
threadMetadata.priority = threadPriority; | ||
|
||
QueueMetadata queueMetadata; | ||
queueMetadata.address = queueAddress; | ||
queueMetadata.label = std::make_shared<std::string>(queueLabel); | ||
|
||
Backtrace backtrace; | ||
backtrace.threadMetadata = threadMetadata; | ||
backtrace.queueMetadata = queueMetadata; | ||
backtrace.addresses = std::vector<std::uintptr_t>(addresses); | ||
|
||
return backtrace; | ||
} | ||
|
||
#endif // SENTRY_TARGET_PROFILING_SUPPORTED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#import "SentryProfilingConditionals.h" | ||
#import <Foundation/Foundation.h> | ||
|
||
#if SENTRY_TARGET_PROFILING_SUPPORTED | ||
|
||
@class SentryProfilerState; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/** | ||
* This delivers a wrapper around the C++ function to create a mock backtrace for incorporation into | ||
* profiler state that can be called from Swift tests. | ||
*/ | ||
@interface SentryProfilerMocksSwiftCompatible : NSObject | ||
|
||
+ (void)appendMockBacktraceToState:(SentryProfilerState *)state | ||
threadID:(uint64_t)threadID | ||
threadPriority:(const int)threadPriority | ||
threadName:(nullable NSString *)threadName | ||
queueAddress:(uint64_t)queueAddress | ||
queueLabel:(NSString *)queueLabel | ||
addresses:(NSArray<NSNumber *> *)addresses; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END | ||
|
||
#endif // SENTRY_TARGET_PROFILING_SUPPORTED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#import "SentryProfilerMocksSwiftCompatible.h" | ||
|
||
#if SENTRY_TARGET_PROFILING_SUPPORTED | ||
|
||
# import "SentryCurrentDate.h" | ||
# import "SentryProfilerMocks.h" | ||
# import "SentryProfilerState+ObjCpp.h" | ||
# include <vector> | ||
|
||
using namespace std; | ||
|
||
@implementation SentryProfilerMocksSwiftCompatible | ||
|
||
+ (void)appendMockBacktraceToState:(SentryProfilerState *)state | ||
threadID:(uint64_t)threadID | ||
threadPriority:(const int)threadPriority | ||
threadName:(nullable NSString *)threadName | ||
queueAddress:(uint64_t)queueAddress | ||
queueLabel:(NSString *)queueLabel | ||
addresses:(NSArray<NSNumber *> *)addresses | ||
{ | ||
auto backtraceAddresses = std::vector<std::uintptr_t>(); | ||
|
||
for (NSNumber *address in addresses) { | ||
backtraceAddresses.push_back(address.unsignedLongLongValue); | ||
} | ||
|
||
auto backtrace = mockBacktrace(threadID, threadPriority, | ||
[threadName cStringUsingEncoding:NSUTF8StringEncoding], queueAddress, | ||
[queueLabel cStringUsingEncoding:NSUTF8StringEncoding], backtraceAddresses); | ||
backtrace.absoluteTimestamp = SentryCurrentDate.getCurrentDateProvider.systemTime; | ||
[state appendBacktrace:backtrace]; | ||
} | ||
|
||
@end | ||
|
||
#endif // SENTRY_TARGET_PROFILING_SUPPORTED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#import "SentryProfilingConditionals.h" | ||
|
||
#if SENTRY_TARGET_PROFILING_SUPPORTED | ||
|
||
# import "SentryBacktrace.hpp" | ||
# import "SentryProfilerState.h" | ||
|
||
/* | ||
* This extension defines C++ interface on SentryProfilerState that is not able to be imported into | ||
* a bridging header via SentryProfilerState.h due to C++/Swift interop limitations. | ||
*/ | ||
|
||
@interface | ||
SentryProfilerState () | ||
|
||
- (void)appendBacktrace:(const sentry::profiling::Backtrace &)backtrace; | ||
|
||
@end | ||
|
||
#endif // SENTRY_TARGET_PROFILING_SUPPORTED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.