mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-01 04:08:07 +00:00
Define our own crash callback struct, so we don't need the PLCrashReporter headers to be public any longer
This commit is contained in:
parent
1f96aaab5e
commit
e66714afca
@ -32,14 +32,6 @@
|
|||||||
|
|
||||||
#import "BITHockeyBaseManager.h"
|
#import "BITHockeyBaseManager.h"
|
||||||
|
|
||||||
// We need this check depending on integrating as a subproject or using the binary distribution
|
|
||||||
#if __has_include("CrashReporter.h")
|
|
||||||
#import "CrashReporter.h"
|
|
||||||
#else
|
|
||||||
#import <CrashReporter/CrashReporter.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Crash Manager status
|
* Crash Manager status
|
||||||
*/
|
*/
|
||||||
@ -59,6 +51,35 @@ typedef NS_ENUM(NSUInteger, BITCrashManagerStatus) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prototype of a callback function used to execute additional user code. Called upon completion of crash
|
||||||
|
* handling, after the crash report has been written to disk.
|
||||||
|
*
|
||||||
|
* @param context The API client's supplied context value.
|
||||||
|
*
|
||||||
|
* @see `BITCrashManagerCallbacks`
|
||||||
|
* @see `[BITCrashManager setCrashCallbacks:]`
|
||||||
|
*/
|
||||||
|
typedef void (*BITCrashManagerPostCrashSignalCallback)(void *context);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This structure contains callbacks supported by `BITCrashManager` to allow the host application to perform
|
||||||
|
* additional tasks prior to program termination after a crash has occured.
|
||||||
|
*
|
||||||
|
* @see `BITCrashManagerPostCrashSignalCallback`
|
||||||
|
* @see `[BITCrashManager setCrashCallbacks:]`
|
||||||
|
*/
|
||||||
|
typedef struct BITCrashManagerCallbacks {
|
||||||
|
/** An arbitrary user-supplied context value. This value may be NULL. */
|
||||||
|
void *context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The callback used to report caught signal information.
|
||||||
|
*/
|
||||||
|
BITCrashManagerPostCrashSignalCallback handleSignal;
|
||||||
|
} BITCrashManagerCallbacks;
|
||||||
|
|
||||||
|
|
||||||
@protocol BITCrashManagerDelegate;
|
@protocol BITCrashManagerDelegate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -234,15 +255,18 @@ typedef NS_ENUM(NSUInteger, BITCrashManagerStatus) {
|
|||||||
*
|
*
|
||||||
* _Async-Safe Functions_
|
* _Async-Safe Functions_
|
||||||
*
|
*
|
||||||
* A subset of functions are defined to be async-safe by the OS, and are safely callable from within a signal handler. If you do implement a custom post-crash handler, it must be async-safe. A table of POSIX-defined async-safe functions and additional information is available from the CERT programming guide - SIG30-C, see https://www.securecoding.cert.org/confluence/display/seccode/SIG30-C.+Call+only+asynchronous-safe+functions+within+signal+handlers
|
* A subset of functions are defined to be async-safe by the OS, and are safely callable from within a signal handler. If you do implement a custom post-crash handler, it must be async-safe. A table of POSIX-defined async-safe functions and additional information is available from the [CERT programming guide - SIG30-C](https://www.securecoding.cert.org/confluence/display/seccode/SIG30-C.+Call+only+asynchronous-safe+functions+within+signal+handlers).
|
||||||
*
|
*
|
||||||
* Most notably, the Objective-C runtime itself is not async-safe, and Objective-C may not be used within a signal handler.
|
* Most notably, the Objective-C runtime itself is not async-safe, and Objective-C may not be used within a signal handler.
|
||||||
*
|
*
|
||||||
* Documentation taken from PLCrashReporter: https://www.plcrashreporter.org/documentation/api/v1.2-rc2/async_safety.html
|
* Documentation taken from PLCrashReporter: https://www.plcrashreporter.org/documentation/api/v1.2-rc2/async_safety.html
|
||||||
*
|
*
|
||||||
|
* @see `BITCrashManagerPostCrashSignalCallback`
|
||||||
|
* @see `BITCrashManagerCallbacks`
|
||||||
|
*
|
||||||
* @param callbacks A pointer to an initialized PLCrashReporterCallback structure, see https://www.plcrashreporter.org/documentation/api/v1.2-rc2/struct_p_l_crash_reporter_callbacks.html
|
* @param callbacks A pointer to an initialized PLCrashReporterCallback structure, see https://www.plcrashreporter.org/documentation/api/v1.2-rc2/struct_p_l_crash_reporter_callbacks.html
|
||||||
*/
|
*/
|
||||||
- (void)setCrashCallbacks: (PLCrashReporterCallbacks *) callbacks;
|
- (void)setCrashCallbacks: (BITCrashManagerCallbacks *) callbacks;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -32,6 +32,8 @@
|
|||||||
|
|
||||||
#if HOCKEYSDK_FEATURE_CRASH_REPORTER
|
#if HOCKEYSDK_FEATURE_CRASH_REPORTER
|
||||||
|
|
||||||
|
#import <CrashReporter/CrashReporter.h>
|
||||||
|
|
||||||
#import <SystemConfiguration/SystemConfiguration.h>
|
#import <SystemConfiguration/SystemConfiguration.h>
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
@ -69,6 +71,25 @@ NSString *const kBITFakeCrashDeviceModel = @"BITFakeCrashDeviceModel";
|
|||||||
NSString *const kBITFakeCrashAppBinaryUUID = @"BITFakeCrashAppBinaryUUID";
|
NSString *const kBITFakeCrashAppBinaryUUID = @"BITFakeCrashAppBinaryUUID";
|
||||||
NSString *const kBITFakeCrashReport = @"BITFakeCrashAppString";
|
NSString *const kBITFakeCrashReport = @"BITFakeCrashAppString";
|
||||||
|
|
||||||
|
|
||||||
|
static BITCrashManagerCallbacks bitCrashCallbacks = {
|
||||||
|
.context = NULL,
|
||||||
|
.handleSignal = NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
// proxy implementation for PLCrashReporter to keep our interface stable while this can change
|
||||||
|
static void plcr_post_crash_callback (siginfo_t *info, ucontext_t *uap, void *context) {
|
||||||
|
if (bitCrashCallbacks.handleSignal != NULL)
|
||||||
|
bitCrashCallbacks.handleSignal(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
static PLCrashReporterCallbacks plCrashCallbacks = {
|
||||||
|
.version = 0,
|
||||||
|
.context = NULL,
|
||||||
|
.handleSignal = plcr_post_crash_callback
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
@interface BITCrashManager ()
|
@interface BITCrashManager ()
|
||||||
|
|
||||||
@property (nonatomic, strong) NSFileManager *fileManager;
|
@property (nonatomic, strong) NSFileManager *fileManager;
|
||||||
@ -498,8 +519,22 @@ NSString *const kBITFakeCrashReport = @"BITFakeCrashAppString";
|
|||||||
#pragma mark - Public
|
#pragma mark - Public
|
||||||
|
|
||||||
|
|
||||||
- (void)setCrashCallbacks: (PLCrashReporterCallbacks *) callbacks {
|
/**
|
||||||
_crashCallBacks = callbacks;
|
* Set the callback for PLCrashReporter
|
||||||
|
*
|
||||||
|
* @param callbacks BITCrashManagerCallbacks instance
|
||||||
|
*/
|
||||||
|
- (void)setCrashCallbacks: (BITCrashManagerCallbacks *) callbacks {
|
||||||
|
if (!callbacks) return;
|
||||||
|
|
||||||
|
// set our proxy callback struct
|
||||||
|
bitCrashCallbacks.context = callbacks->context;
|
||||||
|
bitCrashCallbacks.handleSignal = callbacks->handleSignal;
|
||||||
|
|
||||||
|
// set the PLCrashReporterCallbacks struct
|
||||||
|
plCrashCallbacks.context = callbacks->context;
|
||||||
|
|
||||||
|
_crashCallBacks = &plCrashCallbacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
#if HOCKEYSDK_FEATURE_CRASH_REPORTER
|
#if HOCKEYSDK_FEATURE_CRASH_REPORTER
|
||||||
|
|
||||||
|
#import <CrashReporter/CrashReporter.h>
|
||||||
|
|
||||||
@interface BITCrashManager () {
|
@interface BITCrashManager () {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -833,7 +833,7 @@
|
|||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
shellScript = "# Sets the target folders and the final framework product.\nFMK_NAME=HockeySDK\nFMK_VERSION=A\nFMK_RESOURCE_BUNDLE=HockeySDKResources\n\n# Documentation\nHOCKEYSDK_DOCSET_VERSION_NAME=\"de.bitstadium.${HOCKEYSDK_DOCSET_NAME}-${VERSION_STRING}\"\n\n# Install dir will be the final output to the framework.\n# The following line create it in the root folder of the current project.\nPRODUCTS_DIR=${SRCROOT}/../Products\nPLCR_DIR=${SRCROOT}/../Vendor/CrashReporter.framework\nZIP_FOLDER=HockeySDK-iOS\nTEMP_DIR=${PRODUCTS_DIR}/${ZIP_FOLDER}\nINSTALL_DIR=${TEMP_DIR}/${FMK_NAME}.framework\n\n# Working dir will be deleted after the framework creation.\nWRK_DIR=build\nDEVICE_DIR=${WRK_DIR}/Release-iphoneos\nSIMULATOR_DIR=${WRK_DIR}/Release-iphonesimulator\nHEADERS_DIR=${WRK_DIR}/Release-iphoneos/usr/local/include\n\n# Building both architectures.\nxcodebuild -project \"HockeySDK.xcodeproj\" -configuration \"Release\" -target \"${FMK_NAME}\" -sdk iphoneos\nxcodebuild -project \"HockeySDK.xcodeproj\" -configuration \"Release\" -target \"${FMK_NAME}\" -sdk iphonesimulator\n\n# Cleaning the oldest.\nif [ -d \"${TEMP_DIR}\" ]\nthen\nrm -rf \"${TEMP_DIR}\"\nfi\n\n# Creates and renews the final product folder.\nmkdir -p \"${INSTALL_DIR}\"\nmkdir -p \"${INSTALL_DIR}/Versions\"\nmkdir -p \"${INSTALL_DIR}/Versions/${FMK_VERSION}\"\nmkdir -p \"${INSTALL_DIR}/Versions/${FMK_VERSION}/Resources\"\nmkdir -p \"${INSTALL_DIR}/Versions/${FMK_VERSION}/Headers\"\n\n# Creates the internal links.\n# It MUST uses relative path, otherwise will not work when the folder is copied/moved.\nln -s \"${FMK_VERSION}\" \"${INSTALL_DIR}/Versions/Current\"\nln -s \"Versions/Current/Headers\" \"${INSTALL_DIR}/Headers\"\nln -s \"Versions/Current/Resources\" \"${INSTALL_DIR}/Resources\"\nln -s \"Versions/Current/${FMK_NAME}\" \"${INSTALL_DIR}/${FMK_NAME}\"\n\n# Copies the headers and resources files to the final product folder.\ncp -R \"${SRCROOT}/build/Release-iphoneos/include/HockeySDK/\" \"${INSTALL_DIR}/Versions/${FMK_VERSION}/Headers/\"\ncp -R \"${PLCR_DIR}/Versions/A/Headers/\" \"${INSTALL_DIR}/Versions/${FMK_VERSION}/Headers/\"\ncp -R \"${DEVICE_DIR}/${FMK_RESOURCE_BUNDLE}.bundle\" \"${INSTALL_DIR}/Versions/${FMK_VERSION}/Resources/\"\ncp -f \"${SRCROOT}/${FMK_NAME}.xcconfig\" \"${INSTALL_DIR}/Versions/${FMK_VERSION}/Resources/\"\n\n# Uses the Lipo Tool to merge both binary files (i386 + armv6/armv7) into one Universal final product.\nlipo -create \"${DEVICE_DIR}/lib${FMK_NAME}.a\" \"${SIMULATOR_DIR}/lib${FMK_NAME}.a\" -output \"${INSTALL_DIR}/Versions/${FMK_VERSION}/${FMK_NAME}\"\n\n# Combine the CrashReporter static library into a new Hockey static library file if they are not already present and copy the public headers too\nif [ -z $(otool -L \"${INSTALL_DIR}/Versions/${FMK_VERSION}/${FMK_NAME}\" | grep 'libCrashReporter') ]\nthen\nlibtool -static -o \"${INSTALL_DIR}/Versions/${FMK_VERSION}/${FMK_NAME}\" \"${INSTALL_DIR}/Versions/${FMK_VERSION}/${FMK_NAME}\" \"${SRCROOT}/../Vendor/CrashReporter.framework/Versions/A/CrashReporter\"\nfi\n\nrm -r \"${WRK_DIR}\"\n\n# build embeddedframework folder and move framework into it\nmkdir \"${INSTALL_DIR}/../${FMK_NAME}.embeddedframework\"\nmv \"${INSTALL_DIR}\" \"${INSTALL_DIR}/../${FMK_NAME}.embeddedframework/${FMK_NAME}.framework\"\n\n# link Resources\nNEW_INSTALL_DIR=${TEMP_DIR}/${FMK_NAME}.embeddedframework\nmkdir \"${NEW_INSTALL_DIR}/Resources\"\nln -s \"../${FMK_NAME}.framework/Resources/${FMK_RESOURCE_BUNDLE}.bundle\" \"${NEW_INSTALL_DIR}/Resources/${FMK_RESOURCE_BUNDLE}.bundle\"\nln -s \"../${FMK_NAME}.framework/Resources/${FMK_NAME}.xcconfig\" \"${NEW_INSTALL_DIR}/Resources/${FMK_NAME}.xcconfig\"\n\n# copy license, changelog, documentation, integration json\ncp -f \"${SRCROOT}/../Docs/Changelog-template.md\" \"${TEMP_DIR}/CHANGELOG\"\ncp -f \"${SRCROOT}/../Docs/Guide-Installation-Setup-template.md\" \"${TEMP_DIR}/README.md\"\ncp -f \"${SRCROOT}/../LICENSE\" \"${TEMP_DIR}\"\nmkdir \"${TEMP_DIR}/${HOCKEYSDK_DOCSET_VERSION_NAME}.docset\"\ncp -R \"${SRCROOT}/../documentation/docset/Contents\" \"${TEMP_DIR}/${HOCKEYSDK_DOCSET_VERSION_NAME}.docset\"\n\n# build zip\ncd \"${PRODUCTS_DIR}\"\nrm -f \"${FMK_NAME}-iOS-${VERSION_STRING}.zip\"\nzip -yr \"${FMK_NAME}-iOS-${VERSION_STRING}.zip\" \"${ZIP_FOLDER}\" -x \\*/.*\n\n#copy to output dir on cisimple\nif [ $CISIMPLE ]; then\n if [ ! -d \"${CONFIGURATION_BUILD_DIR}\" ]; then\n mkdir \"${CONFIGURATION_BUILD_DIR}\"\n fi\n cd \"${PRODUCTS_DIR}\"\n cp \"${FMK_NAME}-iOS-${VERSION_STRING}.zip\" \"${CONFIGURATION_BUILD_DIR}/${FMK_NAME}-iOS-${VERSION_STRING}.zip\"\nfi";
|
shellScript = "# Sets the target folders and the final framework product.\nFMK_NAME=HockeySDK\nFMK_VERSION=A\nFMK_RESOURCE_BUNDLE=HockeySDKResources\n\n# Documentation\nHOCKEYSDK_DOCSET_VERSION_NAME=\"de.bitstadium.${HOCKEYSDK_DOCSET_NAME}-${VERSION_STRING}\"\n\n# Install dir will be the final output to the framework.\n# The following line create it in the root folder of the current project.\nPRODUCTS_DIR=${SRCROOT}/../Products\nZIP_FOLDER=HockeySDK-iOS\nTEMP_DIR=${PRODUCTS_DIR}/${ZIP_FOLDER}\nINSTALL_DIR=${TEMP_DIR}/${FMK_NAME}.framework\n\n# Working dir will be deleted after the framework creation.\nWRK_DIR=build\nDEVICE_DIR=${WRK_DIR}/Release-iphoneos\nSIMULATOR_DIR=${WRK_DIR}/Release-iphonesimulator\nHEADERS_DIR=${WRK_DIR}/Release-iphoneos/usr/local/include\n\n# Building both architectures.\nxcodebuild -project \"HockeySDK.xcodeproj\" -configuration \"Release\" -target \"${FMK_NAME}\" -sdk iphoneos\nxcodebuild -project \"HockeySDK.xcodeproj\" -configuration \"Release\" -target \"${FMK_NAME}\" -sdk iphonesimulator\n\n# Cleaning the oldest.\nif [ -d \"${TEMP_DIR}\" ]\nthen\nrm -rf \"${TEMP_DIR}\"\nfi\n\n# Creates and renews the final product folder.\nmkdir -p \"${INSTALL_DIR}\"\nmkdir -p \"${INSTALL_DIR}/Versions\"\nmkdir -p \"${INSTALL_DIR}/Versions/${FMK_VERSION}\"\nmkdir -p \"${INSTALL_DIR}/Versions/${FMK_VERSION}/Resources\"\nmkdir -p \"${INSTALL_DIR}/Versions/${FMK_VERSION}/Headers\"\n\n# Creates the internal links.\n# It MUST uses relative path, otherwise will not work when the folder is copied/moved.\nln -s \"${FMK_VERSION}\" \"${INSTALL_DIR}/Versions/Current\"\nln -s \"Versions/Current/Headers\" \"${INSTALL_DIR}/Headers\"\nln -s \"Versions/Current/Resources\" \"${INSTALL_DIR}/Resources\"\nln -s \"Versions/Current/${FMK_NAME}\" \"${INSTALL_DIR}/${FMK_NAME}\"\n\n# Copies the headers and resources files to the final product folder.\ncp -R \"${SRCROOT}/build/Release-iphoneos/include/HockeySDK/\" \"${INSTALL_DIR}/Versions/${FMK_VERSION}/Headers/\"\ncp -R \"${DEVICE_DIR}/${FMK_RESOURCE_BUNDLE}.bundle\" \"${INSTALL_DIR}/Versions/${FMK_VERSION}/Resources/\"\ncp -f \"${SRCROOT}/${FMK_NAME}.xcconfig\" \"${INSTALL_DIR}/Versions/${FMK_VERSION}/Resources/\"\n\n# Uses the Lipo Tool to merge both binary files (i386 + armv6/armv7) into one Universal final product.\nlipo -create \"${DEVICE_DIR}/lib${FMK_NAME}.a\" \"${SIMULATOR_DIR}/lib${FMK_NAME}.a\" -output \"${INSTALL_DIR}/Versions/${FMK_VERSION}/${FMK_NAME}\"\n\n# Combine the CrashReporter static library into a new Hockey static library file if they are not already present and copy the public headers too\nif [ -z $(otool -L \"${INSTALL_DIR}/Versions/${FMK_VERSION}/${FMK_NAME}\" | grep 'libCrashReporter') ]\nthen\nlibtool -static -o \"${INSTALL_DIR}/Versions/${FMK_VERSION}/${FMK_NAME}\" \"${INSTALL_DIR}/Versions/${FMK_VERSION}/${FMK_NAME}\" \"${SRCROOT}/../Vendor/CrashReporter.framework/Versions/A/CrashReporter\"\nfi\n\nrm -r \"${WRK_DIR}\"\n\n# build embeddedframework folder and move framework into it\nmkdir \"${INSTALL_DIR}/../${FMK_NAME}.embeddedframework\"\nmv \"${INSTALL_DIR}\" \"${INSTALL_DIR}/../${FMK_NAME}.embeddedframework/${FMK_NAME}.framework\"\n\n# link Resources\nNEW_INSTALL_DIR=${TEMP_DIR}/${FMK_NAME}.embeddedframework\nmkdir \"${NEW_INSTALL_DIR}/Resources\"\nln -s \"../${FMK_NAME}.framework/Resources/${FMK_RESOURCE_BUNDLE}.bundle\" \"${NEW_INSTALL_DIR}/Resources/${FMK_RESOURCE_BUNDLE}.bundle\"\nln -s \"../${FMK_NAME}.framework/Resources/${FMK_NAME}.xcconfig\" \"${NEW_INSTALL_DIR}/Resources/${FMK_NAME}.xcconfig\"\n\n# copy license, changelog, documentation, integration json\ncp -f \"${SRCROOT}/../Docs/Changelog-template.md\" \"${TEMP_DIR}/CHANGELOG\"\ncp -f \"${SRCROOT}/../Docs/Guide-Installation-Setup-template.md\" \"${TEMP_DIR}/README.md\"\ncp -f \"${SRCROOT}/../LICENSE\" \"${TEMP_DIR}\"\nmkdir \"${TEMP_DIR}/${HOCKEYSDK_DOCSET_VERSION_NAME}.docset\"\ncp -R \"${SRCROOT}/../documentation/docset/Contents\" \"${TEMP_DIR}/${HOCKEYSDK_DOCSET_VERSION_NAME}.docset\"\n\n# build zip\ncd \"${PRODUCTS_DIR}\"\nrm -f \"${FMK_NAME}-iOS-${VERSION_STRING}.zip\"\nzip -yr \"${FMK_NAME}-iOS-${VERSION_STRING}.zip\" \"${ZIP_FOLDER}\" -x \\*/.*\n\n#copy to output dir on cisimple\nif [ $CISIMPLE ]; then\nif [ ! -d \"${CONFIGURATION_BUILD_DIR}\" ]; then\nmkdir \"${CONFIGURATION_BUILD_DIR}\"\nfi\ncd \"${PRODUCTS_DIR}\"\ncp \"${FMK_NAME}-iOS-${VERSION_STRING}.zip\" \"${CONFIGURATION_BUILD_DIR}/${FMK_NAME}-iOS-${VERSION_STRING}.zip\"\nfi";
|
||||||
};
|
};
|
||||||
1E8E66B215BC3D8200632A2E /* ShellScript */ = {
|
1E8E66B215BC3D8200632A2E /* ShellScript */ = {
|
||||||
isa = PBXShellScriptBuildPhase;
|
isa = PBXShellScriptBuildPhase;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user