#import "client/mac/Framework/Breakpad.h"
#import "client/mac/Framework/OnDemandServer.h"
#import "client/mac/handler/protected_memory_allocator.h"
+#include "common/mac/launch_reporter.h"
#import "common/mac/MachIPC.h"
#import "common/simple_string_dictionary.h"
: mutex_(mutex),
allocator_(allocator) {
// Lock the mutex
- int rv = pthread_mutex_lock(mutex_);
+ __attribute__((unused)) int rv = pthread_mutex_lock(mutex_);
assert(rv == 0);
// Unprotect the memory
allocator_->Protect();
// Then unlock the mutex
- int rv = pthread_mutex_unlock(mutex_);
+ __attribute__((unused)) int rv = pthread_mutex_unlock(mutex_);
assert(rv == 0);
};
}
bool Initialize(NSDictionary *parameters);
+ bool InitializeInProcess(NSDictionary *parameters);
+ bool InitializeOutOfProcess(NSDictionary *parameters);
bool ExtractParameters(NSDictionary *parameters);
int exception_subcode,
mach_port_t crashing_thread);
+ // Dispatches to HandleMinidump().
+ // This gets called instead of ExceptionHandlerDirectCallback when running
+ // with the BREAKPAD_IN_PROCESS option.
+ static bool HandleMinidumpCallback(const char *dump_dir,
+ const char *minidump_id,
+ void *context,
+ bool succeeded);
+
+ // This is only used when BREAKPAD_IN_PROCESS is YES.
+ bool HandleMinidump(const char *dump_dir, const char *minidump_id);
+
// Since ExceptionHandler (w/o namespace) is defined as typedef in OSX's
// MachineExceptions.h, we have to explicitly name the handler.
google_breakpad::ExceptionHandler *handler_; // The actual handler (STRONG)
}
//=============================================================================
+bool Breakpad::HandleMinidumpCallback(const char *dump_dir,
+ const char *minidump_id,
+ void *context,
+ bool succeeded) {
+ Breakpad *breakpad = (Breakpad *)context;
+
+ // If our context is damaged or something, just return false to indicate that
+ // the handler should continue without us.
+ if (!breakpad || !succeeded)
+ return false;
+
+ return breakpad->HandleMinidump(dump_dir, minidump_id);
+}
+
+//=============================================================================
#pragma mark -
#include <dlfcn.h>
return false;
}
+ if ([[parameters objectForKey:@BREAKPAD_IN_PROCESS] boolValue])
+ return InitializeInProcess(parameters);
+ else
+ return InitializeOutOfProcess(parameters);
+}
+
+//=============================================================================
+bool Breakpad::InitializeInProcess(NSDictionary* parameters) {
+ handler_ =
+ new (gBreakpadAllocator->Allocate(
+ sizeof(google_breakpad::ExceptionHandler)))
+ google_breakpad::ExceptionHandler(
+ config_params_->GetValueForKey(BREAKPAD_DUMP_DIRECTORY),
+ 0, &HandleMinidumpCallback, this, true, 0);
+ return true;
+}
+
+//=============================================================================
+bool Breakpad::InitializeOutOfProcess(NSDictionary* parameters) {
// Get path to Inspector executable.
NSString *inspectorPathString = KeyValue(@BREAKPAD_INSPECTOR_LOCATION);
}
//=============================================================================
+bool Breakpad::HandleMinidump(const char *dump_dir, const char *minidump_id) {
+ google_breakpad::ConfigFile config_file;
+ config_file.WriteFile(dump_dir, config_params_, dump_dir, minidump_id);
+ google_breakpad::LaunchReporter(
+ config_params_->GetValueForKey(BREAKPAD_REPORTER_EXE_LOCATION),
+ config_file.GetFilePath());
+ return true;
+}
+
+//=============================================================================
//=============================================================================
#pragma mark -