diff --git a/CrashReporter.xcodeproj/project.pbxproj b/CrashReporter.xcodeproj/project.pbxproj index 9d0044b..21b6b70 100644 --- a/CrashReporter.xcodeproj/project.pbxproj +++ b/CrashReporter.xcodeproj/project.pbxproj @@ -3494,6 +3494,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1.5.1; DEBUG_INFORMATION_FORMAT = dwarf; @@ -3531,6 +3532,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1.5.1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; diff --git a/Other Sources/Crash Demo/main.m b/Other Sources/Crash Demo/main.m index bf6eec4..6a12842 100644 --- a/Other Sources/Crash Demo/main.m +++ b/Other Sources/Crash Demo/main.m @@ -27,7 +27,7 @@ */ #import -#import "CrashReporter.h" +#import "../../Source/CrashReporter.h" #import #import @@ -81,7 +81,7 @@ static void save_crash_report (PLCrashReporter *reporter) { return; } - PLCrashReport *report = [[[PLCrashReport alloc] initWithData: data error: &error] autorelease]; + PLCrashReport *report = [[PLCrashReport alloc] initWithData: data error: &error]; NSString *text = [PLCrashReportTextFormatter stringValueForCrashReport: report withTextFormat: PLCrashReportTextFormatiOS]; NSLog(@"%@", text); @@ -136,7 +136,6 @@ static bool debugger_should_exit (void) { } int main (int argc, char *argv[]) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSError *error = nil; /* @@ -159,9 +158,9 @@ int main (int argc, char *argv[]) { #else PLCrashReporterSignalHandlerTypeBSD; #endif - PLCrashReporterConfig *config = [[[PLCrashReporterConfig alloc] initWithSignalHandlerType: signalHandlerType - symbolicationStrategy: PLCrashReporterSymbolicationStrategyAll] autorelease]; - PLCrashReporter *reporter = [[[PLCrashReporter alloc] initWithConfiguration: config] autorelease]; + PLCrashReporterConfig *config = [[PLCrashReporterConfig alloc] initWithSignalHandlerType: signalHandlerType + symbolicationStrategy: PLCrashReporterSymbolicationStrategyAll]; + PLCrashReporter *reporter = [[PLCrashReporter alloc] initWithConfiguration: config]; /* Save any existing crash report. */ save_crash_report(reporter); @@ -183,9 +182,6 @@ int main (int argc, char *argv[]) { if (![reporter enableCrashReporterAndReturnError: &error]) { NSLog(@"Could not enable crash reporter: %@", error); } - /* Add another stack frame */ stackFrame(); - - [pool release]; } diff --git a/Other Sources/plcrashutil/main.m b/Other Sources/plcrashutil/main.m index 3abe33b..80b3721 100644 --- a/Other Sources/plcrashutil/main.m +++ b/Other Sources/plcrashutil/main.m @@ -117,7 +117,6 @@ static int convert_command (int argc, char *argv[]) { } int main (int argc, char *argv[]) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; int ret = 0; if (argc < 2) { @@ -132,7 +131,5 @@ int main (int argc, char *argv[]) { print_usage(); ret = 1; } - - [pool release]; exit(ret); } diff --git a/Source/PLCrashHostInfo.m b/Source/PLCrashHostInfo.m index 59c9d46..b8bccae 100644 --- a/Source/PLCrashHostInfo.m +++ b/Source/PLCrashHostInfo.m @@ -51,7 +51,7 @@ * fetching the host info, nil will be returned. */ + (instancetype) currentHostInfo { - return [[[self alloc] init] autorelease]; + return [[self alloc] init]; } /* @@ -100,10 +100,9 @@ error: if (val == NULL) { /* This should never fail; if it does, either malloc failed, or 'kern.osrelease' disappeared. */ NSLog(@"Failed to fetch kern.osrelease value %d: %s", errno, strerror(errno)); - [self release]; return nil; } - NSString *osrelease = [[[NSString alloc] initWithBytesNoCopy: val length: strlen(val) encoding: NSUTF8StringEncoding freeWhenDone: YES] autorelease]; + NSString *osrelease = [[NSString alloc] initWithBytesNoCopy: val length: strlen(val) encoding: NSUTF8StringEncoding freeWhenDone: YES]; /* Since this is best-effort, we ignore parse failures; unparseable elements will be defaulted to '0' */ parse_osrelease(osrelease, &_darwinVersion); diff --git a/Source/PLCrashLogWriter.m b/Source/PLCrashLogWriter.m index 5c416ed..119e277 100644 --- a/Source/PLCrashLogWriter.m +++ b/Source/PLCrashLogWriter.m @@ -339,7 +339,7 @@ plcrash_error_t plcrash_log_writer_init (plcrash_log_writer_t *writer, writer->process_info.parent_process_id = pinfo.parentProcessID; /* Retrieve name. This will fail on iOS 9+, where EPERM is returned due to new sandbox constraints. */ - PLCrashProcessInfo *parentInfo = [[[PLCrashProcessInfo alloc] initWithProcessID: pinfo.parentProcessID] autorelease]; + PLCrashProcessInfo *parentInfo = [[PLCrashProcessInfo alloc] initWithProcessID: pinfo.parentProcessID]; if (parentInfo != nil) { if (parentInfo.processName != nil) { writer->process_info.parent_process_name = strdup([parentInfo.processName UTF8String]); diff --git a/Source/PLCrashMachExceptionPort.m b/Source/PLCrashMachExceptionPort.m index 5aa0286..266b998 100644 --- a/Source/PLCrashMachExceptionPort.m +++ b/Source/PLCrashMachExceptionPort.m @@ -76,7 +76,7 @@ return nil; } - return [[[PLCrashMachExceptionPortSet alloc] initWithAsyncSafeRepresentation: states] autorelease]; + return [[PLCrashMachExceptionPortSet alloc] initWithAsyncSafeRepresentation: states]; } /** @@ -110,7 +110,7 @@ return nil; } - return [[[PLCrashMachExceptionPortSet alloc] initWithAsyncSafeRepresentation: states] autorelease]; + return [[PLCrashMachExceptionPortSet alloc] initWithAsyncSafeRepresentation: states]; } /** @@ -151,8 +151,6 @@ if (MACH_PORT_VALID(_port) && (kt = mach_port_mod_refs(mach_task_self(), _port, MACH_PORT_RIGHT_SEND, -1)) != KERN_SUCCESS) { NSLog(@"Unexpected error incrementing mach port reference: %d", kt); } - - [super dealloc]; } /** @@ -189,8 +187,7 @@ } if (ports != NULL) - *ports = [[[PLCrashMachExceptionPortSet alloc] initWithAsyncSafeRepresentation: prev] autorelease]; - + *ports = [[PLCrashMachExceptionPortSet alloc] initWithAsyncSafeRepresentation: prev]; return YES; } @@ -228,7 +225,7 @@ } if (ports != NULL) - *ports = [[[PLCrashMachExceptionPortSet alloc] initWithAsyncSafeRepresentation: prev] autorelease]; + *ports = [[PLCrashMachExceptionPortSet alloc] initWithAsyncSafeRepresentation: prev]; return YES; } diff --git a/Source/PLCrashMachExceptionPortSet.m b/Source/PLCrashMachExceptionPortSet.m index eae9ab2..e771baa 100644 --- a/Source/PLCrashMachExceptionPortSet.m +++ b/Source/PLCrashMachExceptionPortSet.m @@ -58,7 +58,7 @@ return nil; NSAssert([set count] <= EXC_TYPES_COUNT, @"Set size of %lu exceeds EXC_TYPES_COUNT (%lu)", (unsigned long)[set count], (unsigned long)EXC_TYPES_COUNT); - _state_set = [set retain]; + _state_set = set; /* Initialize the async-safe C representation (using borrowed port references) */ plcrash_mach_exception_port_set_t port_set; @@ -94,10 +94,10 @@ kern_return_t kt; NSMutableSet *stateResult = [NSMutableSet setWithCapacity: states->count]; for (mach_msg_type_number_t i = 0; i < states->count; i++) { - PLCrashMachExceptionPort *state = [[[PLCrashMachExceptionPort alloc] initWithServerPort: states->ports[i] + PLCrashMachExceptionPort *state = [[PLCrashMachExceptionPort alloc] initWithServerPort: states->ports[i] mask: states->masks[i] behavior: states->behaviors[i] - flavor: states->flavors[i]] autorelease]; + flavor: states->flavors[i]]; [stateResult addObject: state]; /* The state instance increments the refcount, and we acquire ownership of the caller's refcount */ @@ -106,20 +106,14 @@ } } - _state_set = [stateResult retain]; + _state_set = stateResult; _asyncSafeRepresentation = asyncSafeRepresentation; return self; } -- (void) dealloc { - [_state_set release]; - [super dealloc]; -} - - // from NSFastEnumeration protocol -- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState *) state objects: (id *) stackbuf count: (NSUInteger) len { +- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState *) state objects: (id __unsafe_unretained _Nullable [_Nonnull]) stackbuf count: (NSUInteger) len { return [_state_set countByEnumeratingWithState: state objects: stackbuf count: len]; } diff --git a/Source/PLCrashMachExceptionServer.m b/Source/PLCrashMachExceptionServer.m index 433ff97..82e7513 100644 --- a/Source/PLCrashMachExceptionServer.m +++ b/Source/PLCrashMachExceptionServer.m @@ -283,8 +283,6 @@ struct plcrash_exception_server_context { free(_serverContext); _serverContext = NULL; - - [self release]; return nil; } @@ -294,8 +292,6 @@ struct plcrash_exception_server_context { pthread_mutex_destroy(&_serverContext->lock); free(_serverContext); _serverContext = NULL; - - [self release]; return nil; } @@ -305,8 +301,6 @@ struct plcrash_exception_server_context { kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &_serverContext->server_port); if (kr != KERN_SUCCESS) { plcrash_populate_mach_error(outError, kr, @"Failed to allocate exception server's port"); - - [self release]; return nil; } @@ -316,16 +310,12 @@ struct plcrash_exception_server_context { kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &_serverContext->notify_port); if (kr != KERN_SUCCESS) { plcrash_populate_mach_error(outError, kr, @"Failed to allocate exception server's port"); - - [self release]; return nil; } kr = mach_port_insert_right(mach_task_self(), _serverContext->notify_port, _serverContext->notify_port, MACH_MSG_TYPE_MAKE_SEND); if (kr != KERN_SUCCESS) { plcrash_populate_mach_error(outError, kr, @"Failed to add send right to exception server's port"); - - [self release]; return nil; } @@ -333,8 +323,6 @@ struct plcrash_exception_server_context { kr = mach_port_request_notification(mach_task_self(), _serverContext->server_port, MACH_NOTIFY_NO_SENDERS, 1, _serverContext->notify_port, MACH_MSG_TYPE_MAKE_SEND_ONCE, &prev_notify_port); if (kr != KERN_SUCCESS) { plcrash_populate_mach_error(outError, kr, @"Failed to request MACH_NOTIFY_NO_SENDERS on the exception server's port"); - - [self release]; return nil; } @@ -344,8 +332,7 @@ struct plcrash_exception_server_context { kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_PORT_SET, &_serverContext->port_set); if (kr != KERN_SUCCESS) { plcrash_populate_mach_error(outError, kr, @"Failed to allocate exception server's port set"); - - [self release]; + return nil; } @@ -353,8 +340,7 @@ struct plcrash_exception_server_context { kr = mach_port_move_member(mach_task_self(), _serverContext->server_port, _serverContext->port_set); if (kr != KERN_SUCCESS) { plcrash_populate_mach_error(outError, kr, @"Failed to add exception server port to port set"); - - [self release]; + return nil; } @@ -362,8 +348,7 @@ struct plcrash_exception_server_context { kr = mach_port_move_member(mach_task_self(), _serverContext->notify_port, _serverContext->port_set); if (kr != KERN_SUCCESS) { plcrash_populate_mach_error(outError, kr, @"Failed to add exception server notify port to port set"); - - [self release]; + return nil; } @@ -371,8 +356,7 @@ struct plcrash_exception_server_context { { if (pthread_attr_init(&attr) != 0) { plcrash_populate_posix_error(outError, errno, @"Failed to initialize pthread_attr"); - - [self release]; + return nil; } @@ -384,8 +368,7 @@ struct plcrash_exception_server_context { if (pthread_create(&thr, &attr, &exception_server_thread, _serverContext) != 0) { plcrash_populate_posix_error(outError, errno, @"Failed to create exception server thread"); pthread_attr_destroy(&attr); - - [self release]; + return nil; } @@ -471,10 +454,10 @@ struct plcrash_exception_server_context { /* Create the port oject */ PLCrashMachExceptionPort *result; - result = [[[PLCrashMachExceptionPort alloc] initWithServerPort: port + result = [[PLCrashMachExceptionPort alloc] initWithServerPort: port mask: mask behavior: PLCRASH_DEFAULT_BEHAVIOR - flavor: MACHINE_THREAD_STATE] autorelease]; + flavor: MACHINE_THREAD_STATE]; /* Drop our send right */ mach_port_deallocate(mach_task_self(), port); @@ -813,7 +796,6 @@ static void *exception_server_thread (void *arg) { mach_msg_return_t mr; if (_serverContext == NULL) { - [super dealloc]; return; } @@ -858,8 +840,6 @@ static void *exception_server_thread (void *arg) { /* Once we've been signaled by the background thread, it will no longer access exc_context */ free(_serverContext); - - [super dealloc]; } @end diff --git a/Source/PLCrashProcessInfo.m b/Source/PLCrashProcessInfo.m index a18f245..da8a09b 100644 --- a/Source/PLCrashProcessInfo.m +++ b/Source/PLCrashProcessInfo.m @@ -59,7 +59,7 @@ * will be fetched once, and the returned instance is immutable. */ + (instancetype) currentProcessInfo { - return [[[self alloc] initWithProcessID: getpid()] autorelease]; + return [[self alloc] initWithProcessID: getpid()]; } /** @@ -87,8 +87,6 @@ if (sysctl(process_info_mib, sizeof(process_info_mib)/sizeof(process_info_mib[0]), &process_info, &process_info_len, NULL, 0) != 0) { if (errno == ENOENT) PLCF_DEBUG("Unexpected sysctl error %d: %s", errno, strerror(errno)); - - [self release]; return nil; } @@ -126,11 +124,6 @@ return self; } -- (void) dealloc { - [_processName release]; - [super dealloc]; -} - @end /** diff --git a/Source/PLCrashReport.m b/Source/PLCrashReport.m index 75d5d1c..8bb892c 100644 --- a/Source/PLCrashReport.m +++ b/Source/PLCrashReport.m @@ -114,53 +114,53 @@ static void populate_nserror (NSError **error, PLCrashReporterError code, NSStri /* Machine info */ if (_decoder->crashReport->machine_info != NULL) { - _machineInfo = [[self extractMachineInfo: _decoder->crashReport->machine_info error: outError] retain]; + _machineInfo = [self extractMachineInfo: _decoder->crashReport->machine_info error: outError]; if (!_machineInfo) goto error; } /* System info */ - _systemInfo = [[self extractSystemInfo: _decoder->crashReport->system_info processorInfo: _machineInfo.processorInfo error: outError] retain]; + _systemInfo = [self extractSystemInfo: _decoder->crashReport->system_info processorInfo: _machineInfo.processorInfo error: outError]; if (!_systemInfo) goto error; /* Application info */ - _applicationInfo = [[self extractApplicationInfo: _decoder->crashReport->application_info error: outError] retain]; + _applicationInfo = [self extractApplicationInfo: _decoder->crashReport->application_info error: outError]; if (!_applicationInfo) goto error; /* Process info. Handle missing info gracefully -- it is only included in v1.1+ crash reports. */ if (_decoder->crashReport->process_info != NULL) { - _processInfo = [[self extractProcessInfo: _decoder->crashReport->process_info error:outError] retain]; + _processInfo = [self extractProcessInfo: _decoder->crashReport->process_info error:outError]; if (!_processInfo) goto error; } /* Signal info */ - _signalInfo = [[self extractSignalInfo: _decoder->crashReport->signal error: outError] retain]; + _signalInfo = [self extractSignalInfo: _decoder->crashReport->signal error: outError]; if (!_signalInfo) goto error; /* Mach exception info */ if (_decoder->crashReport->signal != NULL && _decoder->crashReport->signal->mach_exception != NULL) { - _machExceptionInfo = [[self extractMachExceptionInfo: _decoder->crashReport->signal->mach_exception error: outError] retain]; + _machExceptionInfo = [self extractMachExceptionInfo: _decoder->crashReport->signal->mach_exception error: outError]; if (!_machExceptionInfo) goto error; } /* Thread info */ - _threads = [[self extractThreadInfo: _decoder->crashReport error: outError] retain]; + _threads = [self extractThreadInfo: _decoder->crashReport error: outError]; if (!_threads) goto error; /* Image info */ - _images = [[self extractImageInfo: _decoder->crashReport error: outError] retain]; + _images = [self extractImageInfo: _decoder->crashReport error: outError]; if (!_images) goto error; /* Exception info, if it is available */ if (_decoder->crashReport->exception != NULL) { - _exceptionInfo = [[self extractExceptionInfo: _decoder->crashReport->exception error: outError] retain]; + _exceptionInfo = [self extractExceptionInfo: _decoder->crashReport->exception error: outError]; if (!_exceptionInfo) goto error; } @@ -168,21 +168,20 @@ static void populate_nserror (NSError **error, PLCrashReporterError code, NSStri return self; error: - [self release]; return nil; } - (void) dealloc { /* Free the data objects */ - [_systemInfo release]; - [_machineInfo release]; - [_applicationInfo release]; - [_processInfo release]; - [_signalInfo release]; - [_machExceptionInfo release]; - [_threads release]; - [_images release]; - [_exceptionInfo release]; + _systemInfo = NULL; + _machineInfo = NULL; + _applicationInfo = NULL; + _processInfo = NULL; + _signalInfo = NULL; + _machExceptionInfo = NULL; + _threads = NULL; + _images = NULL; + _exceptionInfo = NULL; if (_uuid != NULL) CFRelease(_uuid); @@ -196,8 +195,6 @@ error: free(_decoder); _decoder = NULL; } - - [super dealloc]; } /** @@ -359,12 +356,12 @@ error: } /* Done */ - return [[[PLCrashReportSystemInfo alloc] initWithOperatingSystem: (PLCrashReportOperatingSystem) systemInfo->operating_system + return [[PLCrashReportSystemInfo alloc] initWithOperatingSystem: (PLCrashReportOperatingSystem) systemInfo->operating_system operatingSystemVersion: [NSString stringWithUTF8String: systemInfo->os_version] operatingSystemBuild: osBuild architecture: (PLCrashReportArchitecture) systemInfo->architecture processorInfo: processorInfo - timestamp: timestamp] autorelease]; + timestamp: timestamp]; } /** @@ -379,9 +376,9 @@ error: return nil; } - return [[[PLCrashReportProcessorInfo alloc] initWithTypeEncoding: (PLCrashReportProcessorTypeEncoding) processorInfo->encoding + return [[PLCrashReportProcessorInfo alloc] initWithTypeEncoding: (PLCrashReportProcessorTypeEncoding) processorInfo->encoding type: processorInfo->type - subtype: processorInfo->subtype] autorelease]; + subtype: processorInfo->subtype]; } /** @@ -428,9 +425,9 @@ error: return nil; } - return [[[PLCrashReportProcessorInfo alloc] initWithTypeEncoding: PLCrashReportProcessorTypeEncodingMach + return [[PLCrashReportProcessorInfo alloc] initWithTypeEncoding: PLCrashReportProcessorTypeEncodingMach type: processorType - subtype: processorSubtype] autorelease]; + subtype: processorSubtype]; } /** @@ -460,10 +457,10 @@ error: } /* Done */ - return [[[PLCrashReportMachineInfo alloc] initWithModelName: model + return [[PLCrashReportMachineInfo alloc] initWithModelName: model processorInfo: processorInfo processorCount: machineInfo->processor_count - logicalProcessorCount: machineInfo->logical_processor_count] autorelease]; + logicalProcessorCount: machineInfo->logical_processor_count]; } /** @@ -507,9 +504,9 @@ error: NSString *identifier = [NSString stringWithUTF8String: applicationInfo->identifier]; NSString *version = [NSString stringWithUTF8String: applicationInfo->version]; - return [[[PLCrashReportApplicationInfo alloc] initWithApplicationIdentifier: identifier + return [[PLCrashReportApplicationInfo alloc] initWithApplicationIdentifier: identifier applicationVersion: version - applicationMarketingVersion:marketingVersion] autorelease]; + applicationMarketingVersion:marketingVersion]; } @@ -552,13 +549,13 @@ error: NSUInteger parentProcessID = processInfo->parent_process_id; /* Done */ - return [[[PLCrashReportProcessInfo alloc] initWithProcessName: processName + return [[PLCrashReportProcessInfo alloc] initWithProcessName: processName processID: processID processPath: processPath processStartTime: startTime parentProcessName: parentProcessName parentProcessID: parentProcessID - native: processInfo->native] autorelease]; + native: processInfo->native]; } /** @@ -574,9 +571,9 @@ error: } NSString *name = [NSString stringWithUTF8String: symbol->name]; - return [[[PLCrashReportSymbolInfo alloc] initWithSymbolName: name + return [[PLCrashReportSymbolInfo alloc] initWithSymbolName: name startAddress: symbol->start_address - endAddress: symbol->has_end_address ? symbol->end_address : 0] autorelease]; + endAddress: symbol->has_end_address ? symbol->end_address : 0]; } /** @@ -598,8 +595,8 @@ error: return NULL; } - return [[[PLCrashReportStackFrameInfo alloc] initWithInstructionPointer: stackFrame->pc - symbolInfo: symbolInfo] autorelease]; + return [[PLCrashReportStackFrameInfo alloc] initWithInstructionPointer: stackFrame->pc + symbolInfo: symbolInfo]; } /** @@ -643,16 +640,16 @@ error: return nil; } - regInfo = [[[PLCrashReportRegisterInfo alloc] initWithRegisterName: [NSString stringWithUTF8String: reg->name] - registerValue: reg->value] autorelease]; + regInfo = [[PLCrashReportRegisterInfo alloc] initWithRegisterName: [NSString stringWithUTF8String: reg->name] + registerValue: reg->value]; [registers addObject: regInfo]; } /* Create the thread info instance */ - PLCrashReportThreadInfo *threadInfo = [[[PLCrashReportThreadInfo alloc] initWithThreadNumber: thread->thread_number + PLCrashReportThreadInfo *threadInfo = [[PLCrashReportThreadInfo alloc] initWithThreadNumber: thread->thread_number stackFrames: frames crashed: thread->crashed - registers: registers] autorelease]; + registers: registers]; [threadResult addObject: threadInfo]; } @@ -702,11 +699,11 @@ error: } - imageInfo = [[[PLCrashReportBinaryImageInfo alloc] initWithCodeType: codeType + imageInfo = [[PLCrashReportBinaryImageInfo alloc] initWithCodeType: codeType baseAddress: image->base_address size: image->size name: [NSString stringWithUTF8String: image->name] - uuid: uuid] autorelease]; + uuid: uuid]; [images addObject: imageInfo]; } @@ -762,11 +759,11 @@ error: } if (frames == nil) { - return [[[PLCrashReportExceptionInfo alloc] initWithExceptionName: name reason: reason] autorelease]; + return [[PLCrashReportExceptionInfo alloc] initWithExceptionName: name reason: reason]; } else { - return [[[PLCrashReportExceptionInfo alloc] initWithExceptionName: name + return [[PLCrashReportExceptionInfo alloc] initWithExceptionName: name reason: reason - stackFrames: frames] autorelease]; + stackFrames: frames]; } } @@ -804,7 +801,7 @@ error: NSString *name = [NSString stringWithUTF8String: signalInfo->name]; NSString *code = [NSString stringWithUTF8String: signalInfo->code]; - return [[[PLCrashReportSignalInfo alloc] initWithSignalName: name code: code address: signalInfo->address] autorelease]; + return [[PLCrashReportSignalInfo alloc] initWithSignalName: name code: code address: signalInfo->address]; } /** @@ -836,7 +833,7 @@ error: } /* Done */ - return [[[PLCrashReportMachExceptionInfo alloc] initWithType: machExceptionInfo->type codes: codes] autorelease]; + return [[PLCrashReportMachExceptionInfo alloc] initWithType: machExceptionInfo->type codes: codes]; } @end diff --git a/Source/PLCrashReportApplicationInfo.m b/Source/PLCrashReportApplicationInfo.m index f095e7b..d9d8a49 100644 --- a/Source/PLCrashReportApplicationInfo.m +++ b/Source/PLCrashReportApplicationInfo.m @@ -49,20 +49,13 @@ if ((self = [super init]) == nil) return nil; - _applicationIdentifier = [applicationIdentifier retain]; - _applicationVersion = [applicationVersion retain]; - _applicationMarketingVersion = [applicationMarketingVersion retain]; + _applicationIdentifier = applicationIdentifier; + _applicationVersion = applicationVersion; + _applicationMarketingVersion = applicationMarketingVersion; return self; } -- (void) dealloc { - [_applicationIdentifier release]; - [_applicationVersion release]; - [_applicationMarketingVersion release]; - [super dealloc]; -} - @synthesize applicationIdentifier = _applicationIdentifier; @synthesize applicationVersion = _applicationVersion; @synthesize applicationMarketingVersion = _applicationMarketingVersion; diff --git a/Source/PLCrashReportBinaryImageInfo.m b/Source/PLCrashReportBinaryImageInfo.m index 803df14..0be57d9 100644 --- a/Source/PLCrashReportBinaryImageInfo.m +++ b/Source/PLCrashReportBinaryImageInfo.m @@ -61,8 +61,8 @@ _baseAddress = baseAddress; _imageSize = size; - _imageName = [name retain]; - _processorInfo = [processorInfo retain]; + _imageName = name; + _processorInfo = processorInfo; if (uuid != nil) { _hasImageUUID = YES; @@ -89,12 +89,4 @@ return self; } -- (void) dealloc { - [_processorInfo release]; - [_imageName release]; - [_imageUUID release]; - - [super dealloc]; -} - @end diff --git a/Source/PLCrashReportExceptionInfo.m b/Source/PLCrashReportExceptionInfo.m index 4802f59..917d838 100644 --- a/Source/PLCrashReportExceptionInfo.m +++ b/Source/PLCrashReportExceptionInfo.m @@ -58,19 +58,11 @@ if ((self = [super init]) == nil) return nil; - _name = [name retain]; - _reason = [reason retain]; - _stackFrames = [stackFrames retain]; + _name = name; + _reason = reason; + _stackFrames = stackFrames; return self; } -- (void) dealloc { - [_name release]; - [_reason release]; - [_stackFrames release]; - - [super dealloc]; -} - @end diff --git a/Source/PLCrashReportMachExceptionInfo.m b/Source/PLCrashReportMachExceptionInfo.m index 75fe21c..f053ec5 100644 --- a/Source/PLCrashReportMachExceptionInfo.m +++ b/Source/PLCrashReportMachExceptionInfo.m @@ -44,14 +44,9 @@ return nil; _type = type; - _codes = [codes retain]; + _codes = codes; return self; } -- (void) dealloc { - [_codes release]; - [super dealloc]; -} - @end diff --git a/Source/PLCrashReportMachineInfo.m b/Source/PLCrashReportMachineInfo.m index 5882485..cd16638 100644 --- a/Source/PLCrashReportMachineInfo.m +++ b/Source/PLCrashReportMachineInfo.m @@ -61,19 +61,12 @@ if ((self = [super init]) == nil) return nil; - _modelName = [modelName retain]; - _processorInfo = [processorInfo retain]; + _modelName = modelName; + _processorInfo = processorInfo; _processorCount = processorCount; _logicalProcessorCount = logicalProcessorCount; return self; } -- (void) dealloc { - [_modelName release]; - [_processorInfo release]; - - [super dealloc]; -} - @end diff --git a/Source/PLCrashReportProcessInfo.m b/Source/PLCrashReportProcessInfo.m index b699c94..7f5f5d6 100644 --- a/Source/PLCrashReportProcessInfo.m +++ b/Source/PLCrashReportProcessInfo.m @@ -61,25 +61,17 @@ if ((self = [super init]) == nil) return nil; - _processName = [processName retain]; + _processName = processName; _processID = processID; - _processPath = [processPath retain]; - _processStartTime = [processStartTime retain]; - _parentProcessName = [parentProcessName retain]; + _processPath = processPath; + _processStartTime = processStartTime; + _parentProcessName = parentProcessName; _parentProcessID = parentProcessID; _native = native; return self; } -- (void) dealloc { - [_processName release]; - [_processPath release]; - [_processStartTime release]; - [_parentProcessName release]; - [super dealloc]; -} - @synthesize processName = _processName; @synthesize processID = _processID; @synthesize processPath = _processPath; diff --git a/Source/PLCrashReportRegisterInfo.m b/Source/PLCrashReportRegisterInfo.m index b4e9b87..e007591 100644 --- a/Source/PLCrashReportRegisterInfo.m +++ b/Source/PLCrashReportRegisterInfo.m @@ -41,17 +41,12 @@ if ((self = [super init]) == nil) return nil; - _registerName = [registerName retain]; + _registerName = registerName; _registerValue = registerValue; return self; } -- (void) dealloc { - [_registerName release]; - [super dealloc]; -} - @synthesize registerName = _registerName; @synthesize registerValue = _registerValue; diff --git a/Source/PLCrashReportSignalInfo.m b/Source/PLCrashReportSignalInfo.m index f787925..4c8b1ed 100644 --- a/Source/PLCrashReportSignalInfo.m +++ b/Source/PLCrashReportSignalInfo.m @@ -41,19 +41,13 @@ if ((self = [super init]) == nil) return nil; - _name = [name retain]; - _code = [code retain]; + _name = name; + _code = code; _address = address; return self; } -- (void) dealloc { - [_name release]; - [_code release]; - [super dealloc]; -} - @synthesize name = _name; @synthesize code = _code; @synthesize address = _address; diff --git a/Source/PLCrashReportStackFrameInfo.m b/Source/PLCrashReportStackFrameInfo.m index dc51e3f..543127f 100644 --- a/Source/PLCrashReportStackFrameInfo.m +++ b/Source/PLCrashReportStackFrameInfo.m @@ -47,15 +47,8 @@ return nil; _instructionPointer = instructionPointer; - _symbolInfo = [symbolInfo retain]; - + _symbolInfo = symbolInfo; return self; } -- (void) dealloc { - [_symbolInfo release]; - - [super dealloc]; -} - @end diff --git a/Source/PLCrashReportSymbolInfo.m b/Source/PLCrashReportSymbolInfo.m index 58883ae..301db99 100644 --- a/Source/PLCrashReportSymbolInfo.m +++ b/Source/PLCrashReportSymbolInfo.m @@ -52,17 +52,11 @@ if ((self = [super init]) == nil) return nil; - _symbolName = [symbolName retain]; + _symbolName = symbolName; _startAddress = startAddress; _endAddress = endAddress; return self; } -- (void) dealloc { - [_symbolName release]; - - [super dealloc]; -} - @end diff --git a/Source/PLCrashReportSystemInfo.m b/Source/PLCrashReportSystemInfo.m index 1996025..95009e3 100644 --- a/Source/PLCrashReportSystemInfo.m +++ b/Source/PLCrashReportSystemInfo.m @@ -147,23 +147,15 @@ PLCrashReportArchitecture PLCrashReportHostArchitecture = return nil; _operatingSystem = operatingSystem; - _osVersion = [operatingSystemVersion retain]; - _osBuild = [operatingSystemBuild retain]; + _osVersion = operatingSystemVersion; + _osBuild = operatingSystemBuild; _architecture = architecture; - _processorInfo = [processorInfo retain]; - _timestamp = [timestamp retain]; + _processorInfo = processorInfo; + _timestamp = timestamp; return self; } -- (void) dealloc { - [_osVersion release]; - [_osBuild release]; - [_timestamp release]; - [_processorInfo release]; - [super dealloc]; -} - @synthesize operatingSystem = _operatingSystem; @synthesize operatingSystemVersion = _osVersion; @synthesize operatingSystemBuild = _osBuild; diff --git a/Source/PLCrashReportTextFormatter.m b/Source/PLCrashReportTextFormatter.m index 5bfa032..f904210 100644 --- a/Source/PLCrashReportTextFormatter.m +++ b/Source/PLCrashReportTextFormatter.m @@ -182,8 +182,7 @@ static NSInteger binaryImageSort(id binary1, id binary2, void *context); NSString *incidentIdentifier = @"???"; if (report.uuidRef != NULL) { - incidentIdentifier = (NSString *) CFUUIDCreateString(NULL, report.uuidRef); - [incidentIdentifier autorelease]; + incidentIdentifier = (NSString *) CFBridgingRelease(CFUUIDCreateString(NULL, report.uuidRef)); } [text appendFormat: @"Incident Identifier: %@\n", incidentIdentifier]; diff --git a/Source/PLCrashReportThreadInfo.m b/Source/PLCrashReportThreadInfo.m index 2f16c2c..01d3f95 100644 --- a/Source/PLCrashReportThreadInfo.m +++ b/Source/PLCrashReportThreadInfo.m @@ -47,19 +47,13 @@ return nil; _threadNumber = threadNumber; - _stackFrames = [stackFrames retain]; + _stackFrames = stackFrames; _crashed = crashed; - _registers = [registers retain]; + _registers = registers; return self; } -- (void) dealloc { - [_stackFrames release]; - [_registers release]; - [super dealloc]; -} - @synthesize threadNumber = _threadNumber; @synthesize stackFrames = _stackFrames; @synthesize crashed = _crashed; diff --git a/Source/PLCrashReporter.m b/Source/PLCrashReporter.m index 6256064..673ac17 100644 --- a/Source/PLCrashReporter.m +++ b/Source/PLCrashReporter.m @@ -608,16 +608,18 @@ static PLCrashReporter *sharedReporter = nil; return NO; /* Enable the server. */ - _machServer = [self enableMachExceptionServerWithPreviousPortSet: &_previousMachPorts + id prevMacPorts = [_previousMachPorts copy]; + _machServer = [self enableMachExceptionServerWithPreviousPortSet: &prevMacPorts callback: &mach_exception_callback context: &signal_handler_context error: outError]; + _previousMachPorts = prevMacPorts; if (_machServer == nil) return NO; /* Acquire references to the autoreleased values */ - [_machServer retain]; - [_previousMachPorts retain]; + __strong id machServer = _machServer; + __strong id prevMacPortsStrong = _previousMachPorts; /* * MEMORY WARNING: To ensure that our instance survives for the lifetime of the callback registration, @@ -625,7 +627,7 @@ static PLCrashReporter *sharedReporter = nil; * survive for the lifetime of the callback. Since there's currently no support for *deregistering* a crash reporter, * this simply results in the reporter living forever. */ - [self retain]; + __strong id strong_self = self; /* * Save the previous ports. There's a race condition here, in that an exception that is delivered before (or during) @@ -858,17 +860,17 @@ cleanup: return nil; /* Save the configuration */ - _config = [configuration retain]; - _applicationIdentifier = [applicationIdentifier retain]; - _applicationVersion = [applicationVersion retain]; - _applicationMarketingVersion = [applicationMarketingVersion retain]; + _config = configuration; + _applicationIdentifier = applicationIdentifier; + _applicationVersion = applicationVersion; + _applicationMarketingVersion = applicationMarketingVersion; /* No occurances of '/' should ever be in a bundle ID, but just to be safe, we escape them */ NSString *appIdPath = [applicationIdentifier stringByReplacingOccurrencesOfString: @"/" withString: @"_"]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); NSString *cacheDir = [paths objectAtIndex: 0]; - _crashReportDirectory = [[[cacheDir stringByAppendingPathComponent: PLCRASH_CACHE_DIR] stringByAppendingPathComponent: appIdPath] retain]; + _crashReportDirectory = [[cacheDir stringByAppendingPathComponent: PLCRASH_CACHE_DIR] stringByAppendingPathComponent: appIdPath]; return self; } @@ -892,7 +894,6 @@ cleanup: const char *progname = getprogname(); if (progname == NULL) { [NSException raise: PLCrashReporterException format: @"Can not determine process identifier or process name"]; - [self release]; return nil; } @@ -959,7 +960,7 @@ cleanup: /* Create the server */ NSError *osError; - PLCrashMachExceptionServer *server = [[[PLCrashMachExceptionServer alloc] initWithCallBack: callback context: context error: &osError] autorelease]; + PLCrashMachExceptionServer *server = [[PLCrashMachExceptionServer alloc] initWithCallBack: callback context: context error: &osError]; if (server == nil) { plcrash_populate_error(outError, PLCrashReporterErrorOperatingSystem, @"Failed to instantiate the Mach exception server.", osError); return nil; @@ -983,21 +984,6 @@ cleanup: #endif /* PLCRASH_FEATURE_MACH_EXCEPTIONS */ -- (void) dealloc { - [_config release]; - -#if PLCRASH_FEATURE_MACH_EXCEPTIONS - [_machServer release]; - [_previousMachPorts release]; -#endif /* PLCRASH_FEATURE_MACH_EXCEPTIONS */ - - [_crashReportDirectory release]; - [_applicationIdentifier release]; - [_applicationVersion release]; - [_applicationMarketingVersion release]; - - [super dealloc]; -} /** * Map the configuration defined @a strategy to the backing plcrash_async_symbol_strategy_t representation. diff --git a/Source/PLCrashReporterConfig.m b/Source/PLCrashReporterConfig.m index 4d248a5..a6bf6c8 100644 --- a/Source/PLCrashReporterConfig.m +++ b/Source/PLCrashReporterConfig.m @@ -43,7 +43,7 @@ * Return the default local configuration. */ + (instancetype) defaultConfiguration { - return [[[self alloc] init] autorelease]; + return [[self alloc] init]; } /** diff --git a/Source/PLCrashSignalHandler.mm b/Source/PLCrashSignalHandler.mm index 313b55d..fe62ad5 100644 --- a/Source/PLCrashSignalHandler.mm +++ b/Source/PLCrashSignalHandler.mm @@ -290,7 +290,6 @@ static PLCrashSignalHandler *sharedHandler; /* (Unlikely) malloc failure */ if (_sigstk.ss_sp == NULL) { - [self release]; return nil; }