Provide access to the signal information

git-svn-id: https://plcrashreporter.googlecode.com/svn/trunk@232 25172300-ee46-11dd-abe2-393a09110dd0
This commit is contained in:
landonf@OFFICE.PLAUSIBLELABS.COM 2008-12-18 20:44:12 +00:00
Родитель 677098eb37
Коммит 65f9c1bc48
4 изменённых файлов: 60 добавлений и 0 удалений

Просмотреть файл

@ -16,6 +16,7 @@ _PLCrashLogHostArchitecture
.objc_class_name_PLCrashLog
.objc_class_name_PLCrashLogSystemInfo
.objc_class_name_PLCrashLogApplicationInfo
.objc_class_name_PLCrashLogSignalInfo
.objc_class_name_PLCrashLogThreadInfo
.objc_class_name_PLCrashLogRegisterInfo
.objc_class_name_PLCrashLogStackFrameInfo

Просмотреть файл

@ -8,6 +8,7 @@
#import <Foundation/Foundation.h>
#import "PLCrashLogSystemInfo.h"
#import "PLCrashLogApplicationInfo.h"
#import "PLCrashLogSignalInfo.h"
#import "PLCrashLogThreadInfo.h"
#import "PLCrashLogBinaryImageInfo.h"
#import "PLCrashLogExceptionInfo.h"
@ -61,6 +62,9 @@ typedef struct _PLCrashLogDecoder _PLCrashLogDecoder;
/** Application info */
PLCrashLogApplicationInfo *_applicationInfo;
/** Signal info */
PLCrashLogSignalInfo *_signalInfo;
/** Thread info (PLCrashLogThreadInfo instances) */
NSArray *_threads;
@ -85,6 +89,12 @@ typedef struct _PLCrashLogDecoder _PLCrashLogDecoder;
*/
@property(nonatomic, readonly) PLCrashLogApplicationInfo *applicationInfo;
/**
* Signal information. This provides the signal and signal code
* of the fatal signal.
*/
@property(nonatomic, readonly) PLCrashLogSignalInfo *signalInfo;
/**
* Thread information. Returns a list of PLCrashLogThreadInfo instances.
*/

Просмотреть файл

@ -24,6 +24,8 @@ struct _PLCrashLogDecoder {
- (NSArray *) extractThreadInfo: (Plcrash__CrashReport *) crashReport error: (NSError **) outError;
- (NSArray *) extractImageInfo: (Plcrash__CrashReport *) crashReport error: (NSError **) outError;
- (PLCrashLogApplicationInfo *) extractExceptionInfo: (Plcrash__CrashReport__Exception *) exceptionInfo error: (NSError **) outError;
- (PLCrashLogSignalInfo *) extractSignalInfo: (Plcrash__CrashReport__Signal *) signalInfo error: (NSError **) outError;
@end
@ -77,6 +79,11 @@ static void populate_nserror (NSError **error, PLCrashReporterError code, NSStri
if (!_applicationInfo)
goto error;
/* Signal info */
_signalInfo = [[self extractSignalInfo: _decoder->crashReport->signal error: outError] retain];
if (!_signalInfo)
goto error;
/* Thread info */
_threads = [[self extractThreadInfo: _decoder->crashReport error: outError] retain];
if (!_threads)
@ -146,6 +153,7 @@ error:
@synthesize systemInfo = _systemInfo;
@synthesize applicationInfo = _applicationInfo;
@synthesize signalInfo = _signalInfo;
@synthesize threads = _threads;
@synthesize images = _images;
@synthesize exceptionInfo = _exceptionInfo;
@ -430,6 +438,43 @@ error:
return [[[PLCrashLogExceptionInfo alloc] initWithExceptionName: name reason: reason] autorelease];
}
/**
* Extract signal information from the crash log. Returns nil on error.
*/
- (PLCrashLogSignalInfo *) extractSignalInfo: (Plcrash__CrashReport__Signal *) signalInfo
error: (NSError **) outError
{
/* Validate */
if (signalInfo == NULL) {
populate_nserror(outError, PLCrashReporterErrorCrashReportInvalid,
NSLocalizedString(@"Crash report is missing Signal Information section",
@"Missing appinfo in crash report"));
return nil;
}
/* Name available? */
if (signalInfo->name == NULL) {
populate_nserror(outError, PLCrashReporterErrorCrashReportInvalid,
NSLocalizedString(@"Crash report is missing signal name field",
@"Missing appinfo operating system in crash report"));
return nil;
}
/* Code available? */
if (signalInfo->code == NULL) {
populate_nserror(outError, PLCrashReporterErrorCrashReportInvalid,
NSLocalizedString(@"Crash report is missing signal code field",
@"Missing appinfo operating system in crash report"));
return nil;
}
/* Done */
NSString *name = [NSString stringWithUTF8String: signalInfo->name];
NSString *code = [NSString stringWithUTF8String: signalInfo->code];
return [[[PLCrashLogSignalInfo alloc] initWithSignalName: name code: code] autorelease];
}
@end
/**

Просмотреть файл

@ -102,6 +102,10 @@
STAssertNotNil(crashLog.applicationInfo.applicationIdentifier, @"No application identifier available");
STAssertNotNil(crashLog.applicationInfo.applicationVersion, @"No application version available");
/* Signal info */
STAssertEqualStrings(@"SIGSEGV", crashLog.signalInfo.name, @"Signal is incorrect");
STAssertEqualStrings(@"SEGV_MAPERR", crashLog.signalInfo.code, @"Signal code is incorrect");
/* Thread info */
STAssertNotNil(crashLog.threads, @"Thread list is nil");
STAssertNotEquals((NSUInteger)0, [crashLog.threads count], @"No thread values returned");