From 48d544c3d59016d81a8c848bcb611475c9a8aa2a Mon Sep 17 00:00:00 2001 From: Dave MacLachlan Date: Sun, 6 Nov 2022 09:27:33 -0800 Subject: [PATCH] Check in initial source code. --- crashdump.xcodeproj/project.pbxproj | 296 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + crashdump/main.m | 48 +++ 4 files changed, 359 insertions(+) create mode 100644 crashdump.xcodeproj/project.pbxproj create mode 100644 crashdump.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 crashdump.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 crashdump/main.m diff --git a/crashdump.xcodeproj/project.pbxproj b/crashdump.xcodeproj/project.pbxproj new file mode 100644 index 0000000..d0b9451 --- /dev/null +++ b/crashdump.xcodeproj/project.pbxproj @@ -0,0 +1,296 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 8B167F0229181988004C7C12 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B167F0129181988004C7C12 /* main.m */; }; + 8B167F0B2918220E004C7C12 /* OSAnalytics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8B167F0A2918220E004C7C12 /* OSAnalytics.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 8B167EFC29181988004C7C12 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 8B167EFE29181988004C7C12 /* crashdump */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = crashdump; sourceTree = BUILT_PRODUCTS_DIR; }; + 8B167F0129181988004C7C12 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 8B167F0A2918220E004C7C12 /* OSAnalytics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OSAnalytics.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/PrivateFrameworks/OSAnalytics.framework; sourceTree = DEVELOPER_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8B167EFB29181988004C7C12 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 8B167F0B2918220E004C7C12 /* OSAnalytics.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 8B167EF529181988004C7C12 = { + isa = PBXGroup; + children = ( + 8B167F0029181988004C7C12 /* crashdump */, + 8B167EFF29181988004C7C12 /* Products */, + 8B167F092918220E004C7C12 /* Frameworks */, + ); + sourceTree = ""; + }; + 8B167EFF29181988004C7C12 /* Products */ = { + isa = PBXGroup; + children = ( + 8B167EFE29181988004C7C12 /* crashdump */, + ); + name = Products; + sourceTree = ""; + }; + 8B167F0029181988004C7C12 /* crashdump */ = { + isa = PBXGroup; + children = ( + 8B167F0129181988004C7C12 /* main.m */, + ); + path = crashdump; + sourceTree = ""; + }; + 8B167F092918220E004C7C12 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 8B167F0A2918220E004C7C12 /* OSAnalytics.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 8B167EFD29181988004C7C12 /* crashdump */ = { + isa = PBXNativeTarget; + buildConfigurationList = 8B167F0529181988004C7C12 /* Build configuration list for PBXNativeTarget "crashdump" */; + buildPhases = ( + 8B167EFA29181988004C7C12 /* Sources */, + 8B167EFB29181988004C7C12 /* Frameworks */, + 8B167EFC29181988004C7C12 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = crashdump; + productName = crashdump; + productReference = 8B167EFE29181988004C7C12 /* crashdump */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 8B167EF629181988004C7C12 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastUpgradeCheck = 1400; + TargetAttributes = { + 8B167EFD29181988004C7C12 = { + CreatedOnToolsVersion = 14.0; + }; + }; + }; + buildConfigurationList = 8B167EF929181988004C7C12 /* Build configuration list for PBXProject "crashdump" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 8B167EF529181988004C7C12; + productRefGroup = 8B167EFF29181988004C7C12 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 8B167EFD29181988004C7C12 /* crashdump */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 8B167EFA29181988004C7C12 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8B167F0229181988004C7C12 /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 8B167F0329181988004C7C12 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 12.3; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 8B167F0429181988004C7C12 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 12.3; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + }; + name = Release; + }; + 8B167F0629181988004C7C12 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 9SY52WKP32; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SYSTEM_FRAMEWORK_SEARCH_PATHS = $DEVELOPER_SDK_DIR/MacOSX.sdk/System/Library/PrivateFrameworks/; + }; + name = Debug; + }; + 8B167F0729181988004C7C12 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 9SY52WKP32; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SYSTEM_FRAMEWORK_SEARCH_PATHS = $DEVELOPER_SDK_DIR/MacOSX.sdk/System/Library/PrivateFrameworks/; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 8B167EF929181988004C7C12 /* Build configuration list for PBXProject "crashdump" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8B167F0329181988004C7C12 /* Debug */, + 8B167F0429181988004C7C12 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 8B167F0529181988004C7C12 /* Build configuration list for PBXNativeTarget "crashdump" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8B167F0629181988004C7C12 /* Debug */, + 8B167F0729181988004C7C12 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 8B167EF629181988004C7C12 /* Project object */; +} diff --git a/crashdump.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/crashdump.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/crashdump.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/crashdump.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/crashdump.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/crashdump.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/crashdump/main.m b/crashdump/main.m new file mode 100644 index 0000000..ed5bd0b --- /dev/null +++ b/crashdump/main.m @@ -0,0 +1,48 @@ +// +// main.m +// crashdump +// +// Created by Dave MacLachlan on 11/6/22. +// + +#import + +// Private API for turning crash reports into dictionaries. +// This is valid for at least MacOS 12 and 13. +// This was extracted from: +// /System/Library/PrivateFrameworks/OSAnalytics.framework/Versions/A/OSAnalytics +@interface OSALegacyXform : NSObject +// Takes in a crash report file pointed to by url and returns a dictionary with either +// OSATransformResultReport or OSATransformResultError keys. ++ (NSDictionary *)transformURL:(NSURL *)url options:(id)options; +@end + +// These are the keys for the dictionary created by OSALegacyXform. +extern NSString *OSATransformResultError; +extern NSString *OSATransformResultReport; + +int main(int argc, const char * argv[]) { + @autoreleasepool { + if (argc != 2) { + printf("crashdump \n"); + return 1; + } + NSString *path = [NSString stringWithUTF8String:argv[1]]; + NSURL *url = [NSURL fileURLWithPath:path]; + NSDictionary *output = [OSALegacyXform transformURL:url options:nil]; + NSString *report = output[OSATransformResultReport]; + if (report) { + printf("%s", report.UTF8String); + return 0; + } + // uh-oh error occurred converting crash. + // Try to output something with gcc error syntax if we are using this in a script. + NSError *outputError = output[OSATransformResultError]; + if (outputError) { + printf("%s: error: %s\n", argv[1], outputError.localizedDescription.UTF8String); + } else { + printf("%s: error: Unable to parse file\n", argv[1]); + } + } + return 1; +}