113 #ifndef kComponentSignatureString
114 #define kComponentSignatureString "Third Party Client"
117 #define DEBUG_LEVEL_PRODUCTION 0
118 #define DEBUG_LEVEL_BREAK_ONLY 1
119 #define DEBUG_LEVEL_EXTERNAL 3
120 #define DEBUG_LEVEL_INTERNAL 4
121 #define DEBUGFULL DEBUG_LEVEL_INTERNAL
122 #define DEBUG_NO_OPTIONS 0
130 #define DEBUGLEVEL DEBUG_LEVEL_PRODUCTION
132 #define DEBUGLEVEL DEBUG_LEVEL_EXTERNAL
134 #define DEBUGLEVEL DEBUG_LEVEL_INTERNAL
136 #define DEBUGLEVEL DEBUG_LEVEL_PRODUCTION
137 #elif DEBUG_BREAK_ONLY
138 #define DEBUGLEVEL DEBUG_LEVEL_BREAK_ONLY
140 #define DEBUGLEVEL DEBUG_LEVEL_INTERNAL
145 #define DEBUGLEVEL DEBUG_LEVEL_PRODUCTION
148 #ifndef COMPONENT_SIGNATURE
149 #define COMPONENT_SIGNATURE '?*?*'
152 #define QuoteExceptionString(x) #x
177 #if PRAGMA_STRUCT_ALIGN
178 #pragma options align = mac68k
179 #elif PRAGMA_STRUCT_PACKPUSH
180 #pragma pack(push, 2)
181 #elif PRAGMA_STRUCT_PACK
195 const char *assertionString,
const char *exceptionString,
196 const char *errorString,
const char *fileName,
long lineNumber,
199 #ifndef DEBUGASSERTMSG
200 #if DEBUGLEVEL == DEBUG_LEVEL_BREAK_ONLY
201 #define DEBUGASSERTMSG(componentSignature, options, assertionString, \
202 exceptionString, errorString, fileName, lineNumber, \
205 #elif DEBUGLEVEL == DEBUG_LEVEL_EXTERNAL
207 #if (applec && (!__powerc))
208 #define DEBUGASSERTMSG(componentSignature, options, assertionString, \
209 exceptionString, errorString, fileName, lineNumber, \
211 DebugAssert(componentSignature, options, kComponentSignatureString, \
212 assertionString, NULL, NULL, 0, value)
214 #define DEBUGASSERTMSG(componentSignature, options, assertionString, \
215 exceptionString, errorString, fileName, lineNumber, \
217 DebugAssert(componentSignature, options, \
218 kComponentSignatureString ": " assertionString, NULL, NULL, \
221 #elif DEBUGLEVEL == DEBUG_LEVEL_INTERNAL
223 #if (applec && (!__powerc))
224 #define DEBUGASSERTMSG(componentSignature, options, assertionString, \
225 exceptionString, errorString, fileName, lineNumber, \
227 DebugAssert(componentSignature, options, kComponentSignatureString, \
228 assertionString, NULL, fileName, lineNumber, value)
230 #define DEBUGASSERTMSG(componentSignature, options, assertionString, \
231 exceptionString, errorString, fileName, lineNumber, \
233 DebugAssert(componentSignature, options, \
234 kComponentSignatureString ": " assertionString, exceptionString, \
235 errorString, fileName, lineNumber, value)
239 #define DEBUGASSERTMSG(componentSignature, options, assertionString, \
240 exceptionString, errorString, fileName, lineNumber, \
254 kBlessedBusErrorBait = 0x68F168F1
260 k68kInterruptLevelMask = 0x00000007,
261 kInVBLTaskMask = 0x00000010,
262 kInDeferredTaskMask = 0x00000020,
263 kInSecondaryIntHandlerMask = 0x00000040,
264 kInNestedInterruptMask = 0x00000080
269 kComponentDebugOption =
290 DebugComponentCallbackProcPtr)(SInt32 optionSelectorNum,
293 typedef STACK_UPP_TYPE(DebugComponentCallbackProcPtr) DebugComponentCallbackUPP;
315 #define ATTASKLEVEL0() (TaskLevel() == 0)
339 DebugComponentCallbackUPP componentCallback);
367 ConstStr255Param optionName);
410 Str255 componentName);
435 SInt32 *optionSelectorNum, Str255 optionName,
471 OSType componentSignature, UInt32 options,
const char *assertionString,
472 const char *exceptionString,
const char *errorString,
const char *fileName,
473 long lineNumber,
void *value, ConstStr255Param outputMsg);
475 DebugAssertOutputHandlerUPP;
498 #if CALL_NOT_IN_CARBON
536 #define DPRINTF(x) dprintf x
551 DebugComponentCallbackUPP
553 #if !OPAQUE_UPP_TYPES
556 uppDebugComponentCallbackProcInfo = 0x00000FC0
559 inline DebugComponentCallbackUPP
563 (ProcPtr)(userRoutine), uppDebugComponentCallbackProcInfo,
564 GetCurrentArchitecture());
567 #define NewDebugComponentCallbackUPP(userRoutine) \
568 (DebugComponentCallbackUPP) NewRoutineDescriptor( \
569 (ProcPtr)(userRoutine), uppDebugComponentCallbackProcInfo, \
570 GetCurrentArchitecture())
582 DebugAssertOutputHandlerUPP
584 #if !OPAQUE_UPP_TYPES
587 uppDebugAssertOutputHandlerProcInfo = 0x00FFFFC0
591 inline DebugAssertOutputHandlerUPP
595 (ProcPtr)(userRoutine), uppDebugAssertOutputHandlerProcInfo,
596 GetCurrentArchitecture());
599 #define NewDebugAssertOutputHandlerUPP(userRoutine) \
600 (DebugAssertOutputHandlerUPP) NewRoutineDescriptor( \
601 (ProcPtr)(userRoutine), uppDebugAssertOutputHandlerProcInfo, \
602 GetCurrentArchitecture())
616 #if !OPAQUE_UPP_TYPES
624 #define DisposeDebugComponentCallbackUPP(userUPP) \
625 DisposeRoutineDescriptor(userUPP)
639 #if !OPAQUE_UPP_TYPES
647 #define DisposeDebugAssertOutputHandlerUPP(userUPP) \
648 DisposeRoutineDescriptor(userUPP)
663 DebugComponentCallbackUPP userUPP);
664 #if !OPAQUE_UPP_TYPES
669 DebugComponentCallbackUPP userUPP)
671 CALL_THREE_PARAMETER_UPP(userUPP, uppDebugComponentCallbackProcInfo,
672 optionSelectorNum, command, optionSetting);
675 #define InvokeDebugComponentCallbackUPP(optionSelectorNum, command, \
676 optionSetting, userUPP) \
677 CALL_THREE_PARAMETER_UPP((userUPP), uppDebugComponentCallbackProcInfo, \
678 (optionSelectorNum), (command), (optionSetting))
692 const char *assertionString,
693 const char *exceptionString,
694 const char *errorString,
const char *fileName,
695 long lineNumber,
void *value,
696 ConstStr255Param outputMsg,
697 DebugAssertOutputHandlerUPP userUPP);
698 #if !OPAQUE_UPP_TYPES
701 OSType componentSignature, UInt32 options,
const char *assertionString,
702 const char *exceptionString,
const char *errorString,
const char *fileName,
703 long lineNumber,
void *value, ConstStr255Param outputMsg,
704 DebugAssertOutputHandlerUPP userUPP)
706 CALL_NINE_PARAMETER_UPP(userUPP, uppDebugAssertOutputHandlerProcInfo,
707 componentSignature, options, assertionString,
708 exceptionString, errorString, fileName, lineNumber,
712 #define InvokeDebugAssertOutputHandlerUPP( \
713 componentSignature, options, assertionString, exceptionString, \
714 errorString, fileName, lineNumber, value, outputMsg, userUPP) \
715 CALL_NINE_PARAMETER_UPP((userUPP), uppDebugAssertOutputHandlerProcInfo, \
716 (componentSignature), (options), (assertionString), \
717 (exceptionString), (errorString), (fileName), \
718 (lineNumber), (value), (outputMsg))
722 #if CALL_NOT_IN_CARBON || OLDROUTINENAMES
724 #define NewDebugComponentCallbackProc(userRoutine) \
725 NewDebugComponentCallbackUPP(userRoutine)
726 #define NewDebugAssertOutputHandlerProc(userRoutine) \
727 NewDebugAssertOutputHandlerUPP(userRoutine)
728 #define CallDebugComponentCallbackProc(userRoutine, optionSelectorNum, \
729 command, optionSetting) \
730 InvokeDebugComponentCallbackUPP(optionSelectorNum, command, optionSetting, \
732 #define CallDebugAssertOutputHandlerProc( \
733 userRoutine, componentSignature, options, assertionString, \
734 exceptionString, errorString, fileName, lineNumber, value, outputMsg) \
735 InvokeDebugAssertOutputHandlerUPP( \
736 componentSignature, options, assertionString, exceptionString, \
737 errorString, fileName, lineNumber, value, outputMsg, userRoutine)
756 #if CALL_NOT_IN_CARBON
758 #define LocalLMGetMacJmp() (*((unsigned long *)0x0120))
759 #define LocalLMGetMacJmpFlag() (*((UInt8 *)0x0BFF))
760 #define LocalLMKeyMap ((UInt16 *)(0x0174))
762 #define ISCAPSLOCKKEYDOWN() ((LocalLMKeyMap[3] & 0x0002) == 0x0002)
764 #define ISLOWLEVELDEBUGGERCALLABLE() \
765 ((LocalLMGetMacJmpFlag() != (UInt8)0xff) && \
766 ((LocalLMGetMacJmpFlag() & (UInt8)0xe0) == (UInt8)0x60) && \
767 (LocalLMGetMacJmp() != 0) && \
768 (LocalLMGetMacJmp() != (unsigned long)0xffffffff))
773 #define SafeDebugger() \
776 if (ISLOWLEVELDEBUGGERCALLABLE()) \
780 #define SafeDebugStr(str) \
783 if (ISLOWLEVELDEBUGGERCALLABLE()) \
787 #define CapsLockDebugger() \
790 if (ISLOWLEVELDEBUGGERCALLABLE() && ISCAPSLOCKKEYDOWN()) \
794 #define CapsLockDebugStr(str) \
797 if (ISLOWLEVELDEBUGGERCALLABLE() && ISCAPSLOCKKEYDOWN()) \
805 #define DEBUGGER() SafeDebugger()
807 #define DEBUGSTR(str) SafeDebugStr(str)
811 #define DEBUGSTR(str)
818 #if DEBUGLEVEL == DEBUG_LEVEL_PRODUCTION
819 #define check(assertion)
820 #define check_string(assertion, cstring)
821 #define check_noerr(err)
822 #define check_noerr_string(error, cstring)
823 #define debug_string(cstring)
824 #define require(assertion, label) \
830 #define require_string(assertion, label, string) require(assertion, label)
831 #define require_quiet(assertion, label) require(assertion, label)
832 #define require_noerr(error, label) \
835 if ((error) != noErr) \
838 #define require_noerr_quiet(assertion, label) require_noerr(assertion, label)
839 #define require_noerr_action(error, label, action) \
842 if ((error) != noErr) \
850 #define require_noerr_action_quiet(assertion, label, action) \
851 require_noerr_action(assertion, label, action)
852 #define require_action(assertion, label, action) \
863 #define require_action_quiet(assertion, label, action) \
864 require_action(assertion, label, action)
865 #define require_action_string(assertion, label, action, cstring) \
881 #define debug_string(string) \
884 DEBUGASSERTMSG(COMPONENT_SIGNATURE, DEBUG_NO_OPTIONS, \
885 QuoteExceptionString(string), NULL, NULL, __FILE__, \
891 #define check(assertion) \
896 DEBUGASSERTMSG(COMPONENT_SIGNATURE, DEBUG_NO_OPTIONS, \
897 QuoteExceptionString(assertion), NULL, NULL, __FILE__, \
904 #define check_string(assertion, cstring) \
909 DEBUGASSERTMSG(COMPONENT_SIGNATURE, DEBUG_NO_OPTIONS, \
910 QuoteExceptionString(assertion), cstring, NULL, __FILE__, \
917 #define check_noerr(error) \
920 OSStatus localError = error; \
921 if (localError != noErr) \
923 DEBUGASSERTMSG(COMPONENT_SIGNATURE, DEBUG_NO_OPTIONS, \
924 QuoteExceptionString(error) "== noErr", NULL, NULL, \
925 __FILE__, __LINE__, (void *)localError); \
931 #define check_noerr_string(error, cstring) \
934 OSStatus localError = error; \
935 if (localError != noErr) \
937 DEBUGASSERTMSG(COMPONENT_SIGNATURE, DEBUG_NO_OPTIONS, \
938 QuoteExceptionString(error) "== noErr\n", cstring, NULL, \
939 __FILE__, __LINE__, (void *)localError); \
945 #define require(assertion, exception) \
950 DEBUGASSERTMSG(COMPONENT_SIGNATURE, DEBUG_NO_OPTIONS, \
951 QuoteExceptionString(assertion), \
952 QuoteExceptionString(exception), NULL, __FILE__, \
960 #define require_noerr(error, exception) \
963 OSStatus localError = error; \
964 if (localError != noErr) \
966 DEBUGASSERTMSG(COMPONENT_SIGNATURE, DEBUG_NO_OPTIONS, \
967 QuoteExceptionString(error) "== noErr", \
968 QuoteExceptionString(exception), NULL, __FILE__, \
969 __LINE__, (void *)localError); \
976 #define require_string(assertion, exception, string) \
981 DEBUGASSERTMSG(COMPONENT_SIGNATURE, DEBUG_NO_OPTIONS, string, \
982 QuoteExceptionString(assertion), \
983 QuoteExceptionString(exception), __FILE__, __LINE__, 0); \
990 #define require_noerr_action(error, exception, action) \
993 OSStatus localError = error; \
994 if (localError != noErr) \
996 DEBUGASSERTMSG(COMPONENT_SIGNATURE, DEBUG_NO_OPTIONS, \
997 QuoteExceptionString(error) "== noErr", \
998 QuoteExceptionString(exception), NULL, __FILE__, \
999 __LINE__, (void *)localError); \
1009 #define require_noerr_quiet(error, exception) \
1012 if (error != noErr) \
1020 #define require_noerr_action_quiet(error, exception, action) \
1023 if (error != noErr) \
1034 #define require_action(assertion, exception, action) \
1039 DEBUGASSERTMSG(COMPONENT_SIGNATURE, DEBUG_NO_OPTIONS, \
1040 QuoteExceptionString(assertion), \
1041 QuoteExceptionString(exception), NULL, __FILE__, \
1052 #define require_action_string(assertion, exception, action, cstring) \
1057 DEBUGASSERTMSG(COMPONENT_SIGNATURE, DEBUG_NO_OPTIONS, \
1058 cstring ": " QuoteExceptionString(assertion), \
1059 QuoteExceptionString(exception), NULL, __FILE__, \
1070 #define require_quiet(assertion, exception) \
1081 #define require_action_quiet(assertion, exception, action) \
1099 #define check_tasklevel0() check(ATTASKLEVEL0())
1100 #define check_tasklevel0_string(string) check_string(ATTASKLEVEL0(), string)
1102 #define require_tasklevel0(label) require(ATTASKLEVEL0(), label)
1103 #define require_tasklevel0_string(label, string) \
1104 require_string(ATTASKLEVEL0(), label, string)
1105 #define require_tasklevel0_action(label, string, action) \
1106 require_action(ATTASKLEVEL0(), label, action)
1107 #define require_tasklevel0_action_string(label, string, action) \
1108 require_action_string(ATTASKLEVEL0(), label, action, string)
1112 #if DEBUGLEVEL > DEBUG_LEVEL_PRODUCTION
1113 #define verify(assertion) check(assertion)
1114 #define verify_noerr(assertion) check_noerr((assertion))
1116 #define verify(assertion) \
1119 (void)(assertion); \
1121 #define verify_noerr(assertion) verify(assertion)
1126 #define ncheck(assertion) check(!(assertion))
1127 #define ncheck_string(assertion, cstring) check_string(!(assertion), cstring)
1128 #define nrequire(assertion, exception) require(!(assertion), exception)
1129 #define nrequire_action(assertion, exception, action) \
1130 require_action(!(assertion), exception, action)
1131 #define nrequire_quiet(assertion, exception) \
1132 require_quiet(!(assertion), exception)
1133 #define nrequire_action_quiet(assertion, exception, action) \
1134 require_action_quiet(!(assertion), exception, action)
1135 #define nrequire_string(assertion, exception, string) \
1136 require_string(!(assertion), exception, string)
1138 #if PRAGMA_STRUCT_ALIGN
1139 #pragma options align = reset
1140 #elif PRAGMA_STRUCT_PACKPUSH
1142 #elif PRAGMA_STRUCT_PACK
1146 #ifdef PRAGMA_IMPORT_OFF
1149 #pragma import reset
OSStatus NewDebugOption(OSType componentSignature, SInt32 optionSelectorNum, ConstStr255Param optionName)
#define NewDebugAssertOutputHandlerUPP(userRoutine)
Definition: Debugging.h:599
OSStatus SetDebugOptionValue(OSType componentSignature, SInt32 optionSelectorNum, Boolean newOptionSetting)
OSStatus GetDebugOptionInfo(UInt32 index, OSType componentSignature, SInt32 *optionSelectorNum, Str255 optionName, Boolean *optionSetting)
void InvokeDebugAssertOutputHandlerUPP(OSType componentSignature, UInt32 options, const char *assertionString, const char *exceptionString, const char *errorString, const char *fileName, long lineNumber, void *value, ConstStr255Param outputMsg, DebugAssertOutputHandlerUPP userUPP)
void DebugAssert(OSType componentSignature, UInt32 options, const char *assertionString, const char *exceptionString, const char *errorString, const char *fileName, long lineNumber, void *value)
OSStatus GetDebugComponentInfo(UInt32 index, OSType *componentSignature, Str255 componentName)
void DisposeDebugComponentCallbackUPP(DebugComponentCallbackUPP userUPP)
void vdprintf(const char *format, char *va_args_list)
#define NewDebugComponentCallbackUPP(userRoutine)
Definition: Debugging.h:567
@ kSetDebugOption
Definition: Debugging.h:276
OSStatus NewDebugComponent(OSType componentSignature, ConstStr255Param componentName, DebugComponentCallbackUPP componentCallback)
void DisposeDebugAssertOutputHandlerUPP(DebugAssertOutputHandlerUPP userUPP)
typedef CALLBACK_API(void, DebugComponentCallbackProcPtr)(SInt32 optionSelectorNum
OSStatus DisposeDebugComponent(OSType componentSignature)
void InstallDebugAssertOutputHandler(DebugAssertOutputHandlerUPP handler)
void InvokeDebugComponentCallbackUPP(SInt32 optionSelectorNum, UInt32 command, Boolean *optionSetting, DebugComponentCallbackUPP userUPP)
void dprintf(const char *format,...)
File Manager (MFS, HFS, and HFS+) Interfaces.
Basic Macintosh data types.
unsigned char Boolean
Definition: MacTypes.h:318
void DisposeRoutineDescriptor(UniversalProcPtr theUPP)
#define STACK_UPP_TYPE(name)
Definition: MixedMode.h:734
UniversalProcPtr NewRoutineDescriptor(ProcPtr theProc, ProcInfoType theProcInfo, ISAType theISA)