Define a flag to note whether the crashing process is being run via process-level CPU emulation (such as Rosetta).
git-svn-id: https://plcrashreporter.googlecode.com/svn/trunk@386 25172300-ee46-11dd-abe2-393a09110dd0
This commit is contained in:
Родитель
8135501b43
Коммит
12e9bba1f2
|
@ -237,6 +237,9 @@ message CrashReport {
|
|||
|
||||
/* Application parent process ID */
|
||||
required uint32 parent_process_id = 5;
|
||||
|
||||
/** If false, the process is being run via process-level CPU emulation (such as Rosetta). */
|
||||
required bool native = 6;
|
||||
}
|
||||
|
||||
/* The process info. Required for all v1.1+ crash reports. */
|
||||
|
|
|
@ -101,6 +101,9 @@ typedef struct plcrash_log_writer {
|
|||
|
||||
/** Parent process ID */
|
||||
pid_t parent_process_id;
|
||||
|
||||
/** If false, the reporting process is being run under process emulation (such as Rosetta). */
|
||||
bool native;
|
||||
} process_info;
|
||||
|
||||
/** Binary image data */
|
||||
|
|
|
@ -177,6 +177,9 @@ enum {
|
|||
/** CrashReport.process_info.parent_process_id */
|
||||
PLCRASH_PROTO_PROCESS_INFO_PARENT_PROCESS_ID_ID = 5,
|
||||
|
||||
/** CrashReport.process_info.native */
|
||||
PLCRASH_PROTO_PROCESS_INFO_NATIVE_ID = 6,
|
||||
|
||||
|
||||
/** CrashReport.Processor.encoding */
|
||||
PLCRASH_PROTO_PROCESSOR_ENCODING_ID = 1,
|
||||
|
@ -313,8 +316,23 @@ plcrash_error_t plcrash_log_writer_init (plcrash_log_writer_t *writer, NSString
|
|||
} else {
|
||||
PLCF_DEBUG("Could not retrive hw.logicalcpu_max: %s", strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if emulated. This sysctl is defined here: */
|
||||
{
|
||||
int retval;
|
||||
|
||||
if (plcrash_sysctl_int("sysctl.proc_native", &retval)) {
|
||||
if (retval == 0) {
|
||||
writer->process_info.native = false;
|
||||
} else {
|
||||
writer->process_info.native = true;
|
||||
}
|
||||
} else {
|
||||
/* If the sysctl is not available, the process can be assumed to be native. */
|
||||
writer->process_info.native = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Fetch the OS information */
|
||||
|
@ -588,10 +606,12 @@ static size_t plcrash_writer_write_app_info (plcrash_async_file_t *file, const c
|
|||
* @param process_path Process path
|
||||
* @param parent_process_name Parent process name
|
||||
* @param parent_process_id Parent process ID
|
||||
* @param native If false, process is running under emulation.
|
||||
*/
|
||||
static size_t plcrash_writer_write_process_info (plcrash_async_file_t *file, const char *process_name,
|
||||
const pid_t process_id, const char *process_path,
|
||||
const char *parent_process_name, const pid_t parent_process_id)
|
||||
const char *parent_process_name, const pid_t parent_process_id,
|
||||
bool native)
|
||||
{
|
||||
size_t rv = 0;
|
||||
|
||||
|
@ -612,7 +632,10 @@ static size_t plcrash_writer_write_process_info (plcrash_async_file_t *file, con
|
|||
|
||||
/* Parent process ID */
|
||||
rv += plcrash_writer_pack(file, PLCRASH_PROTO_PROCESS_INFO_PARENT_PROCESS_ID_ID, PLPROTOBUF_C_TYPE_UINT64, &parent_process_id);
|
||||
|
||||
|
||||
/* Native process. */
|
||||
rv += plcrash_writer_pack(file, PLCRASH_PROTO_PROCESS_INFO_NATIVE_ID, PLPROTOBUF_C_TYPE_BOOL, &native);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -1027,13 +1050,13 @@ plcrash_error_t plcrash_log_writer_write (plcrash_log_writer_t *writer, plcrash_
|
|||
/* Determine size */
|
||||
size = plcrash_writer_write_process_info(NULL, writer->process_info.process_name, writer->process_info.process_id,
|
||||
writer->process_info.process_path, writer->process_info.parent_process_name,
|
||||
writer->process_info.parent_process_id);
|
||||
writer->process_info.parent_process_id, writer->process_info.native);
|
||||
|
||||
/* Write message */
|
||||
plcrash_writer_pack(file, PLCRASH_PROTO_PROCESS_INFO_ID, PLPROTOBUF_C_TYPE_MESSAGE, &size);
|
||||
plcrash_writer_write_process_info(file, writer->process_info.process_name, writer->process_info.process_id,
|
||||
writer->process_info.process_path, writer->process_info.parent_process_name,
|
||||
writer->process_info.parent_process_id);
|
||||
writer->process_info.parent_process_id, writer->process_info.native);
|
||||
}
|
||||
|
||||
/* Threads */
|
||||
|
|
|
@ -430,7 +430,8 @@ error:
|
|||
processID: processID
|
||||
processPath: processPath
|
||||
parentProcessName: parentProcessName
|
||||
parentProcessID: parentProcessID] autorelease];
|
||||
parentProcessID: parentProcessID
|
||||
native: processInfo->native] autorelease];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,13 +46,17 @@
|
|||
|
||||
/** Parent process ID */
|
||||
NSUInteger _parentProcessID;
|
||||
|
||||
/** If false, the process is being run via process-level CPU emulation (such as Rosetta). */
|
||||
BOOL _native;
|
||||
}
|
||||
|
||||
- (id) initWithProcessName: (NSString *) processName
|
||||
processID: (NSUInteger) processID
|
||||
processPath: (NSString *) processPath
|
||||
parentProcessName: (NSString *) parentProcessName
|
||||
parentProcessID: (NSUInteger) parentProcessID;
|
||||
parentProcessID: (NSUInteger) parentProcessID
|
||||
native: (BOOL) native;
|
||||
|
||||
/**
|
||||
* The process name. This value may not be included in the crash report, in which case this property
|
||||
|
@ -82,4 +86,7 @@
|
|||
*/
|
||||
@property(nonatomic, readonly) NSUInteger parentProcessID;
|
||||
|
||||
/** 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
|
|
@ -46,12 +46,15 @@
|
|||
* @param processPath Full path to the process' binary. 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
|
||||
* CPU emulation (such as Rosetta).
|
||||
*/
|
||||
- (id) initWithProcessName: (NSString *) processName
|
||||
processID: (NSUInteger) processID
|
||||
processPath: (NSString *) processPath
|
||||
parentProcessName: (NSString *) parentProcessName
|
||||
parentProcessID: (NSUInteger) parentProcessID
|
||||
native: (BOOL) native
|
||||
{
|
||||
if ((self = [super init]) == nil)
|
||||
return nil;
|
||||
|
@ -61,7 +64,8 @@
|
|||
_processPath = [processPath retain];
|
||||
_parentProcessName = [parentProcessName retain];
|
||||
_parentProcessID = parentProcessID;
|
||||
|
||||
_native = native;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -77,5 +81,6 @@
|
|||
@synthesize processPath = _processPath;
|
||||
@synthesize parentProcessName = _parentProcessName;
|
||||
@synthesize parentProcessID = _parentProcessID;
|
||||
@synthesize native = _native;
|
||||
|
||||
@end
|
||||
|
|
|
@ -149,6 +149,7 @@
|
|||
STAssertNotNil(crashLog.processInfo.processName, @"No process name available");
|
||||
STAssertNotNil(crashLog.processInfo.processPath, @"No process path available");
|
||||
STAssertNotNil(crashLog.processInfo.parentProcessName, @"No parent process name available");
|
||||
STAssertTrue(crashLog.processInfo.native, @"Process should be native");
|
||||
|
||||
/* Signal info */
|
||||
STAssertEqualStrings(@"SIGSEGV", crashLog.signalInfo.name, @"Signal is incorrect");
|
||||
|
|
Загрузка…
Ссылка в новой задаче