git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@634 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
dmaclach 2010-07-28 19:06:30 +00:00
parent 6e3869c19f
commit 97918069d8
3 changed files with 55 additions and 46 deletions

View file

@ -110,16 +110,19 @@ typedef bool (*BreakpadFilterCallback)(int exception_type,
// Key: Value: // Key: Value:
// BREAKPAD_PRODUCT Product name (e.g., "MyAwesomeProduct") // BREAKPAD_PRODUCT Product name (e.g., "MyAwesomeProduct")
// This one is used as the key to identify // This one is used as the key to identify
// the product when uploading // the product when uploading. Falls back to
// CFBundleName if not specified.
// REQUIRED // REQUIRED
// //
// BREAKPAD_PRODUCT_DISPLAY This is the display name, e.g. a pretty // BREAKPAD_PRODUCT_DISPLAY This is the display name, e.g. a pretty
// name for the product when the crash_sender // name for the product when the crash_sender
// pops up UI for the user. Falls back to // pops up UI for the user. Falls back first to
// CFBundleDisplayName and then to
// BREAKPAD_PRODUCT if not specified. // BREAKPAD_PRODUCT if not specified.
// //
// BREAKPAD_VERSION Product version (e.g., 1.2.3), used // BREAKPAD_VERSION Product version (e.g., 1.2.3), used
// as metadata for crash report // as metadata for crash report. Falls back to
// CFBundleVersion if not specified.
// REQUIRED // REQUIRED
// //
// BREAKPAD_VENDOR Vendor name, used in UI (e.g. "A report has // BREAKPAD_VENDOR Vendor name, used in UI (e.g. "A report has

View file

@ -164,7 +164,7 @@ class Breakpad {
: handler_(NULL), : handler_(NULL),
config_params_(NULL), config_params_(NULL),
send_and_exit_(true), send_and_exit_(true),
filter_callback_(NULL), filter_callback_(NULL),
filter_callback_context_(NULL) { filter_callback_context_(NULL) {
inspector_path_[0] = 0; inspector_path_[0] = 0;
} }
@ -289,9 +289,9 @@ NSString * GetResourcePath() {
Dl_info info; Dl_info info;
if (dladdr((const void*)GetResourcePath, &info) != 0) { if (dladdr((const void*)GetResourcePath, &info) != 0) {
NSFileManager *filemgr = [NSFileManager defaultManager]; NSFileManager *filemgr = [NSFileManager defaultManager];
NSString *filePath NSString *filePath =
= [filemgr stringWithFileSystemRepresentation:info.dli_fname [filemgr stringWithFileSystemRepresentation:info.dli_fname
length:strlen(info.dli_fname)]; length:strlen(info.dli_fname)];
NSString *bundlePath = [filePath stringByDeletingLastPathComponent]; NSString *bundlePath = [filePath stringByDeletingLastPathComponent];
// The "Resources" directory should be in the same directory as the // The "Resources" directory should be in the same directory as the
// executable code, since that's how the Breakpad framework is built. // executable code, since that's how the Breakpad framework is built.
@ -300,7 +300,7 @@ NSString * GetResourcePath() {
DEBUGLOG(stderr, "Could not find GetResourcePath\n"); DEBUGLOG(stderr, "Could not find GetResourcePath\n");
// fallback plan // fallback plan
NSBundle *bundle = NSBundle *bundle =
[NSBundle bundleWithIdentifier:@"com.Google.BreakpadFramework"]; [NSBundle bundleWithIdentifier:@"com.Google.BreakpadFramework"];
resourcePath = [bundle resourcePath]; resourcePath = [bundle resourcePath];
} }
@ -364,9 +364,10 @@ bool Breakpad::Initialize(NSDictionary *parameters) {
// Create the handler (allocating it in our special protected pool) // Create the handler (allocating it in our special protected pool)
handler_ = handler_ =
new (gBreakpadAllocator->Allocate(sizeof(google_breakpad::ExceptionHandler))) new (gBreakpadAllocator->Allocate(
google_breakpad::ExceptionHandler( sizeof(google_breakpad::ExceptionHandler)))
Breakpad::ExceptionHandlerDirectCallback, this, true); google_breakpad::ExceptionHandler(
Breakpad::ExceptionHandlerDirectCallback, this, true);
return true; return true;
} }
@ -396,22 +397,23 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) {
NSString *urlStr = [parameters objectForKey:@BREAKPAD_URL]; NSString *urlStr = [parameters objectForKey:@BREAKPAD_URL];
NSString *interval = [parameters objectForKey:@BREAKPAD_REPORT_INTERVAL]; NSString *interval = [parameters objectForKey:@BREAKPAD_REPORT_INTERVAL];
NSString *inspectorPathString = NSString *inspectorPathString =
[parameters objectForKey:@BREAKPAD_INSPECTOR_LOCATION]; [parameters objectForKey:@BREAKPAD_INSPECTOR_LOCATION];
NSString *reporterPathString = NSString *reporterPathString =
[parameters objectForKey:@BREAKPAD_REPORTER_EXE_LOCATION]; [parameters objectForKey:@BREAKPAD_REPORTER_EXE_LOCATION];
NSString *timeout = [parameters objectForKey:@BREAKPAD_CONFIRM_TIMEOUT]; NSString *timeout = [parameters objectForKey:@BREAKPAD_CONFIRM_TIMEOUT];
NSArray *logFilePaths = [parameters objectForKey:@BREAKPAD_LOGFILES]; NSArray *logFilePaths = [parameters objectForKey:@BREAKPAD_LOGFILES];
NSString *logFileTailSize = [parameters objectForKey:@BREAKPAD_LOGFILE_UPLOAD_SIZE]; NSString *logFileTailSize =
[parameters objectForKey:@BREAKPAD_LOGFILE_UPLOAD_SIZE];
NSString *requestUserText = NSString *requestUserText =
[parameters objectForKey:@BREAKPAD_REQUEST_COMMENTS]; [parameters objectForKey:@BREAKPAD_REQUEST_COMMENTS];
NSString *requestEmail = [parameters objectForKey:@BREAKPAD_REQUEST_EMAIL]; NSString *requestEmail = [parameters objectForKey:@BREAKPAD_REQUEST_EMAIL];
NSString *vendor = NSString *vendor =
[parameters objectForKey:@BREAKPAD_VENDOR]; [parameters objectForKey:@BREAKPAD_VENDOR];
NSString *dumpSubdirectory = NSString *dumpSubdirectory =
[parameters objectForKey:@BREAKPAD_DUMP_DIRECTORY]; [parameters objectForKey:@BREAKPAD_DUMP_DIRECTORY];
NSDictionary *serverParameters = NSDictionary *serverParameters =
[parameters objectForKey:@BREAKPAD_SERVER_PARAMETER_DICT]; [parameters objectForKey:@BREAKPAD_SERVER_PARAMETER_DICT];
// These may have been set above as user prefs, which take priority. // These may have been set above as user prefs, which take priority.
if (!skipConfirm) { if (!skipConfirm) {
@ -424,8 +426,12 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) {
if (!product) if (!product)
product = [parameters objectForKey:@"CFBundleName"]; product = [parameters objectForKey:@"CFBundleName"];
if (!display) if (!display) {
display = product; display = [parameters objectForKey:@"CFBundleDisplayName"];
if (!display) {
display = product;
}
}
if (!version) if (!version)
version = [parameters objectForKey:@"CFBundleVersion"]; version = [parameters objectForKey:@"CFBundleVersion"];
@ -505,8 +511,10 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) {
// Find Reporter. // Find Reporter.
if (!reporterPathString) { if (!reporterPathString) {
reporterPathString = reporterPathString =
[resourcePath stringByAppendingPathComponent:@"crash_report_sender.app"]; [resourcePath
reporterPathString = [[NSBundle bundleWithPath:reporterPathString] executablePath]; stringByAppendingPathComponent:@"crash_report_sender.app"];
reporterPathString =
[[NSBundle bundleWithPath:reporterPathString] executablePath];
} }
// Verify that there is a Reporter application. // Verify that there is a Reporter application.
@ -551,9 +559,9 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) {
dictionary.SetKeyValue(BREAKPAD_SKIP_CONFIRM, [skipConfirm UTF8String]); dictionary.SetKeyValue(BREAKPAD_SKIP_CONFIRM, [skipConfirm UTF8String]);
dictionary.SetKeyValue(BREAKPAD_CONFIRM_TIMEOUT, [timeout UTF8String]); dictionary.SetKeyValue(BREAKPAD_CONFIRM_TIMEOUT, [timeout UTF8String]);
dictionary.SetKeyValue(BREAKPAD_INSPECTOR_LOCATION, dictionary.SetKeyValue(BREAKPAD_INSPECTOR_LOCATION,
[inspectorPathString fileSystemRepresentation]); [inspectorPathString fileSystemRepresentation]);
dictionary.SetKeyValue(BREAKPAD_REPORTER_EXE_LOCATION, dictionary.SetKeyValue(BREAKPAD_REPORTER_EXE_LOCATION,
[reporterPathString fileSystemRepresentation]); [reporterPathString fileSystemRepresentation]);
dictionary.SetKeyValue(BREAKPAD_LOGFILE_UPLOAD_SIZE, dictionary.SetKeyValue(BREAKPAD_LOGFILE_UPLOAD_SIZE,
[logFileTailSize UTF8String]); [logFileTailSize UTF8String]);
dictionary.SetKeyValue(BREAKPAD_REQUEST_COMMENTS, dictionary.SetKeyValue(BREAKPAD_REQUEST_COMMENTS,
@ -562,7 +570,7 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) {
dictionary.SetKeyValue(BREAKPAD_VENDOR, [vendor UTF8String]); dictionary.SetKeyValue(BREAKPAD_VENDOR, [vendor UTF8String]);
dictionary.SetKeyValue(BREAKPAD_DUMP_DIRECTORY, dictionary.SetKeyValue(BREAKPAD_DUMP_DIRECTORY,
[dumpSubdirectory UTF8String]); [dumpSubdirectory UTF8String]);
struct timeval tv; struct timeval tv;
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
char timeStartedString[32]; char timeStartedString[32];
@ -593,7 +601,7 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) {
} }
//============================================================================= //=============================================================================
void Breakpad::SetKeyValue(NSString *key, NSString *value) { void Breakpad::SetKeyValue(NSString *key, NSString *value) {
// We allow nil values. This is the same as removing the keyvalue. // We allow nil values. This is the same as removing the keyvalue.
if (!config_params_ || !key) if (!config_params_ || !key)
return; return;
@ -602,7 +610,7 @@ void Breakpad::SetKeyValue(NSString *key, NSString *value) {
} }
//============================================================================= //=============================================================================
NSString * Breakpad::KeyValue(NSString *key) { NSString *Breakpad::KeyValue(NSString *key) {
if (!config_params_ || !key) if (!config_params_ || !key)
return nil; return nil;
@ -611,25 +619,24 @@ NSString * Breakpad::KeyValue(NSString *key) {
} }
//============================================================================= //=============================================================================
void Breakpad::RemoveKeyValue(NSString *key) { void Breakpad::RemoveKeyValue(NSString *key) {
if (!config_params_ || !key) if (!config_params_ || !key) return;
return;
config_params_->RemoveKey([key UTF8String]); config_params_->RemoveKey([key UTF8String]);
} }
//============================================================================= //=============================================================================
void Breakpad::GenerateAndSendReport() { void Breakpad::GenerateAndSendReport() {
config_params_->SetKeyValue(BREAKPAD_ON_DEMAND, "YES"); config_params_->SetKeyValue(BREAKPAD_ON_DEMAND, "YES");
HandleException(0, 0, 0, mach_thread_self()); HandleException(0, 0, 0, mach_thread_self());
config_params_->SetKeyValue(BREAKPAD_ON_DEMAND, "NO"); config_params_->SetKeyValue(BREAKPAD_ON_DEMAND, "NO");
} }
//============================================================================= //=============================================================================
bool Breakpad::HandleException(int exception_type, bool Breakpad::HandleException(int exception_type,
int exception_code, int exception_code,
int exception_subcode, int exception_subcode,
mach_port_t crashing_thread) { mach_port_t crashing_thread) {
DEBUGLOG(stderr, "Breakpad: an exception occurred\n"); DEBUGLOG(stderr, "Breakpad: an exception occurred\n");
if (filter_callback_) { if (filter_callback_) {
@ -705,8 +712,7 @@ bool Breakpad::HandleException(int exception_type,
// If we don't want any forwarding, return true here to indicate that we've // If we don't want any forwarding, return true here to indicate that we've
// processed things as much as we want. // processed things as much as we want.
if (send_and_exit_) if (send_and_exit_) return true;
return true;
return false; return false;
} }
@ -732,11 +738,11 @@ BreakpadRef BreakpadCreate(NSDictionary *parameters) {
// since once it does its allocations and locks the memory, smashes to itself // since once it does its allocations and locks the memory, smashes to itself
// don't affect anything we care about. // don't affect anything we care about.
gMasterAllocator = gMasterAllocator =
new ProtectedMemoryAllocator(sizeof(ProtectedMemoryAllocator) * 2); new ProtectedMemoryAllocator(sizeof(ProtectedMemoryAllocator) * 2);
gKeyValueAllocator = gKeyValueAllocator =
new (gMasterAllocator->Allocate(sizeof(ProtectedMemoryAllocator))) new (gMasterAllocator->Allocate(sizeof(ProtectedMemoryAllocator)))
ProtectedMemoryAllocator(sizeof(SimpleStringDictionary)); ProtectedMemoryAllocator(sizeof(SimpleStringDictionary));
// Create a mutex for use in accessing the SimpleStringDictionary // Create a mutex for use in accessing the SimpleStringDictionary
int mutexResult = pthread_mutex_init(&gDictionaryMutex, NULL); int mutexResult = pthread_mutex_init(&gDictionaryMutex, NULL);
@ -754,8 +760,8 @@ BreakpadRef BreakpadCreate(NSDictionary *parameters) {
*/ */
gBreakpadAllocator = gBreakpadAllocator =
new (gMasterAllocator->Allocate(sizeof(ProtectedMemoryAllocator))) new (gMasterAllocator->Allocate(sizeof(ProtectedMemoryAllocator)))
ProtectedMemoryAllocator(breakpad_pool_size); ProtectedMemoryAllocator(breakpad_pool_size);
// Stack-based autorelease pool for Breakpad::Create() obj-c code. // Stack-based autorelease pool for Breakpad::Create() obj-c code.
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

View file

@ -1210,7 +1210,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 8B3102D411F0D60300FCF3E4 /* BreakpadDebug.xcconfig */; baseConfigurationReference = 8B3102D411F0D60300FCF3E4 /* BreakpadDebug.xcconfig */;
buildSettings = { buildSettings = {
HEADER_SEARCH_PATHS = "\"../../../**\""; HEADER_SEARCH_PATHS = ../../..;
}; };
name = Debug; name = Debug;
}; };
@ -1218,7 +1218,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 8B3102D511F0D60300FCF3E4 /* BreakpadRelease.xcconfig */; baseConfigurationReference = 8B3102D511F0D60300FCF3E4 /* BreakpadRelease.xcconfig */;
buildSettings = { buildSettings = {
HEADER_SEARCH_PATHS = "\"../../../**\""; HEADER_SEARCH_PATHS = ../../..;
}; };
name = Release; name = Release;
}; };