Update PLCrashReporter

This commit is contained in:
Andreas Linde 2012-07-03 17:29:08 +02:00
parent 748fbdd6a7
commit 4a10d000d0
9 changed files with 180 additions and 21 deletions

View File

@ -225,5 +225,5 @@ typedef enum {
* Most notably, the Objective-C runtime itself is not async-safe, and Objective-C may not be used within a signal
* handler.
*
* @sa PLCrashReporter::setCrashCallbacks:
*/
* @sa PLCrashReporter::setReporterCallbacks:
*/

View File

@ -35,6 +35,7 @@
#import "PLCrashReportThreadInfo.h"
#import "PLCrashReportBinaryImageInfo.h"
#import "PLCrashReportExceptionInfo.h"
#import "PLCrashReportReportInfo.h"
/**
* @ingroup constants
@ -78,6 +79,9 @@ typedef struct _PLCrashReportDecoder _PLCrashReportDecoder;
@private
/** Private implementation variables (used to hide the underlying protobuf parser) */
_PLCrashReportDecoder *_decoder;
/** Report info (may be nil) */
PLCrashReportReportInfo *_reportInfo;
/** System info */
PLCrashReportSystemInfo *_systemInfo;
@ -91,7 +95,7 @@ typedef struct _PLCrashReportDecoder _PLCrashReportDecoder;
/** Process info */
PLCrashReportProcessInfo *_processInfo;
/** Signal info */
/** Signal info (may be nil) */
PLCrashReportSignalInfo *_signalInfo;
/** Thread info (PLCrashReportThreadInfo instances) */
@ -166,4 +170,14 @@ typedef struct _PLCrashReportDecoder _PLCrashReportDecoder;
*/
@property(nonatomic, readonly) PLCrashReportExceptionInfo *exceptionInfo;
/**
* YES if report information is available.
*/
@property(nonatomic, readonly) BOOL hasReportInfo;
/**
* Crash report information.
*/
@property(nonatomic, readonly) PLCrashReportReportInfo *reportInfo;
@end

View File

@ -1,7 +1,7 @@
/*
* Author: Landon Fuller <landonf@plausiblelabs.com>
*
* Copyright (c) 2008-2009 Plausible Labs Cooperative, Inc.
* Copyright (c) 2008-2012 Plausible Labs Cooperative, Inc.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
@ -35,10 +35,18 @@
/** Application version */
NSString *_applicationVersion;
/** Application short version */
NSString *_applicationShortVersion;
/** Application startup timestamp */
NSDate *_applicationStartupTimestamp;
}
- (id) initWithApplicationIdentifier: (NSString *) applicationIdentifier
applicationVersion: (NSString *) applicationVersion;
applicationVersion: (NSString *) applicationVersion
applicationShortVersion: (NSString *) applicationShortVersion
applicationStartupTimestamp: (NSDate *) applicationStartupTimestamp;
/**
* The application identifier. This is usually the application's CFBundleIdentifier value.
@ -50,4 +58,14 @@
*/
@property(nonatomic, readonly) NSString *applicationVersion;
@end
/**
* The application short version. This is usually the application's CFBundleShortVersionString value.
*/
@property(nonatomic, readonly) NSString *applicationShortVersion;
/**
* The application startup timestamp. This is set when initializing the crash reporter.
*/
@property(nonatomic, readonly) NSDate *applicationStartupTimestamp;
@end

View File

@ -89,4 +89,4 @@
/** The process' native execution status. If false, the process is being run via process-level CPU emulation (such as Rosetta). */
@property(nonatomic, readonly) BOOL native;
@end
@end

View File

@ -0,0 +1,45 @@
/*
* Author: Andreas Linde <mail@andreaslinde.de>
*
* Copyright (c) 2012 Plausible Labs Cooperative, Inc.
* Copyright (c) 2012 Andreas Linde
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#import <Foundation/Foundation.h>
@interface PLCrashReportReportInfo : NSObject {
@private
/** Crash Report GUID */
NSString *_reportGUID;
}
- (id) initWithReportGUID: (NSString *) reportGUID;
/**
* The crash report GUID.
*/
@property(nonatomic, readonly) NSString *reportGUID;
@end

View File

@ -32,15 +32,31 @@
@private
/** Frame instruction pointer. */
uint64_t _instructionPointer;
/** Symbol start address, if any. */
uint64_t _symbolStart;
/** Symbol name, if any. */
NSString *_symbolName;
}
- (id) initWithInstructionPointer: (uint64_t) instructionPointer;
- (id) initWithInstructionPointer: (uint64_t) instructionPointer symbolStart: (uint64_t) symbolStart symbolName: (NSString *) symbolName;
/**
* Frame's instruction pointer.
*/
@property(nonatomic, readonly) uint64_t instructionPointer;
/**
* Frame's symbol address, if determined, otherwise 0.
*/
@property(nonatomic, readonly) uint64_t symbolStart;
/**
* Frame's symbol name, if determined, otherwise 0.
*/
@property(nonatomic, readonly) NSString *symbolName;
@end

View File

@ -28,6 +28,34 @@
#import <Foundation/Foundation.h>
/**
* @ingroup enums
*
* This set of constants defines options for PLCrashReporter.
*/
typedef enum {
/** Set this flag to cause PLCrashReporter to intercept exceptions thrown within the main NSRunLoop before they
* reach Apple's exception handler. They will be treated with the default behavior given to uncaught exceptions.
* Use with caution if the client overrides -[NSApplication sendEvent:].
*/
PLCrashReporterOptionCaptureRunLoopExceptions = (1 << 0),
} PLCrashReporterOptions;
/**
* @ingroup enums
*
* This set of constants defines possible values for the reportType in a post-write callback.
*/
typedef enum {
/** The report was generated by a UNIX signal, Mach exception, or Objective-C exception, contains full thread
* information, and will result in termination of the process. */
PLCrashReportTypeCrash = 0,
/** The report was generated by user request and contains full thread information, and execution will continue
* normally. */
PLCrashReportTypeUserRequest = 1,
} PLCrashReportType;
/**
* @ingroup functions
*
@ -39,10 +67,25 @@
* @param context The API client's supplied context value.
*
* @sa @ref async_safety
* @sa PLCrashReporter::setPostCrashCallbacks:
* @sa PLCrashReporter::setReporterCallbacks:
*/
typedef void (*PLCrashReporterPostCrashSignalCallback)(siginfo_t *info, ucontext_t *uap, void *context);
/**
* @ingroup functions
*
* Prototype of a callback function used to execute additional user code after a report has been written
* to disk. If a report is written, this callback will always be called before the PostCrashSignal
* callback. This callback is called only after all data is completely written to disk. In case of
* a user-generated report, no other callback will be made.
*
* @param name The location of the report that was saved. This is a full path.
* @param type The type of report that was written.
* @param context The API client's supplied context value.
* @sa PLCrashReporter::setReporterCallbacks:
*/
typedef void (*PLCrashReporterPostWriteReportCallback)(const char * const path, PLCrashReportType type, void *context);
/**
* @ingroup types
*
@ -53,15 +96,19 @@ typedef void (*PLCrashReporterPostCrashSignalCallback)(siginfo_t *info, ucontext
*/
typedef struct PLCrashReporterCallbacks {
/** The version number of this structure. If not one of the defined version numbers for this type, the behavior
* is undefined. The current version of this structure is 0. */
* is undefined. The current version of this structure is 1. */
uint16_t version;
/** An arbitrary user-supplied context value. This value may be NULL. */
void *context;
/** The callback used to report caught signal information. In version 0 of this structure, all crashes will be
* reported via this function. */
/** The callback used to report caught signal information. In versions 0 and 1 of this structure, all crashes
* will be reported via this function. */
PLCrashReporterPostCrashSignalCallback handleSignal;
/** The callback used to report completion of writing a crash log to disk. Only available in version 1 of this
* structure. If a version 0 structure is used, or this field is set to NULL, no callback is made. */
PLCrashReporterPostWriteReportCallback writeReport;
} PLCrashReporterCallbacks;
@interface PLCrashReporter : NSObject {
@ -75,6 +122,15 @@ typedef struct PLCrashReporterCallbacks {
/** Application version */
NSString *_applicationVersion;
/** Application short version */
NSString *_applicationShortVersion;
/** Application startup timestamp */
time_t _applicationStartupTimestamp;
/** GUID for the crash report */
NSString *_crashReportGUID;
/** Path to the crash reporter internal data directory */
NSString *_crashReportDirectory;
}
@ -82,16 +138,26 @@ typedef struct PLCrashReporterCallbacks {
+ (PLCrashReporter *) sharedReporter;
- (BOOL) hasPendingCrashReport;
- (BOOL) hasReportWithName: (NSString *) reportName;
- (NSData *) loadPendingCrashReportData;
- (NSData *) loadPendingCrashReportDataAndReturnError: (NSError **) outError;
- (NSData *) loadReportWithName: (NSString *) reportName;
- (NSData *) loadReportWithName: (NSString *) reportName andReturnError: (NSError **) outError;
- (BOOL) purgePendingCrashReport;
- (BOOL) purgePendingCrashReportAndReturnError: (NSError **) outError;
- (BOOL) purgeReportWithName: (NSString *) reportName;
- (BOOL) purgeReportWithName: (NSString *) reportName andReturnError: (NSError **) outError;
- (BOOL) enableCrashReporter;
- (BOOL) enableCrashReporterAndReturnError: (NSError **) outError;
- (BOOL) enableCrashReporterWithOptions: (PLCrashReporterOptions) options andReturnError: (NSError **) outError;
- (void) setCrashCallbacks: (PLCrashReporterCallbacks *) callbacks;
- (void) setCrashCallbacks: (PLCrashReporterCallbacks *) callbacks DEPRECATED_ATTRIBUTE;
- (void) setReporterCallbacks: (PLCrashReporterCallbacks *) callbacks;
@end
- (NSData *) generateReportData;
- (BOOL) generateReportWithName: (NSString *) reportName;
@end

View File

@ -3,13 +3,13 @@
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>11D50</string>
<string>11E53</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>CrashReporter</string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.CrashReporter</string>
<string>coop.plausible.CrashReporter</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
@ -21,18 +21,18 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvmgcc42</string>
<string></string>
<key>DTPlatformBuild</key>
<string>4D502</string>
<string>4E3002</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>11C63</string>
<string>11E52</string>
<key>DTSDKName</key>
<string>macosx10.7</string>
<key>DTXcode</key>
<string>0421</string>
<string>0433</string>
<key>DTXcodeBuild</key>
<string>4D502</string>
<string>4E3002</string>
</dict>
</plist>