This is TRHCrashTrap.h in view mode; [Download] [Up]
/*+++ * title: TRHCrashTrap.h * abstract: Interface of of TRHCrashTrap class. * author: various * created: * modified: Dec 1998, by Tom Hageman <tom@basil.icce.rug.nl> * copyleft: (see below) * description: * * [adapted for use in Mail.app by means of MailCrashTrap plugin] * * Based on: // // HKCrashTrap version 1.0 // // Based on ObjectError // Original class by: // Bill Bumgarner, Andrew Stone, Mike Morton, and Julie Zelenski // // Modifications by: // Ivo Rothschild (ivo@hasc.ca) // // A class that [poses as object and] does crash-reporting. // *** This version does _not_ pose as Object anymore, it turns out not // *** to be necessary. // Catches terminating signals (ie seg faults, bus errors) // and fatal Objective-C runtime errors and writes a backtrace // out to the console using some shady hacks. This could be modified // to write backtrace to a file, mail message, etc... if desired. // // // You may freely copy, distribute, and reuse the code in this class. // // NO WARRANTY: // ANY IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE // IS HEREBY DISCLAIMED. IN NO EVENT WILL THE AFOREMENTIONED PARTIES BE LIABLE // FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL // DAMAGES ARISING OUT OF THE USE OF OR INABILITY TO USE THIS CODE. // *---*/ #ifdef RCS_TRHCrashTrap_ID static const char * const RCS_h_id = ((void)&RCS_h_id, "@(#)TRHCrashTrap.h,v 1.12 1999/01/10 13:58:23 tom Exp"); #endif #import <objc/Object.h> // These error code definitions are quite arbitrary, // hopefully will not conflict with anything that applications choose... #define CRASHTRAP_ERROR_BASE 20000000 /* NX_APP_ERROR_BASE + 10000000 */ #define CRASHTRAP_ERROR_RANGE 1000 typedef enum _CrashTrapErrorTokens { CrashTrap_Crash = CRASHTRAP_ERROR_BASE, // For future use. CrashTrap_Continue, CrashTrap_RecursiveCrash } CrashTrapErrorTokens; @interface TRHCrashTrap : Object { // No Ivars } /*" Setup and configuration. "*/ + (void)setup; + (void)setContinueAfterError:(BOOL)flag; + (BOOL)continueAfterError; + (void)setDelegate:aDelegate; + delegate; + (BOOL)isHandlingSignal:(int)aSignal; + (void)setSignal:(int)aSignal handle:(BOOL)aValue; + (void)setDefaultValues; /*" Factory methods to allow subclassing. "*/ + (Class)handlerClass; + (void)setHandlerClass:(Class)aClass; /*" Enable/Disable crash handling. "*/ + (void)resumeHandlingCrashes; + (void)stopHandlingCrashes; /*" Semi-private support methods. "*/ + (void)setSignalHandler:(void (*)())handler; + (void)printFunctionFromFP:(void *)framePointer at:(void *)address index:(int)index; + (void)printMethodFromFP:(void *)framePointer at:(void *)address index:(int)index; + (void)dumpBacktrace; + (void)dumpBacktraceAtFrame:(unsigned)startFrameNumber; /*" Generic error handlers. "*/ + (BOOL)handleError:(const char *)message; + (BOOL)handleError:(const char *)message atFrame:(unsigned)startFrameNumber; + (BOOL)shouldContinue:(const char *)message; /*" Specialized error handlers. "*/ + (void)handleObjcError:object format:(const char *)format args:(va_list)args; + (void)handleSignal:(int)sig; /*" error/backtrace logging. "*/ + (void)logStart; + (void)logMessage:(const char *)message; + (void)logStop; @end // TRHCrashTrap @interface Object (TRHCrashTrapDelegateMethods) - (BOOL)crashTrap:sender shouldContinueAfterError:(const char *)anErrorMessage; /* Give delegate a chance to determine whether it's safe to continue the application after a crash (for instance by presenting an alert panel), or to die gracefully. Return value YES means that CrashTrap should try to continue execution, NO means crash along. */ @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.