Skip to content

Commit

Permalink
Enable swap __cxa_throw by default (#546)
Browse files Browse the repository at this point in the history
* Enable swap __cxa_throw by default

* Update tests
  • Loading branch information
bamx23 authored Aug 26, 2024
1 parent 9b9f2c2 commit 00a2875
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
4 changes: 1 addition & 3 deletions Samples/Tests/IntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ final class MachTests: IntegrationTestBase {

final class CppTests: IntegrationTestBase {
func testRuntimeException() throws {
try launchAndCrash(.cpp_runtimeException) {
$0.isCxaThrowEnabled = true
}
try launchAndCrash(.cpp_runtimeException)

let rawReport = try readPartialCrashReport()
try rawReport.validate()
Expand Down
4 changes: 2 additions & 2 deletions Sources/KSCrashRecording/include/KSCrashCConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ typedef struct {
* accurate stack traces even in dynamically linked libraries and allows overriding
* the original `__cxa_throw` with a custom implementation.
*
* **Default**: false
* **Default**: true
*/
bool enableSwapCxaThrow;
} KSCrashCConfiguration;
Expand All @@ -174,7 +174,7 @@ static inline KSCrashCConfiguration KSCrashCConfiguration_Default(void)
.addConsoleLogToReport = false,
.printPreviousLogOnStartup = false,
.maxReportCount = 5,
.enableSwapCxaThrow = false };
.enableSwapCxaThrow = true };
}

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion Sources/KSCrashRecording/include/KSCrashConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ typedef NS_ENUM(NSUInteger, KSCDeleteBehavior) {
* accurate stack traces even in dynamically linked libraries and allows overriding
* the original `__cxa_throw` with a custom implementation.
*
* **Default**: false
* **Default**: true
*/
@property(nonatomic, assign) BOOL enableSwapCxaThrow;

Expand Down
10 changes: 5 additions & 5 deletions Tests/KSCrashRecordingTests/KSCrashConfiguration_Tests.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ - (void)testInitializationDefaults
XCTAssertFalse(config.addConsoleLogToReport);
XCTAssertFalse(config.printPreviousLogOnStartup);
XCTAssertEqual(config.maxReportCount, 5);
XCTAssertFalse(config.enableSwapCxaThrow);
XCTAssertTrue(config.enableSwapCxaThrow);
XCTAssertEqual(config.deleteBehaviorAfterSendAll, KSCDeleteAlways);
}

Expand All @@ -64,7 +64,7 @@ - (void)testToCConfiguration
config.addConsoleLogToReport = YES;
config.printPreviousLogOnStartup = YES;
config.maxReportCount = 10;
config.enableSwapCxaThrow = YES;
config.enableSwapCxaThrow = NO;

KSCrashCConfiguration cConfig = [config toCConfiguration];

Expand All @@ -80,7 +80,7 @@ - (void)testToCConfiguration
XCTAssertTrue(cConfig.addConsoleLogToReport);
XCTAssertTrue(cConfig.printPreviousLogOnStartup);
XCTAssertEqual(cConfig.maxReportCount, 10);
XCTAssertTrue(cConfig.enableSwapCxaThrow);
XCTAssertFalse(cConfig.enableSwapCxaThrow);

// Free memory allocated for C string array
for (int i = 0; i < cConfig.doNotIntrospectClasses.length; i++) {
Expand All @@ -102,7 +102,7 @@ - (void)testCopyWithZone
config.addConsoleLogToReport = YES;
config.printPreviousLogOnStartup = YES;
config.maxReportCount = 10;
config.enableSwapCxaThrow = YES;
config.enableSwapCxaThrow = NO;

KSCrashConfiguration *copy = [config copy];

Expand All @@ -115,7 +115,7 @@ - (void)testCopyWithZone
XCTAssertTrue(copy.addConsoleLogToReport);
XCTAssertTrue(copy.printPreviousLogOnStartup);
XCTAssertEqual(copy.maxReportCount, 10);
XCTAssertTrue(copy.enableSwapCxaThrow);
XCTAssertFalse(copy.enableSwapCxaThrow);
XCTAssertEqual(copy.deleteBehaviorAfterSendAll, KSCDeleteAlways);
}

Expand Down

0 comments on commit 00a2875

Please sign in to comment.