Merge branch 'master' into bugfix/PLCR-521-concurrent-fault-safety
This commit is contained in:
Коммит
7f667a037f
|
@ -133,6 +133,9 @@ message CrashReport {
|
|||
|
||||
/* Application version string */
|
||||
required string version = 2;
|
||||
|
||||
/* Application marketing version string */
|
||||
optional string marketing_version = 3;
|
||||
}
|
||||
required ApplicationInfo application_info = 2;
|
||||
|
||||
|
|
|
@ -109,6 +109,9 @@ typedef struct plcrash_log_writer {
|
|||
|
||||
/** Application version */
|
||||
char *app_version;
|
||||
|
||||
/** Application marketing version (may be null) */
|
||||
char *app_marketing_version;
|
||||
} application_info;
|
||||
|
||||
/** Process data */
|
||||
|
@ -216,6 +219,7 @@ void plcrash_log_objc_exception_info_free (plcrash_log_objc_exception_info_t *in
|
|||
plcrash_error_t plcrash_log_writer_init (plcrash_log_writer_t *writer,
|
||||
NSString *app_identifier,
|
||||
NSString *app_version,
|
||||
NSString *app_marketing_version,
|
||||
plcrash_async_symbol_strategy_t symbol_strategy,
|
||||
BOOL user_requested);
|
||||
|
||||
|
|
|
@ -95,6 +95,9 @@ enum {
|
|||
|
||||
/** CrashReport.app_info.app_version */
|
||||
PLCRASH_PROTO_APP_INFO_APP_VERSION_ID = 2,
|
||||
|
||||
/** CrashReport.app_info.app_marketing_version */
|
||||
PLCRASH_PROTO_APP_INFO_APP_MARKETING_VERSION_ID = 3,
|
||||
|
||||
|
||||
/** CrashReport.symbol.name */
|
||||
|
@ -261,6 +264,7 @@ enum {
|
|||
* @param writer Writer instance to be initialized.
|
||||
* @param app_identifier Unique per-application identifier. On Mac OS X, this is likely the CFBundleIdentifier.
|
||||
* @param app_version Application version string.
|
||||
* @param app_marketing_version Application marketing version string (may be nil).
|
||||
* @param symbol_strategy The strategy to use for local symbolication.
|
||||
* @param user_requested If true, the written report will be marked as a 'generated' non-crash report, rather than as
|
||||
* a true crash report created upon an actual crash.
|
||||
|
@ -273,6 +277,7 @@ enum {
|
|||
plcrash_error_t plcrash_log_writer_init (plcrash_log_writer_t *writer,
|
||||
NSString *app_identifier,
|
||||
NSString *app_version,
|
||||
NSString *app_marketing_version,
|
||||
plcrash_async_symbol_strategy_t symbol_strategy,
|
||||
BOOL user_requested)
|
||||
{
|
||||
|
@ -299,6 +304,9 @@ plcrash_error_t plcrash_log_writer_init (plcrash_log_writer_t *writer,
|
|||
{
|
||||
writer->application_info.app_identifier = strdup([app_identifier UTF8String]);
|
||||
writer->application_info.app_version = strdup([app_version UTF8String]);
|
||||
if (app_marketing_version != nil) {
|
||||
writer->application_info.app_marketing_version = strdup([app_marketing_version UTF8String]);
|
||||
}
|
||||
}
|
||||
|
||||
/* Fetch the process information */
|
||||
|
@ -480,6 +488,8 @@ void plcrash_log_writer_free (plcrash_log_writer_t *writer) {
|
|||
free(writer->application_info.app_identifier);
|
||||
if (writer->application_info.app_version != NULL)
|
||||
free(writer->application_info.app_version);
|
||||
if (writer->application_info.app_marketing_version != NULL)
|
||||
free(writer->application_info.app_marketing_version);
|
||||
|
||||
/* Free the process info */
|
||||
if (writer->process_info.process_name != NULL)
|
||||
|
@ -655,8 +665,9 @@ static size_t plcrash_writer_write_machine_info (AsyncFile *file, plcrash_log_wr
|
|||
* @param file Output file
|
||||
* @param app_identifier Application identifier
|
||||
* @param app_version Application version
|
||||
* @param app_marketing_version Application marketing version
|
||||
*/
|
||||
static size_t plcrash_writer_write_app_info (AsyncFile *file, const char *app_identifier, const char *app_version) {
|
||||
static size_t plcrash_writer_write_app_info (AsyncFile *file, const char *app_identifier, const char *app_version, const char *app_marketing_version) {
|
||||
size_t rv = 0;
|
||||
|
||||
/* App identifier */
|
||||
|
@ -665,6 +676,10 @@ static size_t plcrash_writer_write_app_info (AsyncFile *file, const char *app_id
|
|||
/* App version */
|
||||
rv += plcrash_writer_pack(file, PLCRASH_PROTO_APP_INFO_APP_VERSION_ID, PLPROTOBUF_C_TYPE_STRING, app_version);
|
||||
|
||||
/* App marketing version */
|
||||
if (app_marketing_version != NULL)
|
||||
rv += plcrash_writer_pack(file, PLCRASH_PROTO_APP_INFO_APP_MARKETING_VERSION_ID, PLPROTOBUF_C_TYPE_STRING, app_marketing_version);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -1287,11 +1302,11 @@ plcrash_error_t plcrash_log_writer_write (plcrash_log_writer_t *writer,
|
|||
uint32_t size;
|
||||
|
||||
/* Determine size */
|
||||
size = plcrash_writer_write_app_info(NULL, writer->application_info.app_identifier, writer->application_info.app_version);
|
||||
size = plcrash_writer_write_app_info(NULL, writer->application_info.app_identifier, writer->application_info.app_version, writer->application_info.app_marketing_version);
|
||||
|
||||
/* Write message */
|
||||
plcrash_writer_pack(file, PLCRASH_PROTO_APP_INFO_ID, PLPROTOBUF_C_TYPE_MESSAGE, &size);
|
||||
plcrash_writer_write_app_info(file, writer->application_info.app_identifier, writer->application_info.app_version);
|
||||
plcrash_writer_write_app_info(file, writer->application_info.app_identifier, writer->application_info.app_version, writer->application_info.app_marketing_version);
|
||||
}
|
||||
|
||||
/* Process info */
|
||||
|
|
|
@ -116,6 +116,7 @@ using namespace plcrash::async;
|
|||
|
||||
STAssertTrue(strcmp(appInfo->identifier, "test.id") == 0, @"Incorrect app ID written");
|
||||
STAssertTrue(strcmp(appInfo->version, "1.0") == 0, @"Incorrect app version written");
|
||||
STAssertTrue(strcmp(appInfo->marketing_version, "2.0") == 0, @"Incorrect app marketing version written");
|
||||
}
|
||||
|
||||
// check a crash report's process info
|
||||
|
@ -324,7 +325,7 @@ using namespace plcrash::async;
|
|||
AsyncFile file = AsyncFile(fd, 0);
|
||||
|
||||
/* Initialize a writer */
|
||||
STAssertEquals(PLCRASH_ESUCCESS, plcrash_log_writer_init(&writer, @"test.id", @"1.0", PLCRASH_ASYNC_SYMBOL_STRATEGY_ALL, false), @"Initialization failed");
|
||||
STAssertEquals(PLCRASH_ESUCCESS, plcrash_log_writer_init(&writer, @"test.id", @"1.0", @"2.0", PLCRASH_ASYNC_SYMBOL_STRATEGY_ALL, false), @"Initialization failed");
|
||||
|
||||
/* Set an exception with a valid return address call stack. */
|
||||
plcrash_log_objc_exception_info_t objc_exc_info;
|
||||
|
|
|
@ -469,6 +469,8 @@ error:
|
|||
- (PLCrashReportApplicationInfo *) extractApplicationInfo: (Plcrash__CrashReport__ApplicationInfo *) applicationInfo
|
||||
error: (NSError **) outError
|
||||
{
|
||||
NSString *marketingVersion = nil;
|
||||
|
||||
/* Validate */
|
||||
if (applicationInfo == NULL) {
|
||||
populate_nserror(outError, PLCrashReporterErrorCrashReportInvalid,
|
||||
|
@ -493,12 +495,18 @@ error:
|
|||
return nil;
|
||||
}
|
||||
|
||||
/* Marketing Version available? */
|
||||
if (applicationInfo->marketing_version != NULL) {
|
||||
marketingVersion = [NSString stringWithUTF8String: applicationInfo->marketing_version];
|
||||
}
|
||||
|
||||
/* Done */
|
||||
NSString *identifier = [NSString stringWithUTF8String: applicationInfo->identifier];
|
||||
NSString *version = [NSString stringWithUTF8String: applicationInfo->version];
|
||||
|
||||
return [[[PLCrashReportApplicationInfo alloc] initWithApplicationIdentifier: identifier
|
||||
applicationVersion: version] autorelease];
|
||||
applicationVersion: version
|
||||
applicationMarketingVersion:marketingVersion] autorelease];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -35,10 +35,14 @@
|
|||
|
||||
/** Application version */
|
||||
NSString *_applicationVersion;
|
||||
|
||||
/** Application marketing version */
|
||||
NSString *_applicationMarketingVersion;
|
||||
}
|
||||
|
||||
- (id) initWithApplicationIdentifier: (NSString *) applicationIdentifier
|
||||
applicationVersion: (NSString *) applicationVersion;
|
||||
applicationVersion: (NSString *) applicationVersion
|
||||
applicationMarketingVersion: (NSString *) applicationMarketingVersion;
|
||||
|
||||
/**
|
||||
* The application identifier. This is usually the application's CFBundleIdentifier value.
|
||||
|
@ -50,4 +54,9 @@
|
|||
*/
|
||||
@property(nonatomic, readonly) NSString *applicationVersion;
|
||||
|
||||
/**
|
||||
* The application marketing version. This is usually the application's CFBundleShortVersionString value if available. May be nil.
|
||||
*/
|
||||
@property(nonatomic, readonly) NSString *applicationMarketingVersion;
|
||||
|
||||
@end
|
||||
|
|
|
@ -44,12 +44,14 @@
|
|||
*/
|
||||
- (id) initWithApplicationIdentifier: (NSString *) applicationIdentifier
|
||||
applicationVersion: (NSString *) applicationVersion
|
||||
applicationMarketingVersion: (NSString *) applicationMarketingVersion
|
||||
{
|
||||
if ((self = [super init]) == nil)
|
||||
return nil;
|
||||
|
||||
_applicationIdentifier = [applicationIdentifier retain];
|
||||
_applicationVersion = [applicationVersion retain];
|
||||
_applicationMarketingVersion = [applicationMarketingVersion retain];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -57,10 +59,12 @@
|
|||
- (void) dealloc {
|
||||
[_applicationIdentifier release];
|
||||
[_applicationVersion release];
|
||||
[_applicationMarketingVersion release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@synthesize applicationIdentifier = _applicationIdentifier;
|
||||
@synthesize applicationVersion = _applicationVersion;
|
||||
@synthesize applicationMarketingVersion = _applicationMarketingVersion;
|
||||
|
||||
@end
|
||||
|
|
|
@ -109,7 +109,7 @@ static plcrash_error_t plcr_live_report_callback (plcrash_async_thread_state_t *
|
|||
AsyncFile file = AsyncFile(fd, 0);
|
||||
|
||||
/* Initialize a writer */
|
||||
STAssertEquals(PLCRASH_ESUCCESS, plcrash_log_writer_init(&writer, @"test.id", @"1.0", PLCRASH_ASYNC_SYMBOL_STRATEGY_ALL, false), @"Initialization failed");
|
||||
STAssertEquals(PLCRASH_ESUCCESS, plcrash_log_writer_init(&writer, @"test.id", @"1.0", @"1.0", PLCRASH_ASYNC_SYMBOL_STRATEGY_ALL, false), @"Initialization failed");
|
||||
|
||||
/* Set an exception with a valid return address call stack. */
|
||||
plcrash_log_objc_exception_info_t objc_exc_info;
|
||||
|
|
|
@ -219,10 +219,15 @@ NSInteger binaryImageSort(id binary1, id binary2, void *context);
|
|||
parentProcessId = [[NSNumber numberWithUnsignedInteger: report.processInfo.parentProcessID] stringValue];
|
||||
}
|
||||
|
||||
NSString *versionString = report.applicationInfo.applicationVersion;
|
||||
/* Marketing version is optional */
|
||||
if (report.applicationInfo.applicationMarketingVersion != nil)
|
||||
versionString = [NSString stringWithFormat: @"%@ (%@)", report.applicationInfo.applicationMarketingVersion, report.applicationInfo.applicationVersion];
|
||||
|
||||
[text appendFormat: @"Process: %@ [%@]\n", processName, processId];
|
||||
[text appendFormat: @"Path: %@\n", processPath];
|
||||
[text appendFormat: @"Identifier: %@\n", report.applicationInfo.applicationIdentifier];
|
||||
[text appendFormat: @"Version: %@\n", report.applicationInfo.applicationVersion];
|
||||
[text appendFormat: @"Version: %@\n", versionString];
|
||||
[text appendFormat: @"Code Type: %@\n", codeType];
|
||||
[text appendFormat: @"Parent Process: %@ [%@]\n", parentProcessName, parentProcessId];
|
||||
}
|
||||
|
|
|
@ -103,6 +103,9 @@ typedef struct PLCrashReporterCallbacks {
|
|||
|
||||
/** Application version */
|
||||
NSString *_applicationVersion;
|
||||
|
||||
/** Application marketing version */
|
||||
NSString *_applicationMarketingVersion;
|
||||
|
||||
/** Path to the crash reporter internal data directory */
|
||||
NSString *_crashReportDirectory;
|
||||
|
|
|
@ -427,7 +427,7 @@ static void uncaught_exception_handler (NSException *exception) {
|
|||
@interface PLCrashReporter (PrivateMethods)
|
||||
|
||||
- (id) initWithBundle: (NSBundle *) bundle configuration: (PLCrashReporterConfig *) configuration;
|
||||
- (id) initWithApplicationIdentifier: (NSString *) applicationIdentifier appVersion: (NSString *) applicationVersion configuration: (PLCrashReporterConfig *) configuration;
|
||||
- (id) initWithApplicationIdentifier: (NSString *) applicationIdentifier appVersion: (NSString *) applicationVersion appMarketingVersion: (NSString *) applicationMarketingVersion configuration: (PLCrashReporterConfig *) configuration;
|
||||
|
||||
- (PLCrashMachExceptionServer *) enableMachExceptionServerWithPreviousPortSet: (PLCrashMachExceptionPortSet **) previousPortSet
|
||||
callback: (PLCrashMachExceptionHandlerCallback) callback
|
||||
|
@ -637,7 +637,7 @@ static PLCrashReporter *sharedReporter = nil;
|
|||
|
||||
assert(_applicationIdentifier != nil);
|
||||
assert(_applicationVersion != nil);
|
||||
plcrash_log_writer_init(&signal_handler_context.writer, _applicationIdentifier, _applicationVersion, [self mapToAsyncSymbolicationStrategy: _config.symbolicationStrategy], false);
|
||||
plcrash_log_writer_init(&signal_handler_context.writer, _applicationIdentifier, _applicationVersion, _applicationMarketingVersion, [self mapToAsyncSymbolicationStrategy: _config.symbolicationStrategy], false);
|
||||
|
||||
|
||||
/* Enable the signal handler */
|
||||
|
@ -762,7 +762,7 @@ static plcrash_error_t plcr_live_report_callback (plcrash_async_thread_state_t *
|
|||
}
|
||||
|
||||
/* Initialize the output context */
|
||||
plcrash_log_writer_init(&writer, _applicationIdentifier, _applicationVersion, [self mapToAsyncSymbolicationStrategy: _config.symbolicationStrategy], true);
|
||||
plcrash_log_writer_init(&writer, _applicationIdentifier, _applicationVersion, _applicationMarketingVersion, [self mapToAsyncSymbolicationStrategy: _config.symbolicationStrategy], true);
|
||||
AsyncFile file = AsyncFile(fd, MAX_REPORT_BYTES);
|
||||
|
||||
/* Mock up a SIGTRAP-based signal info */
|
||||
|
@ -904,12 +904,13 @@ cleanup:
|
|||
*
|
||||
* @param applicationIdentifier The application identifier to be included in crash reports.
|
||||
* @param applicationVersion The application version number to be included in crash reports.
|
||||
* @param applicationMarketingVersion The application marketing version number to be included in crash reports.
|
||||
* @param configuration The PLCrashReporter configuration.
|
||||
*
|
||||
* @todo The appId and version values should be fetched from the PLCrashReporterConfig, once the API
|
||||
* has been extended to allow supplying these values.
|
||||
*/
|
||||
- (id) initWithApplicationIdentifier: (NSString *) applicationIdentifier appVersion: (NSString *) applicationVersion configuration: (PLCrashReporterConfig *) configuration {
|
||||
- (id) initWithApplicationIdentifier: (NSString *) applicationIdentifier appVersion: (NSString *) applicationVersion appMarketingVersion: (NSString *) applicationMarketingVersion configuration: (PLCrashReporterConfig *) configuration {
|
||||
/* Initialize our superclass */
|
||||
if ((self = [super init]) == nil)
|
||||
return nil;
|
||||
|
@ -918,6 +919,7 @@ cleanup:
|
|||
_config = [configuration retain];
|
||||
_applicationIdentifier = [applicationIdentifier retain];
|
||||
_applicationVersion = [applicationVersion retain];
|
||||
_applicationMarketingVersion = [applicationMarketingVersion retain];
|
||||
|
||||
/* No occurances of '/' should ever be in a bundle ID, but just to be safe, we escape them */
|
||||
NSString *appIdPath = [applicationIdentifier stringByReplacingOccurrencesOfString: @"/" withString: @"_"];
|
||||
|
@ -941,6 +943,7 @@ cleanup:
|
|||
- (id) initWithBundle: (NSBundle *) bundle configuration: (PLCrashReporterConfig *) configuration {
|
||||
NSString *bundleIdentifier = [bundle bundleIdentifier];
|
||||
NSString *bundleVersion = [[bundle infoDictionary] objectForKey: (NSString *) kCFBundleVersionKey];
|
||||
NSString *bundleMarketingVersion = [[bundle infoDictionary] objectForKey: @"CFBundleShortVersionString"];
|
||||
|
||||
/* Verify that the identifier is available */
|
||||
if (bundleIdentifier == nil) {
|
||||
|
@ -961,7 +964,7 @@ cleanup:
|
|||
bundleVersion = @"";
|
||||
}
|
||||
|
||||
return [self initWithApplicationIdentifier: bundleIdentifier appVersion: bundleVersion configuration: configuration];
|
||||
return [self initWithApplicationIdentifier: bundleIdentifier appVersion: bundleVersion appMarketingVersion:bundleMarketingVersion configuration: configuration];
|
||||
}
|
||||
|
||||
#if PLCRASH_FEATURE_MACH_EXCEPTIONS
|
||||
|
@ -1049,6 +1052,7 @@ cleanup:
|
|||
[_crashReportDirectory release];
|
||||
[_applicationIdentifier release];
|
||||
[_applicationVersion release];
|
||||
[_applicationMarketingVersion release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче