Expose the new process start time field via the PLCrashReport API.

This commit is contained in:
Landon Fuller 2013-07-10 16:41:21 -04:00
Родитель 8a284e4046
Коммит a3d5df282d
4 изменённых файлов: 29 добавлений и 1 удалений

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

@ -420,6 +420,11 @@ error:
NSString *processPath = nil;
if (processInfo->process_path != NULL)
processPath = [NSString stringWithUTF8String: processInfo->process_path];
/* Start time available? */
NSDate *startTime = nil;
if (processInfo->has_start_time)
startTime = [NSDate dateWithTimeIntervalSince1970: processInfo->start_time];
/* Parent Name available? */
NSString *parentProcessName = nil;
@ -434,6 +439,7 @@ error:
return [[[PLCrashReportProcessInfo alloc] initWithProcessName: processName
processID: processID
processPath: processPath
processStartTime: startTime
parentProcessName: parentProcessName
parentProcessID: parentProcessID
native: processInfo->native] autorelease];

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

@ -40,7 +40,11 @@
/** Process path */
NSString* _processPath;
/** Date and time that the crashing process was started. This may be unavailable, and this property
* will be nil. */
NSDate *_processStartTime;
/** Parent process name */
NSString *_parentProcessName;
@ -54,6 +58,7 @@
- (id) initWithProcessName: (NSString *) processName
processID: (NSUInteger) processID
processPath: (NSString *) processPath
processStartTime: (NSDate *) processStartTime
parentProcessName: (NSString *) parentProcessName
parentProcessID: (NSUInteger) parentProcessID
native: (BOOL) native;
@ -75,6 +80,12 @@
*/
@property(nonatomic, readonly) NSString *processPath;
/**
* Date and time that the crashing process was started. This value may not be included in the crash report, in which case this property
* will be nil.
*/
@property(nonatomic, readonly) NSDate *processStartTime;
/**
* The parent process name. This value may not be included in the crash report, in which case this property
* will be nil.

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

@ -44,6 +44,7 @@
* @param processName Process name. May be nil.
* @param processID Process PID.
* @param processPath Full path to the process' binary. May be nil.
* @param processStartTime Date and time that the crashing process was started. May be nil.
* @param parentProcessName Parent process' name. May be nil.
* @param parentProcessID Parent process' PID.
* @param process Flag designating whether this process is native. If false, the process is being run via process-level
@ -52,6 +53,7 @@
- (id) initWithProcessName: (NSString *) processName
processID: (NSUInteger) processID
processPath: (NSString *) processPath
processStartTime: (NSDate *) processStartTime
parentProcessName: (NSString *) parentProcessName
parentProcessID: (NSUInteger) parentProcessID
native: (BOOL) native
@ -62,6 +64,7 @@
_processName = [processName retain];
_processID = processID;
_processPath = [processPath retain];
_processStartTime = [processStartTime retain];
_parentProcessName = [parentProcessName retain];
_parentProcessID = parentProcessID;
_native = native;
@ -72,6 +75,7 @@
- (void) dealloc {
[_processName release];
[_processPath release];
[_processStartTime release];
[_parentProcessName release];
[super dealloc];
}
@ -79,6 +83,7 @@
@synthesize processName = _processName;
@synthesize processID = _processID;
@synthesize processPath = _processPath;
@synthesize processStartTime = _processStartTime;
@synthesize parentProcessName = _parentProcessName;
@synthesize parentProcessID = _parentProcessID;
@synthesize native = _native;

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

@ -167,6 +167,12 @@ static plcrash_error_t plcr_live_report_callback (plcrash_async_thread_state_t *
STAssertNotNil(crashLog.processInfo, @"No process information available");
STAssertNotNil(crashLog.processInfo.processName, @"No process name available");
STAssertNotNil(crashLog.processInfo.processPath, @"No process path available");
STAssertNotNil(crashLog.processInfo.processStartTime, @"No process start time available");
NSTimeInterval startTimeInterval = [[NSDate date] timeIntervalSinceDate: crashLog.processInfo.processStartTime];
STAssertTrue(startTimeInterval >= 0, @"Date occured in the future");
STAssertTrue(startTimeInterval < 60, @"Date occured more than 60 second in the past");
STAssertNotNil(crashLog.processInfo.parentProcessName, @"No parent process name available");
STAssertTrue(crashLog.processInfo.native, @"Process should be native");