[plcrashreporter] 2 new revisions pushed by landon.j.fuller@gmail.com on 2013-07-11 21:08 GMT

10 views
Skip to first unread message

codesite...@google.com

unread,
Jul 11, 2013, 5:08:23 PM7/11/13
to plcrashrepo...@googlegroups.com
2 new revisions:

Revision: db087b68320e
Author: Landon Fuller <lan...@plausible.coop>
Date: Thu Jul 11 10:42:37 2013
Log: Include a incident UUID in crash reports....
http://code.google.com/p/plcrashreporter/source/detail?r=db087b68320e

Revision: 418cef4d2a48
Author: Landon Fuller <lan...@plausible.coop>
Date: Thu Jul 11 14:07:21 2013
Log: Encode the incident identifier directly as a UUID value.
http://code.google.com/p/plcrashreporter/source/detail?r=418cef4d2a48

==============================================================================
Revision: db087b68320e
Author: Landon Fuller <lan...@plausible.coop>
Date: Thu Jul 11 10:42:37 2013
Log: Include a incident UUID in crash reports.

Issue: 64
Submitted by: Craig Newell <craign [at] ieee.org>

http://code.google.com/p/plcrashreporter/source/detail?r=db087b68320e

Modified:
/Resources/crash_report.proto
/Source/PLCrashLogWriter.h
/Source/PLCrashLogWriter.m
/Source/PLCrashReport.h
/Source/PLCrashReport.m
/Source/PLCrashReportTests.m
/Source/PLCrashReportTextFormatter.m
/Source/PLCrashReporterTests.m

=======================================
--- /Resources/crash_report.proto Tue Jan 1 14:02:34 2013
+++ /Resources/crash_report.proto Thu Jul 11 10:42:37 2013
@@ -318,6 +318,9 @@
message ReportInfo {
/** If true, this report was generated on request, and no crash
occured. */
required bool user_requested = 1;
+
+ /** UUID unique for this crash */
+ optional string incident_id = 2;
}

/* Report format information. Required for all v1.1+ crash reports. */
=======================================
--- /Source/PLCrashLogWriter.h Mon Jan 7 13:17:15 2013
+++ /Source/PLCrashLogWriter.h Thu Jul 11 10:42:37 2013
@@ -54,6 +54,9 @@
/** If true, the report should be marked as a 'generated'
user-requested report, rather than as a true crash
* report */
bool user_requested;
+
+ /** Incident Identifier */
+ char *incident_id;
} report_info;

/** System data */
=======================================
--- /Source/PLCrashLogWriter.m Wed Jul 10 09:29:28 2013
+++ /Source/PLCrashLogWriter.m Thu Jul 11 10:42:37 2013
@@ -233,6 +233,9 @@

/** CrashReport.report_info.crashed */
PLCRASH_PROTO_REPORT_INFO_USER_REQUESTED_ID = 1,
+
+ /** CrashReport.report_info.incident */
+ PLCRASH_PROTO_REPORT_INFO_INCIDENT_ID = 2,
};

/**
@@ -261,6 +264,9 @@
/* Default to false */
writer->report_info.user_requested = user_requested;

+ /* Generate a UUID for this incident */
+ writer->report_info.incident_id = strdup([[[NSUUID UUID] UUIDString]
UTF8String]);
+
/* Fetch the application information */
{
writer->application_info.app_identifier = strdup([app_identifier
UTF8String]);
@@ -1088,6 +1094,9 @@
/* Note crashed status */
rv += plcrash_writer_pack(file,
PLCRASH_PROTO_REPORT_INFO_USER_REQUESTED_ID, PLPROTOBUF_C_TYPE_BOOL,
&writer->report_info.user_requested);

+ /* Incident Identifier */
+ rv += plcrash_writer_pack(file, PLCRASH_PROTO_REPORT_INFO_INCIDENT_ID,
PLPROTOBUF_C_TYPE_STRING, writer->report_info.incident_id);
+
return rv;
}

=======================================
--- /Source/PLCrashReport.h Tue Jan 1 14:02:34 2013
+++ /Source/PLCrashReport.h Thu Jul 11 10:42:37 2013
@@ -107,6 +107,12 @@

/** Exception information (may be nil) */
PLCrashReportExceptionInfo *_exceptionInfo;
+
+ /** User requested not a crash */
+ BOOL _userRequested;
+
+ /** Report UUID */
+ NSString *_incidentIdentifier;
}

- (id) initWithData: (NSData *) encodedData error: (NSError **) outError;
@@ -171,4 +177,14 @@
*/
@property(nonatomic, readonly) PLCrashReportExceptionInfo *exceptionInfo;

+/**
+ * YES if this report was user requested not generated because of a crash.
+ */
+@property(nonatomic, readonly) BOOL userRequested;
+
+/**
+ * Incident Identifier. A UUID unique to this crash report.
+ */
+@property(nonatomic, readonly) NSString *incidentIdentifier;
+
@end
=======================================
--- /Source/PLCrashReport.m Tue Jan 1 14:02:34 2013
+++ /Source/PLCrashReport.m Thu Jul 11 10:42:37 2013
@@ -92,6 +92,22 @@
goto error;
}

+ /* Report info (optional) */
+ _userRequested = NO;
+ _incidentIdentifier = nil;
+ if (_decoder->crashReport->report_info) {
+ _userRequested =
_decoder->crashReport->report_info->user_requested;
+
+ /* Incident Identifier (optional) */
+ if (_decoder->crashReport->report_info->incident_id) {
+ _incidentIdentifier = [[NSString
stringWithUTF8String:_decoder->crashReport->report_info->incident_id]
retain];
+ }
+ }
+
+ /* If no incident identifier from client, generate one now */
+ if (_incidentIdentifier == nil) {
+ _incidentIdentifier = [[[NSUUID UUID] UUIDString] retain];
+ }

/* System info */
_systemInfo = [[self extractSystemInfo:
_decoder->crashReport->system_info error: outError] retain];
@@ -156,6 +172,7 @@
[_threads release];
[_images release];
[_exceptionInfo release];
+ [_incidentIdentifier release];

/* Free the decoder state */
if (_decoder != NULL) {
@@ -215,6 +232,8 @@
@synthesize threads = _threads;
@synthesize images = _images;
@synthesize exceptionInfo = _exceptionInfo;
+@synthesize userRequested = _userRequested;
+@synthesize incidentIdentifier = _incidentIdentifier;

@end

=======================================
--- /Source/PLCrashReportTests.m Tue Jan 1 14:02:34 2013
+++ /Source/PLCrashReportTests.m Thu Jul 11 10:42:37 2013
@@ -121,6 +121,11 @@
PLCrashReport *crashLog = [[[PLCrashReport alloc] initWithData:
[NSData dataWithContentsOfMappedFile: _logPath] error: &error] autorelease];
STAssertNotNil(crashLog, @"Could not decode crash log: %@", error);

+ /* Report info */
+ STAssertFalse(crashLog.userRequested, @"Crash should not be user
requested");
+ STAssertNotNil(crashLog.incidentIdentifier, @"No incident identifier");
+ STAssertNotNil([[NSUUID new]
initWithUUIDString:crashLog.incidentIdentifier], @"incident identifier not
a UUID");
+
/* System info */
STAssertNotNil(crashLog.systemInfo, @"No system information
available");
STAssertNotNil(crashLog.systemInfo.operatingSystemVersion, @"OS
version is nil");
=======================================
--- /Source/PLCrashReportTextFormatter.m Thu Apr 18 08:34:32 2013
+++ /Source/PLCrashReportTextFormatter.m Thu Jul 11 10:42:37 2013
@@ -168,7 +168,7 @@
if (report.hasMachineInfo && report.machineInfo.modelName != nil)
hardwareModel = report.machineInfo.modelName;

- [text appendFormat: @"Incident Identifier: TODO\n"];
+ [text appendFormat: @"Incident Identifier: %@\n",
report.incidentIdentifier];
[text appendFormat: @"CrashReporter Key: TODO\n"];
[text appendFormat: @"Hardware Model: %@\n", hardwareModel];
}
@@ -248,6 +248,13 @@

[text appendString: @"\n"];
}
+
+ /* Was this user requested not a real crash? */
+ if (report.userRequested) {
+ [text appendString: @"Application Specific Information:\n"];
+ [text appendString: @"*** User Requested Crash Report ***\n"];
+ [text appendString: @"\n"];
+ }

/* If an exception stack trace is available, output an
Apple-compatible backtrace. */
if (report.exceptionInfo != nil && report.exceptionInfo.stackFrames !=
nil && [report.exceptionInfo.stackFrames count] > 0) {
=======================================
--- /Source/PLCrashReporterTests.m Mon Jan 7 13:14:07 2013
+++ /Source/PLCrashReporterTests.m Thu Jul 11 10:42:37 2013
@@ -60,6 +60,7 @@
/* Try parsing the result */
PLCrashReport *report = [[PLCrashReport alloc] initWithData:
reportData error: &error];
STAssertNotNil(report, @"Could not parse geneated live report: %@",
error);
+ STAssertTrue(report.userRequested, @"Report not marked user
requested");

/* Sanity check the signal info */
STAssertEqualStrings([[report signalInfo] name], @"SIGTRAP",
@"Incorrect signal name");
@@ -76,7 +77,8 @@

PLCrashReport *report = [[PLCrashReport alloc] initWithData:
reportData error: &error];
STAssertNotNil(report, @"Could not parse geneated live report: %@",
error);
-
+ STAssertTrue(report.userRequested, @"Report not marked user
requested");
+
STAssertEqualStrings([[report signalInfo] name], @"SIGTRAP",
@"Incorrect signal name");
STAssertEqualStrings([[report signalInfo] code], @"TRAP_TRACE",
@"Incorrect signal code");
}

==============================================================================
Revision: 418cef4d2a48
Author: Landon Fuller <lan...@plausible.coop>
Date: Thu Jul 11 14:07:21 2013
Log: Encode the incident identifier directly as a UUID value.

http://code.google.com/p/plcrashreporter/source/detail?r=418cef4d2a48

Modified:
/Resources/crash_report.proto
/Source/PLCrashLogWriter.h
/Source/PLCrashLogWriter.m
/Source/PLCrashLogWriterTests.m
/Source/PLCrashReport.h
/Source/PLCrashReport.m
/Source/PLCrashReportTests.m
/Source/PLCrashReportTextFormatter.m

=======================================
--- /Resources/crash_report.proto Thu Jul 11 10:42:37 2013
+++ /Resources/crash_report.proto Thu Jul 11 14:07:21 2013
@@ -319,8 +319,9 @@
/** If true, this report was generated on request, and no crash
occured. */
required bool user_requested = 1;

- /** UUID unique for this crash */
- optional string incident_id = 2;
+ /** A client-generated 16 byte OSF standard UUID for this report.
May be used to filter duplicate reports submitted
+ * by a single client. */
+ optional bytes uuid = 2;
}

/* Report format information. Required for all v1.1+ crash reports. */
=======================================
--- /Source/PLCrashLogWriter.h Thu Jul 11 10:42:37 2013
+++ /Source/PLCrashLogWriter.h Thu Jul 11 14:07:21 2013
@@ -32,6 +32,8 @@
#import "PLCrashAsync.h"
#import "PLCrashAsyncImageList.h"

+#include <uuid/uuid.h>
+
/**
* @internal
* @defgroup plcrash_log_writer Crash Log Writer
@@ -55,8 +57,8 @@
* report */
bool user_requested;

- /** Incident Identifier */
- char *incident_id;
+ /** Report UUID */
+ uuid_t uuid_bytes;
} report_info;

/** System data */
=======================================
--- /Source/PLCrashLogWriter.m Thu Jul 11 10:42:37 2013
+++ /Source/PLCrashLogWriter.m Thu Jul 11 14:07:21 2013
@@ -234,8 +234,8 @@
/** CrashReport.report_info.crashed */
PLCRASH_PROTO_REPORT_INFO_USER_REQUESTED_ID = 1,

- /** CrashReport.report_info.incident */
- PLCRASH_PROTO_REPORT_INFO_INCIDENT_ID = 2,
+ /** CrashReport.report_info.uuid */
+ PLCRASH_PROTO_REPORT_INFO_UUID_ID = 2,
};

/**
@@ -264,8 +264,15 @@
/* Default to false */
writer->report_info.user_requested = user_requested;

- /* Generate a UUID for this incident */
- writer->report_info.incident_id = strdup([[[NSUUID UUID] UUIDString]
UTF8String]);
+ /* Generate a UUID for this incident; CFUUID is used in favor of
NSUUID as to maintain compatibility
+ * with (Mac OS X 10.7|iOS 5) and earlier. */
+ {
+ CFUUIDRef uuid = CFUUIDCreate(NULL);
+ CFUUIDBytes bytes = CFUUIDGetUUIDBytes(uuid);
+ PLCF_ASSERT(sizeof(bytes) ==
sizeof(writer->report_info.uuid_bytes));
+ memcpy(writer->report_info.uuid_bytes, &bytes,
sizeof(writer->report_info.uuid_bytes));
+ CFRelease(uuid);
+ }

/* Fetch the application information */
{
@@ -1094,8 +1101,12 @@
/* Note crashed status */
rv += plcrash_writer_pack(file,
PLCRASH_PROTO_REPORT_INFO_USER_REQUESTED_ID, PLPROTOBUF_C_TYPE_BOOL,
&writer->report_info.user_requested);

- /* Incident Identifier */
- rv += plcrash_writer_pack(file, PLCRASH_PROTO_REPORT_INFO_INCIDENT_ID,
PLPROTOBUF_C_TYPE_STRING, writer->report_info.incident_id);
+ /* Write the 128-bit UUID */
+ PLProtobufCBinaryData uuid_bin;
+
+ uuid_bin.len = sizeof(writer->report_info.uuid_bytes);
+ uuid_bin.data = &writer->report_info.uuid_bytes;
+ rv += plcrash_writer_pack(file, PLCRASH_PROTO_REPORT_INFO_UUID_ID,
PLPROTOBUF_C_TYPE_BYTES, &uuid_bin);

return rv;
}
=======================================
--- /Source/PLCrashLogWriterTests.m Wed Jul 10 09:29:28 2013
+++ /Source/PLCrashLogWriterTests.m Thu Jul 11 14:07:21 2013
@@ -334,6 +334,16 @@
return;

STAssertFalse(crashReport->report_info->user_requested, @"Report not
correctly marked as non-user-requested");
+ STAssertTrue(crashReport->report_info->has_uuid, @"Report missing a
UUID value");
+ STAssertEquals((size_t)16, crashReport->report_info->uuid.len, @"UUID
is not expected 16 bytes");
+ {
+ CFUUIDBytes uuid_bytes;
+ memcpy(&uuid_bytes, crashReport->report_info->uuid.data,
sizeof(uuid_bytes));
+ CFUUIDRef uuid = CFUUIDCreateFromUUIDBytes(NULL, uuid_bytes);
+ STAssertNotNULL(uuid, @"Value not parsable as a UUID");
+ if (uuid != NULL)
+ CFRelease(uuid);
+ }

/* Test the report */
[self checkSystemInfo: crashReport];
=======================================
--- /Source/PLCrashReport.h Thu Jul 11 10:42:37 2013
+++ /Source/PLCrashReport.h Thu Jul 11 14:07:21 2013
@@ -41,6 +41,12 @@
#import "PLCrashReportSystemInfo.h"
#import "PLCrashReportThreadInfo.h"

+#import <AvailabilityMacros.h>
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8 ||
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_6_0
+#define PLCRASH_PRIVATE_HAS_NSUUID 1
+#endif
+
/**
* @ingroup constants
* Crash file magic identifier */
@@ -112,7 +118,7 @@
BOOL _userRequested;

/** Report UUID */
- NSString *_incidentIdentifier;
+ CFUUIDRef _uuid;
}

- (id) initWithData: (NSData *) encodedData error: (NSError **) outError;
@@ -183,8 +189,10 @@
@property(nonatomic, readonly) BOOL userRequested;

/**
- * Incident Identifier. A UUID unique to this crash report.
+ * A client-generated 16-byte UUID. May be used to filter duplicate
reports submitted or generated
+ * by a single client. Only available in later (v1.2+) crash report format
versions. If not available,
+ * will be NULL.
*/
-@property(nonatomic, readonly) NSString *incidentIdentifier;
+@property(nonatomic, readonly) CFUUIDRef uuidRef;

@end
=======================================
--- /Source/PLCrashReport.m Thu Jul 11 10:42:37 2013
+++ /Source/PLCrashReport.m Thu Jul 11 14:07:21 2013
@@ -94,20 +94,25 @@

/* Report info (optional) */
_userRequested = NO;
- _incidentIdentifier = nil;
- if (_decoder->crashReport->report_info) {
+ _uuid = NULL;
+ if (_decoder->crashReport->report_info != NULL) {
_userRequested =
_decoder->crashReport->report_info->user_requested;

- /* Incident Identifier (optional) */
- if (_decoder->crashReport->report_info->incident_id) {
- _incidentIdentifier = [[NSString
stringWithUTF8String:_decoder->crashReport->report_info->incident_id]
retain];
+ /* Report UUID (optional)
+ * If our minimum supported target is bumped to (10.8+, iOS 6.0+),
NSUUID should
+ * be used instead. */
+ if (_decoder->crashReport->report_info->has_uuid) {
+ /* Validate the UUID length */
+ if (_decoder->crashReport->report_info->uuid.len !=
sizeof(uuid_t)) {
+ populate_nserror(outError,
PLCrashReporterErrorCrashReportInvalid , @"Report UUID value is not a
standard 16 bytes");
+ goto error;
+ }
+
+ CFUUIDBytes uuid_bytes;
+ memcpy(&uuid_bytes,
_decoder->crashReport->report_info->uuid.data,
_decoder->crashReport->report_info->uuid.len);
+ _uuid = CFUUIDCreateFromUUIDBytes(NULL, uuid_bytes);
}
}
-
- /* If no incident identifier from client, generate one now */
- if (_incidentIdentifier == nil) {
- _incidentIdentifier = [[[NSUUID UUID] UUIDString] retain];
- }

/* System info */
_systemInfo = [[self extractSystemInfo:
_decoder->crashReport->system_info error: outError] retain];
@@ -172,7 +177,9 @@
[_threads release];
[_images release];
[_exceptionInfo release];
- [_incidentIdentifier release];
+
+ if (_uuid != NULL)
+ CFRelease(_uuid);

/* Free the decoder state */
if (_decoder != NULL) {
@@ -233,7 +240,7 @@
@synthesize images = _images;
@synthesize exceptionInfo = _exceptionInfo;
@synthesize userRequested = _userRequested;
-@synthesize incidentIdentifier = _incidentIdentifier;
+@synthesize uuidRef = _uuid;

@end

=======================================
--- /Source/PLCrashReportTests.m Thu Jul 11 10:42:37 2013
+++ /Source/PLCrashReportTests.m Thu Jul 11 14:07:21 2013
@@ -123,9 +123,8 @@

/* Report info */
STAssertFalse(crashLog.userRequested, @"Crash should not be user
requested");
- STAssertNotNil(crashLog.incidentIdentifier, @"No incident identifier");
- STAssertNotNil([[NSUUID new]
initWithUUIDString:crashLog.incidentIdentifier], @"incident identifier not
a UUID");
-
+ STAssertNotNULL(crashLog.uuidRef, @"No report UUID");
+
/* System info */
STAssertNotNil(crashLog.systemInfo, @"No system information
available");
STAssertNotNil(crashLog.systemInfo.operatingSystemVersion, @"OS
version is nil");
=======================================
--- /Source/PLCrashReportTextFormatter.m Thu Jul 11 10:42:37 2013
+++ /Source/PLCrashReportTextFormatter.m Thu Jul 11 14:07:21 2013
@@ -46,6 +46,7 @@

@interface PLCrashReportTextFormatter (PrivateAPI)
NSInteger binaryImageSort(id binary1, id binary2, void *context);
+
+ (NSString *) formatStackFrame: (PLCrashReportStackFrameInfo *) frameInfo
frameIndex: (NSUInteger) frameIndex
report: (PLCrashReport *) report
@@ -58,7 +59,6 @@
*/
@implementation PLCrashReportTextFormatter

-
/**
* Formats the provided @a report as human-readable text in the given @a
textFormat, and return
* the formatted result as a string.
@@ -168,7 +168,13 @@
if (report.hasMachineInfo && report.machineInfo.modelName != nil)
hardwareModel = report.machineInfo.modelName;

- [text appendFormat: @"Incident Identifier: %@\n",
report.incidentIdentifier];
+ NSString *incidentIdentifier = @"???";
+ if (report.uuidRef != NULL) {
+ incidentIdentifier = (NSString *) CFUUIDCreateString(NULL,
report.uuidRef);
+ [incidentIdentifier autorelease];
+ }
+
+ [text appendFormat: @"Incident Identifier: %@\n",
incidentIdentifier];
[text appendFormat: @"CrashReporter Key: TODO\n"];
[text appendFormat: @"Hardware Model: %@\n", hardwareModel];
}
@@ -505,6 +511,7 @@
lp64 ? 16 : 8, frameInfo.instructionPointer,
symbolString];
}
+

/**
* Sort PLCrashReportBinaryImageInfo instances by their starting address.
Reply all
Reply to author
Forward
0 new messages