From 09b056975dacd1f0f815ad820b6dc9913b0118a3 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 23 Jun 2020 18:55:43 -0400 Subject: fix pointer style to match the style guide We do this in a lot of places, but we're inconsistent. Normalize the code to the Google C++ style guide. Change-Id: Ic2aceab661ce8f6b993dda21b1cdf5d2198dcbbf Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2262932 Reviewed-by: Sterling Augustine Reviewed-by: Mark Mentovai --- src/client/ios/Breakpad.h | 46 ++-- src/client/ios/Breakpad.mm | 300 ++++++++++----------- src/client/ios/exception_handler_no_mach.cc | 6 +- src/client/ios/exception_handler_no_mach.h | 42 +-- .../ios/handler/ios_exception_minidump_generator.h | 14 +- .../handler/ios_exception_minidump_generator.mm | 20 +- 6 files changed, 214 insertions(+), 214 deletions(-) (limited to 'src/client/ios') diff --git a/src/client/ios/Breakpad.h b/src/client/ios/Breakpad.h index fa790f77..6c9b8bd6 100644 --- a/src/client/ios/Breakpad.h +++ b/src/client/ios/Breakpad.h @@ -37,7 +37,7 @@ // // These files can then be uploaded to a server. -typedef void *BreakpadRef; +typedef void* BreakpadRef; #ifdef __cplusplus extern "C" { @@ -60,15 +60,15 @@ extern "C" { typedef bool (*BreakpadFilterCallback)(int exception_type, int exception_code, mach_port_t crashing_thread, - void *context); + void* context); // Optional user-defined function that will be called after a network upload // of a crash report. // |report_id| will be the id returned by the server, or "ERR" if an error // occurred. // |error| will contain the error, or nil if no error occured. -typedef void (*BreakpadUploadCompletionCallback)(NSString *report_id, - NSError *error); +typedef void (*BreakpadUploadCompletionCallback)(NSString* report_id, + NSError* error); // Create a new BreakpadRef object and install it as an exception // handler. The |parameters| will typically be the contents of your @@ -163,7 +163,7 @@ typedef void (*BreakpadUploadCompletionCallback)(NSString *report_id, // internal values. // Returns a new BreakpadRef object on success, NULL otherwise. -BreakpadRef BreakpadCreate(NSDictionary *parameters); +BreakpadRef BreakpadCreate(NSDictionary* parameters); // Uninstall and release the data associated with |ref|. void BreakpadRelease(BreakpadRef ref); @@ -187,20 +187,20 @@ void BreakpadRelease(BreakpadRef ref); // TODO (nealsid): separate server parameter dictionary from the // dictionary used to configure Breakpad, and document limits for each // independently. -void BreakpadSetKeyValue(BreakpadRef ref, NSString *key, NSString *value); -NSString *BreakpadKeyValue(BreakpadRef ref, NSString *key); -void BreakpadRemoveKeyValue(BreakpadRef ref, NSString *key); +void BreakpadSetKeyValue(BreakpadRef ref, NSString* key, NSString* value); +NSString* BreakpadKeyValue(BreakpadRef ref, NSString* key); +void BreakpadRemoveKeyValue(BreakpadRef ref, NSString* key); // You can use this method to specify parameters that will be uploaded // to the crash server. They will be automatically encoded as // necessary. Note that as mentioned above there are limits on both // the number of keys and their length. -void BreakpadAddUploadParameter(BreakpadRef ref, NSString *key, - NSString *value); +void BreakpadAddUploadParameter(BreakpadRef ref, NSString* key, + NSString* value); // This method will remove a previously-added parameter from the // upload parameter set. -void BreakpadRemoveUploadParameter(BreakpadRef ref, NSString *key); +void BreakpadRemoveUploadParameter(BreakpadRef ref, NSString* key); // Method to handle uploading data to the server @@ -208,10 +208,10 @@ void BreakpadRemoveUploadParameter(BreakpadRef ref, NSString *key); int BreakpadGetCrashReportCount(BreakpadRef ref); // Returns the next upload configuration. The report file is deleted. -NSDictionary *BreakpadGetNextReportConfiguration(BreakpadRef ref); +NSDictionary* BreakpadGetNextReportConfiguration(BreakpadRef ref); // Returns the date of the most recent crash report. -NSDate *BreakpadGetDateOfMostRecentCrashReport(BreakpadRef ref); +NSDate* BreakpadGetDateOfMostRecentCrashReport(BreakpadRef ref); // Upload next report to the server. void BreakpadUploadNextReport(BreakpadRef ref); @@ -220,7 +220,7 @@ void BreakpadUploadNextReport(BreakpadRef ref); // |server_parameters| is additional server parameters to send. void BreakpadUploadNextReportWithParameters( BreakpadRef ref, - NSDictionary *server_parameters, + NSDictionary* server_parameters, BreakpadUploadCompletionCallback callback); // Upload a report to the server. @@ -228,8 +228,8 @@ void BreakpadUploadNextReportWithParameters( // |configuration| is the configuration of the breakpad report to send. void BreakpadUploadReportWithParametersAndConfiguration( BreakpadRef ref, - NSDictionary *server_parameters, - NSDictionary *configuration, + NSDictionary* server_parameters, + NSDictionary* configuration, BreakpadUploadCompletionCallback callback); // Handles the network response of a breakpad upload. This function is needed if @@ -239,21 +239,21 @@ void BreakpadUploadReportWithParametersAndConfiguration( // BreakpadUploadReportWithParametersAndConfiguration. // |data| and |error| contain the network response. void BreakpadHandleNetworkResponse(BreakpadRef ref, - NSDictionary *configuration, - NSData *data, - NSError *error); + NSDictionary* configuration, + NSData* data, + NSError* error); // Upload a file to the server. |data| is the content of the file to sent. // |server_parameters| is additional server parameters to send. -void BreakpadUploadData(BreakpadRef ref, NSData *data, NSString *name, - NSDictionary *server_parameters); +void BreakpadUploadData(BreakpadRef ref, NSData* data, NSString* name, + NSDictionary* server_parameters); // Generate a breakpad minidump and configuration file in the dump directory. // The report will be available for uploading. The paths of the created files // are returned in the dictionary. |server_parameters| is additional server // parameters to add in the config file. -NSDictionary *BreakpadGenerateReport(BreakpadRef ref, - NSDictionary *server_parameters); +NSDictionary* BreakpadGenerateReport(BreakpadRef ref, + NSDictionary* server_parameters); #ifdef __cplusplus } diff --git a/src/client/ios/Breakpad.mm b/src/client/ios/Breakpad.mm index 2b61bbe3..11c51746 100644 --- a/src/client/ios/Breakpad.mm +++ b/src/client/ios/Breakpad.mm @@ -84,9 +84,9 @@ using google_breakpad::LongStringDictionary; // allocation of C++ objects. Note that we don't use operator delete() // but instead call the objects destructor directly: object->~ClassName(); // -ProtectedMemoryAllocator *gMasterAllocator = NULL; -ProtectedMemoryAllocator *gKeyValueAllocator = NULL; -ProtectedMemoryAllocator *gBreakpadAllocator = NULL; +ProtectedMemoryAllocator* gMasterAllocator = NULL; +ProtectedMemoryAllocator* gKeyValueAllocator = NULL; +ProtectedMemoryAllocator* gBreakpadAllocator = NULL; // Mutex for thread-safe access to the key/value dictionary used by breakpad. // It's a global instead of an instance variable of Breakpad @@ -101,8 +101,8 @@ pthread_mutex_t gDictionaryMutex; // Its destructor will first re-protect the memory then release the lock. class ProtectedMemoryLocker { public: - ProtectedMemoryLocker(pthread_mutex_t *mutex, - ProtectedMemoryAllocator *allocator) + ProtectedMemoryLocker(pthread_mutex_t* mutex, + ProtectedMemoryAllocator* allocator) : mutex_(mutex), allocator_(allocator) { // Lock the mutex @@ -127,17 +127,17 @@ class ProtectedMemoryLocker { ProtectedMemoryLocker(const ProtectedMemoryLocker&); ProtectedMemoryLocker& operator=(const ProtectedMemoryLocker&); - pthread_mutex_t *mutex_; - ProtectedMemoryAllocator *allocator_; + pthread_mutex_t* mutex_; + ProtectedMemoryAllocator* allocator_; }; //============================================================================= class Breakpad { public: // factory method - static Breakpad *Create(NSDictionary *parameters) { + static Breakpad* Create(NSDictionary* parameters) { // Allocate from our special allocation pool - Breakpad *breakpad = + Breakpad* breakpad = new (gBreakpadAllocator->Allocate(sizeof(Breakpad))) Breakpad(); @@ -155,62 +155,62 @@ class Breakpad { ~Breakpad(); - void SetKeyValue(NSString *key, NSString *value); - NSString *KeyValue(NSString *key); - void RemoveKeyValue(NSString *key); - NSArray *CrashReportsToUpload(); - NSString *NextCrashReportToUpload(); - NSDictionary *NextCrashReportConfiguration(); - NSDictionary *FixedUpCrashReportConfiguration(NSDictionary *configuration); - NSDate *DateOfMostRecentCrashReport(); - void UploadNextReport(NSDictionary *server_parameters); - void UploadReportWithConfiguration(NSDictionary *configuration, - NSDictionary *server_parameters, + void SetKeyValue(NSString* key, NSString* value); + NSString* KeyValue(NSString* key); + void RemoveKeyValue(NSString* key); + NSArray* CrashReportsToUpload(); + NSString* NextCrashReportToUpload(); + NSDictionary* NextCrashReportConfiguration(); + NSDictionary* FixedUpCrashReportConfiguration(NSDictionary* configuration); + NSDate* DateOfMostRecentCrashReport(); + void UploadNextReport(NSDictionary* server_parameters); + void UploadReportWithConfiguration(NSDictionary* configuration, + NSDictionary* server_parameters, BreakpadUploadCompletionCallback callback); - void UploadData(NSData *data, NSString *name, - NSDictionary *server_parameters); - void HandleNetworkResponse(NSDictionary *configuration, - NSData *data, - NSError *error); - NSDictionary *GenerateReport(NSDictionary *server_parameters); + void UploadData(NSData* data, NSString* name, + NSDictionary* server_parameters); + void HandleNetworkResponse(NSDictionary* configuration, + NSData* data, + NSError* error); + NSDictionary* GenerateReport(NSDictionary* server_parameters); private: Breakpad() : handler_(NULL), config_params_(NULL) {} - bool Initialize(NSDictionary *parameters); + bool Initialize(NSDictionary* parameters); - bool ExtractParameters(NSDictionary *parameters); + bool ExtractParameters(NSDictionary* parameters); // Dispatches to HandleMinidump() - static bool HandleMinidumpCallback(const char *dump_dir, - const char *minidump_id, - void *context, bool succeeded); + static bool HandleMinidumpCallback(const char* dump_dir, + const char* minidump_id, + void* context, bool succeeded); - bool HandleMinidump(const char *dump_dir, - const char *minidump_id); + bool HandleMinidump(const char* dump_dir, + const char* minidump_id); // NSException handler - static void UncaughtExceptionHandler(NSException *exception); + static void UncaughtExceptionHandler(NSException* exception); // Handle an uncaught NSException. - void HandleUncaughtException(NSException *exception); + void HandleUncaughtException(NSException* exception); // 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) + google_breakpad::ExceptionHandler* handler_; // The actual handler (STRONG) - LongStringDictionary *config_params_; // Create parameters (STRONG) + LongStringDictionary* config_params_; // Create parameters (STRONG) ConfigFile config_file_; // A static reference to the current Breakpad instance. Used for handling // NSException. - static Breakpad *current_breakpad_; + static Breakpad* current_breakpad_; }; -Breakpad *Breakpad::current_breakpad_ = NULL; +Breakpad* Breakpad::current_breakpad_ = NULL; #pragma mark - #pragma mark Helper functions @@ -221,14 +221,14 @@ Breakpad *Breakpad::current_breakpad_ = NULL; //============================================================================= static BOOL IsDebuggerActive() { BOOL result = NO; - NSUserDefaults *stdDefaults = [NSUserDefaults standardUserDefaults]; + NSUserDefaults* stdDefaults = [NSUserDefaults standardUserDefaults]; // We check both defaults and the environment variable here BOOL ignoreDebugger = [stdDefaults boolForKey:@IGNORE_DEBUGGER]; if (!ignoreDebugger) { - char *ignoreDebuggerStr = getenv(IGNORE_DEBUGGER); + char* ignoreDebuggerStr = getenv(IGNORE_DEBUGGER); ignoreDebugger = (ignoreDebuggerStr ? strtol(ignoreDebuggerStr, NULL, 10) : 0) != 0; } @@ -240,7 +240,7 @@ static BOOL IsDebuggerActive() { size_t actualSize; if (sysctl(mib, mibSize, NULL, &actualSize, NULL, 0) == 0) { - struct kinfo_proc *info = (struct kinfo_proc *)malloc(actualSize); + struct kinfo_proc* info = (struct kinfo_proc*)malloc(actualSize); if (info) { // This comes from looking at the Darwin xnu Kernel @@ -256,10 +256,10 @@ static BOOL IsDebuggerActive() { } //============================================================================= -bool Breakpad::HandleMinidumpCallback(const char *dump_dir, - const char *minidump_id, - void *context, bool succeeded) { - Breakpad *breakpad = (Breakpad *)context; +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. @@ -270,7 +270,7 @@ bool Breakpad::HandleMinidumpCallback(const char *dump_dir, } //============================================================================= -void Breakpad::UncaughtExceptionHandler(NSException *exception) { +void Breakpad::UncaughtExceptionHandler(NSException* exception) { NSSetUncaughtExceptionHandler(NULL); if (current_breakpad_) { current_breakpad_->HandleUncaughtException(exception); @@ -282,7 +282,7 @@ void Breakpad::UncaughtExceptionHandler(NSException *exception) { #pragma mark - //============================================================================= -bool Breakpad::Initialize(NSDictionary *parameters) { +bool Breakpad::Initialize(NSDictionary* parameters) { // Initialize current_breakpad_ = this; config_params_ = NULL; @@ -325,21 +325,21 @@ Breakpad::~Breakpad() { } //============================================================================= -bool Breakpad::ExtractParameters(NSDictionary *parameters) { - NSString *serverType = [parameters objectForKey:@BREAKPAD_SERVER_TYPE]; - NSString *display = [parameters objectForKey:@BREAKPAD_PRODUCT_DISPLAY]; - NSString *product = [parameters objectForKey:@BREAKPAD_PRODUCT]; - NSString *version = [parameters objectForKey:@BREAKPAD_VERSION]; - NSString *urlStr = [parameters objectForKey:@BREAKPAD_URL]; - NSString *vendor = +bool Breakpad::ExtractParameters(NSDictionary* parameters) { + NSString* serverType = [parameters objectForKey:@BREAKPAD_SERVER_TYPE]; + NSString* display = [parameters objectForKey:@BREAKPAD_PRODUCT_DISPLAY]; + NSString* product = [parameters objectForKey:@BREAKPAD_PRODUCT]; + NSString* version = [parameters objectForKey:@BREAKPAD_VERSION]; + NSString* urlStr = [parameters objectForKey:@BREAKPAD_URL]; + NSString* vendor = [parameters objectForKey:@BREAKPAD_VENDOR]; // We check both parameters and the environment variable here. - char *envVarDumpSubdirectory = getenv(BREAKPAD_DUMP_DIRECTORY); - NSString *dumpSubdirectory = envVarDumpSubdirectory ? + char* envVarDumpSubdirectory = getenv(BREAKPAD_DUMP_DIRECTORY); + NSString* dumpSubdirectory = envVarDumpSubdirectory ? [NSString stringWithUTF8String:envVarDumpSubdirectory] : [parameters objectForKey:@BREAKPAD_DUMP_DIRECTORY]; - NSDictionary *serverParameters = + NSDictionary* serverParameters = [parameters objectForKey:@BREAKPAD_SERVER_PARAMETER_DICT]; if (!product) @@ -360,7 +360,7 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) { } if (!dumpSubdirectory) { - NSString *cachePath = + NSString* cachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) @@ -388,7 +388,7 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) { new (gKeyValueAllocator->Allocate(sizeof(LongStringDictionary))) LongStringDictionary(); - LongStringDictionary &dictionary = *config_params_; + LongStringDictionary& dictionary = *config_params_; dictionary.SetKeyValue(BREAKPAD_SERVER_TYPE, [serverType UTF8String]); dictionary.SetKeyValue(BREAKPAD_PRODUCT_DISPLAY, [display UTF8String]); @@ -407,8 +407,8 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) { if (serverParameters) { // For each key-value pair, call BreakpadAddUploadParameter() - NSEnumerator *keyEnumerator = [serverParameters keyEnumerator]; - NSString *aParameter; + NSEnumerator* keyEnumerator = [serverParameters keyEnumerator]; + NSString* aParameter; while ((aParameter = [keyEnumerator nextObject])) { BreakpadAddUploadParameter(this, aParameter, [serverParameters objectForKey:aParameter]); @@ -418,7 +418,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. if (!config_params_ || !key) return; @@ -427,7 +427,7 @@ void Breakpad::SetKeyValue(NSString *key, NSString *value) { } //============================================================================= -NSString *Breakpad::KeyValue(NSString *key) { +NSString* Breakpad::KeyValue(NSString* key) { if (!config_params_ || !key) return nil; @@ -436,44 +436,44 @@ NSString *Breakpad::KeyValue(NSString *key) { } //============================================================================= -void Breakpad::RemoveKeyValue(NSString *key) { +void Breakpad::RemoveKeyValue(NSString* key) { if (!config_params_ || !key) return; config_params_->RemoveKey([key UTF8String]); } //============================================================================= -NSArray *Breakpad::CrashReportsToUpload() { - NSString *directory = KeyValue(@BREAKPAD_DUMP_DIRECTORY); +NSArray* Breakpad::CrashReportsToUpload() { + NSString* directory = KeyValue(@BREAKPAD_DUMP_DIRECTORY); if (!directory) return nil; - NSArray *dirContents = [[NSFileManager defaultManager] + NSArray* dirContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:directory error:nil]; - NSArray *configs = [dirContents filteredArrayUsingPredicate:[NSPredicate + NSArray* configs = [dirContents filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self BEGINSWITH 'Config-'"]]; return configs; } //============================================================================= -NSString *Breakpad::NextCrashReportToUpload() { - NSString *directory = KeyValue(@BREAKPAD_DUMP_DIRECTORY); +NSString* Breakpad::NextCrashReportToUpload() { + NSString* directory = KeyValue(@BREAKPAD_DUMP_DIRECTORY); if (!directory) return nil; - NSString *config = [CrashReportsToUpload() lastObject]; + NSString* config = [CrashReportsToUpload() lastObject]; if (!config) return nil; return [NSString stringWithFormat:@"%@/%@", directory, config]; } //============================================================================= -NSDictionary *Breakpad::NextCrashReportConfiguration() { - NSDictionary *configuration = [Uploader readConfigurationDataFromFile:NextCrashReportToUpload()]; +NSDictionary* Breakpad::NextCrashReportConfiguration() { + NSDictionary* configuration = [Uploader readConfigurationDataFromFile:NextCrashReportToUpload()]; return FixedUpCrashReportConfiguration(configuration); } //============================================================================= -NSDictionary *Breakpad::FixedUpCrashReportConfiguration(NSDictionary *configuration) { - NSMutableDictionary *fixedConfiguration = [[configuration mutableCopy] autorelease]; +NSDictionary* Breakpad::FixedUpCrashReportConfiguration(NSDictionary* configuration) { + NSMutableDictionary* fixedConfiguration = [[configuration mutableCopy] autorelease]; // kReporterMinidumpDirectoryKey can become stale because the app's data container path includes // an UUID that is not guaranteed to stay the same over time. [fixedConfiguration setObject:KeyValue(@BREAKPAD_DUMP_DIRECTORY) @@ -482,19 +482,19 @@ NSDictionary *Breakpad::FixedUpCrashReportConfiguration(NSDictionary *configurat } //============================================================================= -NSDate *Breakpad::DateOfMostRecentCrashReport() { - NSString *directory = KeyValue(@BREAKPAD_DUMP_DIRECTORY); +NSDate* Breakpad::DateOfMostRecentCrashReport() { + NSString* directory = KeyValue(@BREAKPAD_DUMP_DIRECTORY); if (!directory) { return nil; } - NSFileManager *fileManager = [NSFileManager defaultManager]; - NSArray *dirContents = [fileManager contentsOfDirectoryAtPath:directory error:nil]; - NSArray *dumps = [dirContents filteredArrayUsingPredicate:[NSPredicate + NSFileManager* fileManager = [NSFileManager defaultManager]; + NSArray* dirContents = [fileManager contentsOfDirectoryAtPath:directory error:nil]; + NSArray* dumps = [dirContents filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self ENDSWITH '.dmp'"]]; - NSDate *mostRecentCrashReportDate = nil; - for (NSString *dump in dumps) { - NSString *filePath = [directory stringByAppendingPathComponent:dump]; - NSDate *crashReportDate = + NSDate* mostRecentCrashReportDate = nil; + for (NSString* dump in dumps) { + NSString* filePath = [directory stringByAppendingPathComponent:dump]; + NSDate* crashReportDate = [[fileManager attributesOfItemAtPath:filePath error:nil] fileCreationDate]; if (!mostRecentCrashReportDate) { mostRecentCrashReportDate = crashReportDate; @@ -506,29 +506,29 @@ NSDate *Breakpad::DateOfMostRecentCrashReport() { } //============================================================================= -void Breakpad::HandleNetworkResponse(NSDictionary *configuration, - NSData *data, - NSError *error) { - Uploader *uploader = [[[Uploader alloc] +void Breakpad::HandleNetworkResponse(NSDictionary* configuration, + NSData* data, + NSError* error) { + Uploader* uploader = [[[Uploader alloc] initWithConfig:configuration] autorelease]; [uploader handleNetworkResponse:data withError:error]; } //============================================================================= void Breakpad::UploadReportWithConfiguration( - NSDictionary *configuration, - NSDictionary *server_parameters, + NSDictionary* configuration, + NSDictionary* server_parameters, BreakpadUploadCompletionCallback callback) { - Uploader *uploader = [[[Uploader alloc] + Uploader* uploader = [[[Uploader alloc] initWithConfig:configuration] autorelease]; if (!uploader) return; - for (NSString *key in server_parameters) { + for (NSString* key in server_parameters) { [uploader addServerParameter:[server_parameters objectForKey:key] forKey:key]; } if (callback) { - [uploader setUploadCompletionBlock:^(NSString *report_id, NSError *error) { + [uploader setUploadCompletionBlock:^(NSString* report_id, NSError* error) { dispatch_async(dispatch_get_main_queue(), ^{ callback(report_id, error); }); @@ -538,8 +538,8 @@ void Breakpad::UploadReportWithConfiguration( } //============================================================================= -void Breakpad::UploadNextReport(NSDictionary *server_parameters) { - NSDictionary *configuration = NextCrashReportConfiguration(); +void Breakpad::UploadNextReport(NSDictionary* server_parameters) { + NSDictionary* configuration = NextCrashReportConfiguration(); if (configuration) { return UploadReportWithConfiguration(configuration, server_parameters, nullptr); @@ -547,19 +547,19 @@ void Breakpad::UploadNextReport(NSDictionary *server_parameters) { } //============================================================================= -void Breakpad::UploadData(NSData *data, NSString *name, - NSDictionary *server_parameters) { - NSMutableDictionary *config = [NSMutableDictionary dictionary]; +void Breakpad::UploadData(NSData* data, NSString* name, + NSDictionary* server_parameters) { + NSMutableDictionary* config = [NSMutableDictionary dictionary]; LongStringDictionary::Iterator it(*config_params_); - while (const LongStringDictionary::Entry *next = it.Next()) { + while (const LongStringDictionary::Entry* next = it.Next()) { [config setValue:[NSString stringWithUTF8String:next->value] forKey:[NSString stringWithUTF8String:next->key]]; } - Uploader *uploader = + Uploader* uploader = [[[Uploader alloc] initWithConfig:config] autorelease]; - for (NSString *key in server_parameters) { + for (NSString* key in server_parameters) { [uploader addServerParameter:[server_parameters objectForKey:key] forKey:key]; } @@ -567,11 +567,11 @@ void Breakpad::UploadData(NSData *data, NSString *name, } //============================================================================= -NSDictionary *Breakpad::GenerateReport(NSDictionary *server_parameters) { - NSString *dumpDirAsNSString = KeyValue(@BREAKPAD_DUMP_DIRECTORY); +NSDictionary* Breakpad::GenerateReport(NSDictionary* server_parameters) { + NSString* dumpDirAsNSString = KeyValue(@BREAKPAD_DUMP_DIRECTORY); if (!dumpDirAsNSString) return nil; - const char *dumpDir = [dumpDirAsNSString UTF8String]; + const char* dumpDir = [dumpDirAsNSString UTF8String]; google_breakpad::MinidumpGenerator generator(mach_task_self(), MACH_PORT_NULL); @@ -582,7 +582,7 @@ NSDictionary *Breakpad::GenerateReport(NSDictionary *server_parameters) { return nil; LongStringDictionary params = *config_params_; - for (NSString *key in server_parameters) { + for (NSString* key in server_parameters) { params.SetKeyValue([key UTF8String], [[server_parameters objectForKey:key] UTF8String]); } @@ -590,8 +590,8 @@ NSDictionary *Breakpad::GenerateReport(NSDictionary *server_parameters) { config_file.WriteFile(dumpDir, ¶ms, dumpDir, dumpId.c_str()); // Handle results. - NSMutableDictionary *result = [NSMutableDictionary dictionary]; - NSString *dumpFullPath = [NSString stringWithUTF8String:dumpFilename.c_str()]; + NSMutableDictionary* result = [NSMutableDictionary dictionary]; + NSString* dumpFullPath = [NSString stringWithUTF8String:dumpFilename.c_str()]; [result setValue:dumpFullPath forKey:@BREAKPAD_OUTPUT_DUMP_FILE]; [result setValue:[NSString stringWithUTF8String:config_file.GetFilePath()] @@ -600,8 +600,8 @@ NSDictionary *Breakpad::GenerateReport(NSDictionary *server_parameters) { } //============================================================================= -bool Breakpad::HandleMinidump(const char *dump_dir, - const char *minidump_id) { +bool Breakpad::HandleMinidump(const char* dump_dir, + const char* minidump_id) { config_file_.WriteFile(dump_dir, config_params_, dump_dir, @@ -613,7 +613,7 @@ bool Breakpad::HandleMinidump(const char *dump_dir, } //============================================================================= -void Breakpad::HandleUncaughtException(NSException *exception) { +void Breakpad::HandleUncaughtException(NSException* exception) { // Generate the minidump. google_breakpad::IosExceptionMinidumpGenerator generator(exception); const std::string minidump_path = @@ -650,7 +650,7 @@ void Breakpad::HandleUncaughtException(NSException *exception) { #pragma mark Public API //============================================================================= -BreakpadRef BreakpadCreate(NSDictionary *parameters) { +BreakpadRef BreakpadCreate(NSDictionary* parameters) { try { // This is confusing. Our two main allocators for breakpad memory are: // - gKeyValueAllocator for the key/value memory @@ -690,8 +690,8 @@ BreakpadRef BreakpadCreate(NSDictionary *parameters) { ProtectedMemoryAllocator(breakpad_pool_size); // Stack-based autorelease pool for Breakpad::Create() obj-c code. - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - Breakpad *breakpad = Breakpad::Create(parameters); + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + Breakpad* breakpad = Breakpad::Create(parameters); if (breakpad) { // Make read-only to protect against memory smashers @@ -731,7 +731,7 @@ BreakpadRef BreakpadCreate(NSDictionary *parameters) { //============================================================================= void BreakpadRelease(BreakpadRef ref) { try { - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (gMasterAllocator) { gMasterAllocator->Unprotect(); @@ -764,10 +764,10 @@ void BreakpadRelease(BreakpadRef ref) { } //============================================================================= -void BreakpadSetKeyValue(BreakpadRef ref, NSString *key, NSString *value) { +void BreakpadSetKeyValue(BreakpadRef ref, NSString* key, NSString* value) { try { // Not called at exception time - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad && key && gKeyValueAllocator) { ProtectedMemoryLocker locker(&gDictionaryMutex, gKeyValueAllocator); @@ -780,20 +780,20 @@ void BreakpadSetKeyValue(BreakpadRef ref, NSString *key, NSString *value) { } void BreakpadAddUploadParameter(BreakpadRef ref, - NSString *key, - NSString *value) { + NSString* key, + NSString* value) { // The only difference, internally, between an upload parameter and // a key value one that is set with BreakpadSetKeyValue is that we // prepend the keyname with a special prefix. This informs the // crash sender that the parameter should be sent along with the // POST of the crash dump upload. try { - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad && key && gKeyValueAllocator) { ProtectedMemoryLocker locker(&gDictionaryMutex, gKeyValueAllocator); - NSString *prefixedKey = [@BREAKPAD_SERVER_PARAMETER_PREFIX + NSString* prefixedKey = [@BREAKPAD_SERVER_PARAMETER_PREFIX stringByAppendingString:key]; breakpad->SetKeyValue(prefixedKey, value); } @@ -803,15 +803,15 @@ void BreakpadAddUploadParameter(BreakpadRef ref, } void BreakpadRemoveUploadParameter(BreakpadRef ref, - NSString *key) { + NSString* key) { try { // Not called at exception time - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad && key && gKeyValueAllocator) { ProtectedMemoryLocker locker(&gDictionaryMutex, gKeyValueAllocator); - NSString *prefixedKey = [NSString stringWithFormat:@"%@%@", + NSString* prefixedKey = [NSString stringWithFormat:@"%@%@", @BREAKPAD_SERVER_PARAMETER_PREFIX, key]; breakpad->RemoveKeyValue(prefixedKey); } @@ -820,12 +820,12 @@ void BreakpadRemoveUploadParameter(BreakpadRef ref, } } //============================================================================= -NSString *BreakpadKeyValue(BreakpadRef ref, NSString *key) { - NSString *value = nil; +NSString* BreakpadKeyValue(BreakpadRef ref, NSString* key) { + NSString* value = nil; try { // Not called at exception time - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (!breakpad || !key || !gKeyValueAllocator) return nil; @@ -841,10 +841,10 @@ NSString *BreakpadKeyValue(BreakpadRef ref, NSString *key) { } //============================================================================= -void BreakpadRemoveKeyValue(BreakpadRef ref, NSString *key) { +void BreakpadRemoveKeyValue(BreakpadRef ref, NSString* key) { try { // Not called at exception time - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad && key && gKeyValueAllocator) { ProtectedMemoryLocker locker(&gDictionaryMutex, gKeyValueAllocator); @@ -860,7 +860,7 @@ void BreakpadRemoveKeyValue(BreakpadRef ref, NSString *key) { int BreakpadGetCrashReportCount(BreakpadRef ref) { try { // Not called at exception time - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad) { return static_cast([breakpad->CrashReportsToUpload() count]); @@ -877,9 +877,9 @@ void BreakpadUploadNextReport(BreakpadRef ref) { } //============================================================================= -NSDictionary *BreakpadGetNextReportConfiguration(BreakpadRef ref) { +NSDictionary* BreakpadGetNextReportConfiguration(BreakpadRef ref) { try { - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad) return breakpad->NextCrashReportConfiguration(); } catch(...) { // don't let exceptions leave this C API @@ -889,9 +889,9 @@ NSDictionary *BreakpadGetNextReportConfiguration(BreakpadRef ref) { } //============================================================================= -NSDate *BreakpadGetDateOfMostRecentCrashReport(BreakpadRef ref) { +NSDate* BreakpadGetDateOfMostRecentCrashReport(BreakpadRef ref) { try { - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad) { return breakpad->DateOfMostRecentCrashReport(); } @@ -904,11 +904,11 @@ NSDate *BreakpadGetDateOfMostRecentCrashReport(BreakpadRef ref) { //============================================================================= void BreakpadUploadReportWithParametersAndConfiguration( BreakpadRef ref, - NSDictionary *server_parameters, - NSDictionary *configuration, + NSDictionary* server_parameters, + NSDictionary* configuration, BreakpadUploadCompletionCallback callback) { try { - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (!breakpad || !configuration) return; breakpad->UploadReportWithConfiguration(configuration, server_parameters, @@ -922,13 +922,13 @@ void BreakpadUploadReportWithParametersAndConfiguration( //============================================================================= void BreakpadUploadNextReportWithParameters( BreakpadRef ref, - NSDictionary *server_parameters, + NSDictionary* server_parameters, BreakpadUploadCompletionCallback callback) { try { - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (!breakpad) return; - NSDictionary *configuration = breakpad->NextCrashReportConfiguration(); + NSDictionary* configuration = breakpad->NextCrashReportConfiguration(); if (!configuration) return; return BreakpadUploadReportWithParametersAndConfiguration( @@ -939,12 +939,12 @@ void BreakpadUploadNextReportWithParameters( } void BreakpadHandleNetworkResponse(BreakpadRef ref, - NSDictionary *configuration, - NSData *data, - NSError *error) { + NSDictionary* configuration, + NSData* data, + NSError* error) { try { // Not called at exception time - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad && configuration) breakpad->HandleNetworkResponse(configuration,data, error); @@ -954,11 +954,11 @@ void BreakpadHandleNetworkResponse(BreakpadRef ref, } //============================================================================= -void BreakpadUploadData(BreakpadRef ref, NSData *data, NSString *name, - NSDictionary *server_parameters) { +void BreakpadUploadData(BreakpadRef ref, NSData* data, NSString* name, + NSDictionary* server_parameters) { try { // Not called at exception time - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad) { breakpad->UploadData(data, name, server_parameters); @@ -969,11 +969,11 @@ void BreakpadUploadData(BreakpadRef ref, NSData *data, NSString *name, } //============================================================================= -NSDictionary *BreakpadGenerateReport(BreakpadRef ref, - NSDictionary *server_parameters) { +NSDictionary* BreakpadGenerateReport(BreakpadRef ref, + NSDictionary* server_parameters) { try { // Not called at exception time - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad) { return breakpad->GenerateReport(server_parameters); diff --git a/src/client/ios/exception_handler_no_mach.cc b/src/client/ios/exception_handler_no_mach.cc index 7fcf2d83..cb26449d 100644 --- a/src/client/ios/exception_handler_no_mach.cc +++ b/src/client/ios/exception_handler_no_mach.cc @@ -47,7 +47,7 @@ // for more details. #if USE_PROTECTED_ALLOCATIONS #include "client/mac/handler/protected_memory_allocator.h" - extern ProtectedMemoryAllocator *gBreakpadAllocator; + extern ProtectedMemoryAllocator* gBreakpadAllocator; #endif namespace google_breakpad { @@ -72,10 +72,10 @@ static union { char protected_buffer[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); #endif // defined PAGE_MAX_SIZE #endif // USE_PROTECTED_ALLOCATIONS - google_breakpad::ExceptionHandler *handler; + google_breakpad::ExceptionHandler* handler; } gProtectedData; -ExceptionHandler::ExceptionHandler(const string &dump_path, +ExceptionHandler::ExceptionHandler(const string& dump_path, FilterCallback filter, MinidumpCallback callback, void* callback_context, diff --git a/src/client/ios/exception_handler_no_mach.h b/src/client/ios/exception_handler_no_mach.h index 6d99565b..ec598dcf 100644 --- a/src/client/ios/exception_handler_no_mach.h +++ b/src/client/ios/exception_handler_no_mach.h @@ -53,7 +53,7 @@ class ExceptionHandler { // attempting to write a minidump. If a FilterCallback returns false, Breakpad // will immediately report the exception as unhandled without writing a // minidump, allowing another handler the opportunity to handle it. - typedef bool (*FilterCallback)(void *context); + typedef bool (*FilterCallback)(void* context); // A callback function to run after the minidump has been written. // |minidump_id| is a unique id for the dump, so the minidump @@ -63,18 +63,18 @@ class ExceptionHandler { // Return true if the exception was fully handled and breakpad should exit. // Return false to allow any other exception handlers to process the // exception. - typedef bool (*MinidumpCallback)(const char *dump_dir, - const char *minidump_id, - void *context, bool succeeded); + typedef bool (*MinidumpCallback)(const char* dump_dir, + const char* minidump_id, + void* context, bool succeeded); // A callback function which will be called directly if an exception occurs. // This bypasses the minidump file writing and simply gives the client // the exception information. - typedef bool (*DirectCallback)( void *context, - int exception_type, - int exception_code, - int exception_subcode, - mach_port_t thread_name); + typedef bool (*DirectCallback)(void* context, + int exception_type, + int exception_code, + int exception_subcode, + mach_port_t thread_name); // Creates a new ExceptionHandler instance to handle writing minidumps. // Minidump files will be written to dump_path, and the optional callback @@ -84,22 +84,22 @@ class ExceptionHandler { // be written when WriteMinidump is called. // If port_name is non-NULL, attempt to perform out-of-process dump generation // If port_name is NULL, in-process dump generation will be used. - ExceptionHandler(const string &dump_path, + ExceptionHandler(const string& dump_path, FilterCallback filter, MinidumpCallback callback, - void *callback_context, bool install_handler, - const char *port_name); + void* callback_context, bool install_handler, + const char* port_name); // A special constructor if we want to bypass minidump writing and // simply get a callback with the exception information. ExceptionHandler(DirectCallback callback, - void *callback_context, + void* callback_context, bool install_handler); ~ExceptionHandler(); // Get and set the minidump path. string dump_path() const { return dump_path_; } - void set_dump_path(const string &dump_path) { + void set_dump_path(const string& dump_path) { dump_path_ = dump_path; dump_path_c_ = dump_path_.c_str(); UpdateNextID(); // Necessary to put dump_path_ in next_minidump_path_. @@ -126,7 +126,7 @@ class ExceptionHandler { bool WriteMinidumpWithException(int exception_type, int exception_code, int exception_subcode, - breakpad_ucontext_t *task_context, + breakpad_ucontext_t* task_context, mach_port_t thread_name, bool exit_after_write, bool report_current_thread); @@ -135,8 +135,8 @@ class ExceptionHandler { static void SignalHandler(int sig, siginfo_t* info, void* uc); // disallow copy ctor and operator= - explicit ExceptionHandler(const ExceptionHandler &); - void operator=(const ExceptionHandler &); + explicit ExceptionHandler(const ExceptionHandler&); + void operator=(const ExceptionHandler&); // Generates a new ID and stores it in next_minidump_id_, and stores the // path of the next minidump to be written in next_minidump_path_. @@ -152,15 +152,15 @@ class ExceptionHandler { string next_minidump_path_; // Pointers to the UTF-8 versions of above - const char *dump_path_c_; - const char *next_minidump_id_c_; - const char *next_minidump_path_c_; + const char* dump_path_c_; + const char* next_minidump_id_c_; + const char* next_minidump_path_c_; // The callback function and pointer to be passed back after the minidump // has been written FilterCallback filter_; MinidumpCallback callback_; - void *callback_context_; + void* callback_context_; // The callback function to be passed back when we don't want a minidump // file to be written diff --git a/src/client/ios/handler/ios_exception_minidump_generator.h b/src/client/ios/handler/ios_exception_minidump_generator.h index 21133e63..e48444a7 100644 --- a/src/client/ios/handler/ios_exception_minidump_generator.h +++ b/src/client/ios/handler/ios_exception_minidump_generator.h @@ -41,12 +41,12 @@ namespace google_breakpad { class IosExceptionMinidumpGenerator : public MinidumpGenerator { public: - explicit IosExceptionMinidumpGenerator(NSException *exception); + explicit IosExceptionMinidumpGenerator(NSException* exception); virtual ~IosExceptionMinidumpGenerator(); protected: - virtual bool WriteExceptionStream(MDRawDirectory *exception_stream); - virtual bool WriteThreadStream(mach_port_t thread_id, MDRawThread *thread); + virtual bool WriteExceptionStream(MDRawDirectory* exception_stream); + virtual bool WriteThreadStream(mach_port_t thread_id, MDRawThread* thread); private: @@ -57,16 +57,16 @@ class IosExceptionMinidumpGenerator : public MinidumpGenerator { uintptr_t GetLRFromException(); // Write a virtual thread context for the crashing site. - bool WriteCrashingContext(MDLocationDescriptor *register_location); + bool WriteCrashingContext(MDLocationDescriptor* register_location); // Per-CPU implementations of the above method. #ifdef HAS_ARM_SUPPORT - bool WriteCrashingContextARM(MDLocationDescriptor *register_location); + bool WriteCrashingContextARM(MDLocationDescriptor* register_location); #endif #ifdef HAS_ARM64_SUPPORT - bool WriteCrashingContextARM64(MDLocationDescriptor *register_location); + bool WriteCrashingContextARM64(MDLocationDescriptor* register_location); #endif - NSArray *return_addresses_; + NSArray* return_addresses_; }; } // namespace google_breakpad diff --git a/src/client/ios/handler/ios_exception_minidump_generator.mm b/src/client/ios/handler/ios_exception_minidump_generator.mm index f57bdf21..2a5d76d7 100644 --- a/src/client/ios/handler/ios_exception_minidump_generator.mm +++ b/src/client/ios/handler/ios_exception_minidump_generator.mm @@ -52,7 +52,7 @@ const uintptr_t kExpectedFinalSp = 0; // Append the given value to the sp position of the stack represented // by memory. -void AppendToMemory(uint8_t *memory, uintptr_t sp, uintptr_t data) { +void AppendToMemory(uint8_t* memory, uintptr_t sp, uintptr_t data) { memcpy(memory + sp, &data, sizeof(data)); } #endif @@ -62,7 +62,7 @@ void AppendToMemory(uint8_t *memory, uintptr_t sp, uintptr_t data) { namespace google_breakpad { IosExceptionMinidumpGenerator::IosExceptionMinidumpGenerator( - NSException *exception) + NSException* exception) : MinidumpGenerator(mach_task_self(), 0) { return_addresses_ = [[exception callStackReturnAddresses] retain]; SetExceptionInformation(kExceptionType, @@ -76,7 +76,7 @@ IosExceptionMinidumpGenerator::~IosExceptionMinidumpGenerator() { } bool IosExceptionMinidumpGenerator::WriteCrashingContext( - MDLocationDescriptor *register_location) { + MDLocationDescriptor* register_location) { #ifdef HAS_ARM_SUPPORT return WriteCrashingContextARM(register_location); #elif defined(HAS_ARM64_SUPPORT) @@ -89,12 +89,12 @@ bool IosExceptionMinidumpGenerator::WriteCrashingContext( #ifdef HAS_ARM_SUPPORT bool IosExceptionMinidumpGenerator::WriteCrashingContextARM( - MDLocationDescriptor *register_location) { + MDLocationDescriptor* register_location) { TypedMDRVA context(&writer_); if (!context.Allocate()) return false; *register_location = context.location(); - MDRawContextARM *context_ptr = context.get(); + MDRawContextARM* context_ptr = context.get(); memset(context_ptr, 0, sizeof(MDRawContextARM)); context_ptr->context_flags = MD_CONTEXT_ARM_FULL; context_ptr->iregs[MD_CONTEXT_ARM_REG_IOS_FP] = kExpectedFinalFp; // FP @@ -107,12 +107,12 @@ bool IosExceptionMinidumpGenerator::WriteCrashingContextARM( #ifdef HAS_ARM64_SUPPORT bool IosExceptionMinidumpGenerator::WriteCrashingContextARM64( - MDLocationDescriptor *register_location) { + MDLocationDescriptor* register_location) { TypedMDRVA context(&writer_); if (!context.Allocate()) return false; *register_location = context.location(); - MDRawContextARM64_Old *context_ptr = context.get(); + MDRawContextARM64_Old* context_ptr = context.get(); memset(context_ptr, 0, sizeof(*context_ptr)); context_ptr->context_flags = MD_CONTEXT_ARM64_FULL_OLD; context_ptr->iregs[MD_CONTEXT_ARM64_REG_FP] = kExpectedFinalFp; // FP @@ -132,7 +132,7 @@ uintptr_t IosExceptionMinidumpGenerator::GetLRFromException() { } bool IosExceptionMinidumpGenerator::WriteExceptionStream( - MDRawDirectory *exception_stream) { + MDRawDirectory* exception_stream) { #if defined(HAS_ARM_SUPPORT) || defined(HAS_ARM64_SUPPORT) TypedMDRVA exception(&writer_); @@ -141,7 +141,7 @@ bool IosExceptionMinidumpGenerator::WriteExceptionStream( exception_stream->stream_type = MD_EXCEPTION_STREAM; exception_stream->location = exception.location(); - MDRawExceptionStream *exception_ptr = exception.get(); + MDRawExceptionStream* exception_ptr = exception.get(); exception_ptr->thread_id = pthread_mach_thread_np(pthread_self()); // This naming is confusing, but it is the proper translation from @@ -160,7 +160,7 @@ bool IosExceptionMinidumpGenerator::WriteExceptionStream( } bool IosExceptionMinidumpGenerator::WriteThreadStream(mach_port_t thread_id, - MDRawThread *thread) { + MDRawThread* thread) { #if defined(HAS_ARM_SUPPORT) || defined(HAS_ARM64_SUPPORT) if (pthread_mach_thread_np(pthread_self()) != thread_id) return MinidumpGenerator::WriteThreadStream(thread_id, thread); -- cgit v1.2.1