Skip to content

Commit

Permalink
Merge branch 'next' into tms/release-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
twometresteve committed Jul 5, 2024
2 parents 1a0c6d3 + e279fc6 commit 5056b13
Show file tree
Hide file tree
Showing 25 changed files with 170 additions and 96 deletions.
1 change: 1 addition & 0 deletions .buildkite/pipeline.full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ steps:
artifacts#v1.9.3:
download: "features/fixtures/ios/output/ipa_url_bb_release.txt"
upload: "maze_output/failed/**/*"
upload: "maze_output/failed/**/*"
docker-compose#v4.7.0:
pull: cocoa-maze-runner-bitbar
run: cocoa-maze-runner-bitbar
Expand Down
27 changes: 16 additions & 11 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,28 @@ steps:
# Build
#

- label: Static framework and Swift Package Manager builds
timeout_in_minutes: 10
agents:
queue: macos-14
env:
XCODE_VERSION: 15.3.0
commands:
- make build_xcframework
- make build_swift
- make build_ios_static
plugins:
- artifacts#v1.9.3:
upload: "build/xcframeworks/products/Bugsnag.xcframework"
compressed: xcframework.zip

- label: Build test fixtures
key: cocoa_fixture
timeout_in_minutes: 30
agents:
queue: macos-14
env:
DEVELOPER_DIR: /Applications/Xcode-15.app
XCODE_VERSION: 15.3.0
artifact_paths:
- features/fixtures/ios/output/iOSTestApp_Release.ipa
- features/fixtures/ios/output/iOSTestApp_Debug.ipa
Expand All @@ -31,16 +46,6 @@ steps:
- bundle exec upload-app --farm=bb --app=./features/fixtures/ios/output/iOSTestApp_Debug.ipa --app-id-file=./features/fixtures/ios/output/ipa_url_bb_debug.txt
- bundle exec upload-app --farm=bs --app=./features/fixtures/ios/output/iOSTestApp_Debug.ipa --app-id-file=./features/fixtures/ios/output/ipa_url_bs_debug.txt

- label: Static framework and Swift Package Manager builds
timeout_in_minutes: 10
agents:
queue: macos-14
env:
DEVELOPER_DIR: /Applications/Xcode-15.app
commands:
- make build_swift
- make build_ios_static

- label: Carthage
timeout_in_minutes: 15
agents:
Expand Down
4 changes: 2 additions & 2 deletions .jazzy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ author_url: "https://www.bugsnag.com"
author: "Bugsnag Inc"
clean: false # avoid deleting docs/.git
framework_root: "Bugsnag"
github_file_prefix: "https://github.com/bugsnag/bugsnag-cocoa/tree/v6.29.0/Bugsnag"
github_file_prefix: "https://github.com/bugsnag/bugsnag-cocoa/tree/v6.30.0/Bugsnag"
github_url: "https://github.com/bugsnag/bugsnag-cocoa"
hide_documentation_coverage: true
module: "Bugsnag"
module_version: "6.29.0"
module_version: "6.30.0"
objc: true
output: "docs"
readme: "README.md"
Expand Down
4 changes: 2 additions & 2 deletions Bugsnag.podspec.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Bugsnag",
"version": "6.29.0",
"version": "6.30.0",
"summary": "The Bugsnag crash reporting framework for Apple platforms.",
"homepage": "https://bugsnag.com",
"license": "MIT",
Expand All @@ -9,7 +9,7 @@
},
"source": {
"git": "https://github.com/bugsnag/bugsnag-cocoa.git",
"tag": "v6.29.0"
"tag": "v6.30.0"
},
"ios": {
"frameworks": [
Expand Down
14 changes: 6 additions & 8 deletions Bugsnag.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -737,10 +737,10 @@
09E312F42BF230660081F219 /* BugsnagCocoaPerformanceFromBugsnagCocoa.m in Sources */ = {isa = PBXBuildFile; fileRef = 09E312EE2BF230660081F219 /* BugsnagCocoaPerformanceFromBugsnagCocoa.m */; };
09E312F52BF230660081F219 /* BugsnagCocoaPerformanceFromBugsnagCocoa.m in Sources */ = {isa = PBXBuildFile; fileRef = 09E312EE2BF230660081F219 /* BugsnagCocoaPerformanceFromBugsnagCocoa.m */; };
09E312F62BF230660081F219 /* BugsnagCocoaPerformanceFromBugsnagCocoa.m in Sources */ = {isa = PBXBuildFile; fileRef = 09E312EE2BF230660081F219 /* BugsnagCocoaPerformanceFromBugsnagCocoa.m */; };
09E312F82BF248E70081F219 /* BugsnagCorrelation.h in Headers */ = {isa = PBXBuildFile; fileRef = 09E312F72BF248DD0081F219 /* BugsnagCorrelation.h */; settings = {ATTRIBUTES = (Public, ); }; };
09E312F92BF248E80081F219 /* BugsnagCorrelation.h in Headers */ = {isa = PBXBuildFile; fileRef = 09E312F72BF248DD0081F219 /* BugsnagCorrelation.h */; settings = {ATTRIBUTES = (Public, ); }; };
09E312FA2BF248E90081F219 /* BugsnagCorrelation.h in Headers */ = {isa = PBXBuildFile; fileRef = 09E312F72BF248DD0081F219 /* BugsnagCorrelation.h */; settings = {ATTRIBUTES = (Public, ); }; };
09E312FB2BF248E90081F219 /* BugsnagCorrelation.h in Headers */ = {isa = PBXBuildFile; fileRef = 09E312F72BF248DD0081F219 /* BugsnagCorrelation.h */; settings = {ATTRIBUTES = (Public, ); }; };
09E312F82BF248E70081F219 /* BugsnagCorrelation.h in Headers */ = {isa = PBXBuildFile; fileRef = 09E312F72BF248DD0081F219 /* BugsnagCorrelation.h */; };
09E312F92BF248E80081F219 /* BugsnagCorrelation.h in Headers */ = {isa = PBXBuildFile; fileRef = 09E312F72BF248DD0081F219 /* BugsnagCorrelation.h */; };
09E312FA2BF248E90081F219 /* BugsnagCorrelation.h in Headers */ = {isa = PBXBuildFile; fileRef = 09E312F72BF248DD0081F219 /* BugsnagCorrelation.h */; };
09E312FB2BF248E90081F219 /* BugsnagCorrelation.h in Headers */ = {isa = PBXBuildFile; fileRef = 09E312F72BF248DD0081F219 /* BugsnagCorrelation.h */; };
09E312FC2BF2492C0081F219 /* BugsnagCorrelation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 09E312F72BF248DD0081F219 /* BugsnagCorrelation.h */; };
09E312FE2BF34D6D0081F219 /* BugsnagCorrelation.m in Sources */ = {isa = PBXBuildFile; fileRef = 09E312FD2BF34D6D0081F219 /* BugsnagCorrelation.m */; };
09E312FF2BF34D6D0081F219 /* BugsnagCorrelation.m in Sources */ = {isa = PBXBuildFile; fileRef = 09E312FD2BF34D6D0081F219 /* BugsnagCorrelation.m */; };
Expand Down Expand Up @@ -1577,9 +1577,8 @@
093EB6652AFE4580006EB7E3 /* BSGTestCase.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = BSGTestCase.mm; sourceTree = "<group>"; };
09E312ED2BF230660081F219 /* BugsnagCocoaPerformanceFromBugsnagCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BugsnagCocoaPerformanceFromBugsnagCocoa.h; sourceTree = "<group>"; };
09E312EE2BF230660081F219 /* BugsnagCocoaPerformanceFromBugsnagCocoa.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BugsnagCocoaPerformanceFromBugsnagCocoa.m; sourceTree = "<group>"; };
09E312F72BF248DD0081F219 /* BugsnagCorrelation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BugsnagCorrelation.h; sourceTree = "<group>"; };
09E312F72BF248DD0081F219 /* BugsnagCorrelation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = BugsnagCorrelation.h; path = ../include/Bugsnag/BugsnagCorrelation.h; sourceTree = "<group>"; };
09E312FD2BF34D6D0081F219 /* BugsnagCorrelation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BugsnagCorrelation.m; sourceTree = "<group>"; };
09E313022BF34E5E0081F219 /* BugsnagCorrelation+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BugsnagCorrelation+Private.h"; sourceTree = "<group>"; };
09E3132E2BF3867C0081F219 /* BugsnagPerformanceBridgeTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BugsnagPerformanceBridgeTests.m; sourceTree = "<group>"; };
3A700A8024A63A8E0068CD1B /* BugsnagThread.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BugsnagThread.h; sourceTree = "<group>"; };
3A700A8124A63A8E0068CD1B /* BugsnagSession.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BugsnagSession.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2178,8 +2177,8 @@
0126DED7257A87F40031A70C /* BugsnagAppWithState+Private.h */,
0089684B2486DA9400DC48C2 /* BugsnagBreadcrumb.m */,
0126DEDF257A89490031A70C /* BugsnagBreadcrumb+Private.h */,
09E312F72BF248DD0081F219 /* BugsnagCorrelation.h */,
09E312FD2BF34D6D0081F219 /* BugsnagCorrelation.m */,
09E313022BF34E5E0081F219 /* BugsnagCorrelation+Private.h */,
008968482486DA9400DC48C2 /* BugsnagDevice.m */,
0126DEE7257A8B0F0031A70C /* BugsnagDevice+Private.h */,
0089685A2486DA9500DC48C2 /* BugsnagDeviceWithState.m */,
Expand Down Expand Up @@ -2261,7 +2260,6 @@
3A700A8524A63A8E0068CD1B /* BugsnagBreadcrumb.h */,
3A700A8924A63A8E0068CD1B /* BugsnagClient.h */,
3A700A8D24A63A8E0068CD1B /* BugsnagConfiguration.h */,
09E312F72BF248DD0081F219 /* BugsnagCorrelation.h */,
01C41A27288FD3EA00BAE31A /* BugsnagDefines.h */,
3A700A8F24A63A8E0068CD1B /* BugsnagDevice.h */,
3A700A9224A63A8E0068CD1B /* BugsnagDeviceWithState.h */,
Expand Down
20 changes: 16 additions & 4 deletions Bugsnag/Bugsnag.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#import "BugsnagClient+Private.h"
#import "BugsnagInternals.h"
#import "BugsnagLogger.h"
#import "BSGUtils.h"

static BugsnagClient *bsg_g_bugsnag_client = NULL;

Expand Down Expand Up @@ -98,27 +99,38 @@ + (void)markLaunchCompleted {
}
}

// Here, we pass all public notify APIs to a common handling method
// (notifyErrorOrException) and then prevent the compiler from performing
// any inlining or outlining that would change the number of Bugsnag handler
// methods on the stack and break our stack stripping.
// Note: Each BSGPreventInlining call site within a module MUST pass a different
// string to prevent outlining!

+ (void)notify:(NSException *)exception {
if ([self bugsnagReadyForInternalCalls]) {
[self.client notify:exception];
BSGPreventInlining(@"Prevent");
[self.client notifyErrorOrException:exception stackStripDepth:2 block:nil];
}
}

+ (void)notify:(NSException *)exception block:(BugsnagOnErrorBlock)block {
if ([self bugsnagReadyForInternalCalls]) {
[self.client notify:exception block:block];
BSGPreventInlining(@"inlining");
[self.client notifyErrorOrException:exception stackStripDepth:2 block:block];
}
}

+ (void)notifyError:(NSError *)error {
if ([self bugsnagReadyForInternalCalls]) {
[self.client notifyError:error];
BSGPreventInlining(@"and");
[self.client notifyErrorOrException:error stackStripDepth:2 block:nil];
}
}

+ (void)notifyError:(NSError *)error block:(BugsnagOnErrorBlock)block {
if ([self bugsnagReadyForInternalCalls]) {
[self.client notifyError:error block:block];
BSGPreventInlining(@"outlining");
[self.client notifyErrorOrException:error stackStripDepth:2 block:block];
}
}

Expand Down
20 changes: 20 additions & 0 deletions Bugsnag/Client/BugsnagClient+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,26 @@ BSG_OBJC_DIRECT_MEMBERS

- (void)start;

/**
* Common entry point to notify an error or an exception.
* Bugsnag components MUST NOT call the regular notify methods in this class. ALWAYS call
* this method instead.
*
* You must provide the number of stack trace entries to strip from the top of the stack
* (INCLUDING this method) so that our own reporting methods don't show up in the reported stack trace.
*
* Example: stackStripDepth = 2 would strip the top two entries, which we would expect to be
* 1. +[Bugsnag notifyError:block:]
* 2. -[BugsnagClient notifyErrorOrException:stackStripDepth:block:]
*
* @param errorOrException the error or exception to report.
* @param stackStripDepth The number of stack trace entries to strip from the top of the stack.
* @param block Called after reporting.
*/
- (void)notifyErrorOrException:(id)errorOrException
stackStripDepth:(NSUInteger)stackStripDepth
block:(_Nullable BugsnagOnErrorBlock)block;

@end

NS_ASSUME_NONNULL_END
52 changes: 18 additions & 34 deletions Bugsnag/Client/BugsnagClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
#import "BugsnagBreadcrumbs.h"
#import "BugsnagCollections.h"
#import "BugsnagConfiguration+Private.h"
#import "BugsnagCorrelation+Private.h"
#import "BugsnagDeviceWithState+Private.h"
#import "BugsnagError+Private.h"
#import "BugsnagErrorTypes.h"
Expand Down Expand Up @@ -641,37 +640,35 @@ - (NSString *)context {

// MARK: - Notify

// Prevent the compiler from inlining or optimizing, which would reduce
// the number of bugsnag-only stack entries and mess up our pruning.
// We have to do it this way because you can't mark Objective-C methods noinline or optnone.
// We leave it externable to further dissuade the optimizer.
__attribute__((optnone))
void bsg_notifyErrorOrException(BugsnagClient *self, id errorOrException, BugsnagOnErrorBlock block) {
[self notifyErrorOrException:errorOrException block:block];
}

// note - some duplication between notifyError calls is required to ensure
// the same number of stackframes are used for each call.
// see notify:handledState:block for further info
// Here, we pass all public notify APIs to a common handling method
// (notifyErrorOrException) and then prevent the compiler from performing
// any inlining or outlining that would change the number of Bugsnag handler
// methods on the stack and break our stack stripping.
// Note: Each BSGPreventInlining call site within a module MUST pass a different
// string to prevent outlining!

- (void)notifyError:(NSError *)error {
bsg_log_debug(@"%s %@", __PRETTY_FUNCTION__, error);
bsg_notifyErrorOrException(self, error, nil);
BSGPreventInlining(@"Prevent");
[self notifyErrorOrException:error stackStripDepth:2 block:nil];
}

- (void)notifyError:(NSError *)error block:(BugsnagOnErrorBlock)block {
bsg_log_debug(@"%s %@", __PRETTY_FUNCTION__, error);
bsg_notifyErrorOrException(self, error, block);
BSGPreventInlining(@"inlining");
[self notifyErrorOrException:error stackStripDepth:2 block:block];
}

- (void)notify:(NSException *)exception {
bsg_log_debug(@"%s %@", __PRETTY_FUNCTION__, exception);
bsg_notifyErrorOrException(self, exception, nil);
BSGPreventInlining(@"and");
[self notifyErrorOrException:exception stackStripDepth:2 block:nil];
}

- (void)notify:(NSException *)exception block:(BugsnagOnErrorBlock)block {
bsg_log_debug(@"%s %@", __PRETTY_FUNCTION__, exception);
bsg_notifyErrorOrException(self, exception, block);
BSGPreventInlining(@"outlining");
[self notifyErrorOrException:exception stackStripDepth:2 block:block];
}

// MARK: - Notify (Internal)
Expand All @@ -686,7 +683,9 @@ - (BugsnagCorrelation *)getCurrentCorrelation {
return [[BugsnagCorrelation alloc] initWithTraceId:traceId spanId:spanId];
}

- (void)notifyErrorOrException:(id)errorOrException block:(BugsnagOnErrorBlock)block {
- (void)notifyErrorOrException:(id)errorOrException
stackStripDepth:(NSUInteger)stackStripDepth
block:(_Nullable BugsnagOnErrorBlock)block {
BugsnagCorrelation *correlation = [self getCurrentCorrelation];
NSDictionary *systemInfo = [BSG_KSSystemInfo systemInfo];
BugsnagMetadata *metadata = [self.metadata copy];
Expand Down Expand Up @@ -730,25 +729,10 @@ - (void)notifyErrorOrException:(id)errorOrException block:(BugsnagOnErrorBlock)b
return;
}

/**
* Stack frames starting from this one are removed by setting the depth.
* This helps remove bugsnag frames from showing in NSErrors as their
* trace is synthesized.
*
* For example, for [Bugsnag notifyError:block:], bugsnag adds the following
* frames which must be removed:
*
* 1. +[Bugsnag notifyError:block:]
* 2. -[BugsnagClient notifyError:block:]
* 3. bsg_notifyErrorOrException()
* 4. -[BugsnagClient notifyErrorOrException:block:]
*/
NSUInteger depth = 4;

if (!callStack.count) {
// If the NSException was not raised by the Objective-C runtime, it will be missing a call stack.
// Use the current call stack instead.
callStack = BSGArraySubarrayFromIndex(NSThread.callStackReturnAddresses, depth);
callStack = BSGArraySubarrayFromIndex(NSThread.callStackReturnAddresses, stackStripDepth);
}

#if BSG_HAVE_MACH_THREADS
Expand Down
2 changes: 2 additions & 0 deletions Bugsnag/Helpers/BSGUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ static inline NSString * _Nullable BSGStringFromClass(Class _Nullable cls) {
*/
void bsg_safe_strncpy(char *dst, const char *src, size_t length);

NSString * _Nullable BSGPreventInlining(NSString * _Nullable someValue);

NS_ASSUME_NONNULL_END

__END_DECLS
7 changes: 7 additions & 0 deletions Bugsnag/Helpers/BSGUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,10 @@ dispatch_queue_t BSGGetFileSystemQueue(void) {
}
return nil;
}

NSString * _Nullable BSGPreventInlining(NSString * _Nullable someValue) {
static NSString *lastValue = nil;
NSString *returnValue = lastValue;
lastValue = someValue;
return returnValue;
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
//
// BugsnagCorrelation+Private.h
// BugsnagCorrelation.h
// Bugsnag
//
// Created by Karl Stenerud on 14.05.24.
// Created by Karl Stenerud on 13.05.24.
// Copyright © 2024 Bugsnag Inc. All rights reserved.
//

#import "BugsnagCorrelation.h"

#ifndef BugsnagCorrelation_Private_h
#define BugsnagCorrelation_Private_h
#import <Foundation/Foundation.h>
#import <Bugsnag/BugsnagDefines.h>

NS_ASSUME_NONNULL_BEGIN

@interface BugsnagCorrelation ()
BUGSNAG_EXTERN
@interface BugsnagCorrelation: NSObject

@property (readonly, nonatomic, strong, nullable) NSString *traceId;

@property (readonly, nonatomic, strong, nullable) NSString *spanId;

- (instancetype) initWithTraceId:(NSString * _Nullable) traceId spanId:(NSString * _Nullable)spanId;

Expand All @@ -24,5 +27,3 @@ NS_ASSUME_NONNULL_BEGIN
@end

NS_ASSUME_NONNULL_END

#endif /* BugsnagCorrelation_Private_h */
10 changes: 5 additions & 5 deletions Bugsnag/Payload/BugsnagCorrelation.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2024 Bugsnag Inc. All rights reserved.
//

#import "BugsnagCorrelation+Private.h"
#import "BugsnagCorrelation.h"

@implementation BugsnagCorrelation

Expand All @@ -25,12 +25,12 @@ - (instancetype) initWithJsonDictionary:(NSDictionary<NSString *, NSObject *> *)

if ((self = [super init])) {
id nsnull = NSNull.null;
_traceId = (NSString *)dict[@"traceid"];
_traceId = (NSString *)dict[@"traceId"];
if (_traceId == nsnull) {
_traceId = nil;
}

_spanId = (NSString *)dict[@"spanid"];
_spanId = (NSString *)dict[@"spanId"];
if (_spanId == nsnull) {
_spanId = nil;
}
Expand All @@ -41,8 +41,8 @@ - (instancetype) initWithJsonDictionary:(NSDictionary<NSString *, NSObject *> *)

- (NSDictionary<NSString *, NSObject *> *) toJsonDictionary {
NSMutableDictionary *dict = [NSMutableDictionary new];
dict[@"traceid"] = self.traceId;
dict[@"spanid"] = self.spanId;
dict[@"traceId"] = self.traceId;
dict[@"spanId"] = self.spanId;
return dict;
}

Expand Down
Loading

0 comments on commit 5056b13

Please sign in to comment.