home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Demos / Tools / QC™ 1.1.3 / QCAPI / QCAPI Reference / QCAPI Reference.rsrc / TEXT_131.txt < prev    next >
Encoding:
Text File  |  1995-04-23  |  10.2 KB  |  219 lines

  1.  
  2. Appendix A
  3. Types/Constants
  4.  
  5. The following types and constants are used for input and result codes by QC APIcalls.  They are defined along with the interfaces in the file 'QCAPI.h'.
  6.  
  7. typedef long QCErr;                     // QC error code type
  8. typedef long QCType;                   // QC type codes
  9. typedef Handle QCStateHandle;     // QC save/restore state data
  10.  
  11. The following are possible QCResult values returned by all APIcalls:
  12.  
  13. //    API result codes
  14. enum    {
  15.     kQCNoErr                  = 0,
  16.     kQCInternalErr        = 9,
  17.     kQCNotInstalled,                                     // QC extension not installed
  18.     kQCNotActive,                                          // QC is not testing; must be to complete
  19.     kQCInvalidParam,                                   // invalid parameter passed to routine
  20.     kQCInvalidType,                                       // invalid QCType given to a routine
  21.     kQCPBRecMismatch,                             // QCPBRec size mismatch.  QCAPI library in use
  22.                                                                           //    does not match API loaded extension needs.
  23.     kQCAPIMismatch,                                     // The QCAPI and loaded extension API's don't match!
  24.     kQCErrHandlerNotFound,                 // QCRemoveHandler result when given proc was not
  25.                                                                          //    installed.
  26. };
  27.  
  28.  
  29.  
  30. Appendix B
  31. QC Selectors
  32.  
  33. The following selector types are used in QC control and status calls to set/check individual QC tests.  They are passed as QCSelector values and consistantly used throughout the interface for controlling QC.  They are also passed in the QCPBRec to an installed QCCallBack routine.
  34.  
  35.  
  36. // Possible QCSelector ids
  37. #define    qcAutoLaunch    'auto'                // auto launch this app/file
  38. #define    qcCheckSystemHeap    'cksh'           // check system heap
  39. #define    qcValidateMasterPointers    'vlmp'    // validate master pointers
  40. #define    qcValidateHandlePointers    'vlhp'    // validate handles/pointers
  41. #define    qcDetectWriteToZero    'dtwz'         // detect write to zero
  42. #define    qcDerefZeroCheck    'drzc'            // detect deref zero
  43. #define    qcReasonableAllocation    'rall'   // reasonable allocation                                          
  44.                                               //   checks
  45. #define    qcCheckDisposeRelease    'dprl'       // check DisposeHandle
  46.                                               //   ReleaseResource
  47. #define    qcScrambleHeap    'schp'              // scramble heap
  48. #define    qcPurgeHeap    'pghp'                 // purge heap
  49. #define    qcCheckHeap    'ckhp'                 // check heap
  50. #define    qcInvalidateFreeMemory    'infm'   // trample (invalidate)
  51.                                         //   free memory
  52. #define    qcCheckSystemCode    'csys'        // check system code
  53. #define    qcErrorReporting    'erpt'         // error reporting
  54. #define    qcDebugBreaks    'dbrk'            // debugger breaks
  55. #define    qcBeepNotify    'beep'             // beep on 
  56.                                         //   activate/deactivate
  57. #define    qcIconNotify    'sicn'             // rotate small icon
  58.                                         //   when active
  59. #define    qcBlockMoveChecking    'bkmv'         // check BlockMove calls
  60. #define    qcBlockBoundsChecking    'bbck'       // block bounds checking
  61. #define    qcGrowLockChecking    'grlk'          // grow locked block checking
  62. #define    qcGrowNonRelocChecking    'gron'   // grow non-reloc block 
  63.                                         //   checking
  64. #define    qcAllTestsMask 'mask'                    // all tests mask    
  65.                                         //   activate/deactivate all
  66.  
  67.  
  68.  
  69. Appendix C
  70. QC Handlers
  71.  
  72. You can have complete control over QC error handling by installing a routine that QC will call whenever an error is encountered.  Your application then has the choice of ignoring or handling that error entirely.  If your callback routine wants to handle the error entirely with no further interaction by QC, return true (1), else return false(0).  See QCInstallHandler() and QCRemoveHandler() for information on installing and removing error handlers.  The following list shows all the possible errors your callback routine can receive from QC.
  73.  
  74. struct QCPBRec {
  75.     QCType        testID;                                   // the selector id of the test
  76.                                  //   (currently not used)
  77.     QCErr         error;                                                            // error detected (see below)
  78.     long             data;                                                                // data/address from QCInstallHandler()
  79.     char             *errString;                                        // error string being reported
  80.     long             lastTestedTrapPC;                // PC of last trap QC detected error at
  81.     long             lastTrapPC;                                        // PC of last trap executed from
  82.                                  //   user code
  83. };
  84. typedef struct QCPBRec QCPBRec;
  85. typedef    QCPBRec *QCPBPtr;
  86.  
  87. //    PowerPC mixed mode support
  88. enum {
  89.     uppQCCallBackProcInfo = kCStackBased
  90.         | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  91.         | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(QCPBPtr)))
  92. };
  93.  
  94. // QCCallBack routine descriptors
  95. #if GENERATINGCFM
  96. typedef UniversalProcPtr QCCallBackUPP;
  97. #define NewQCCallBackProc(userRoutine)        \
  98.         (QCCallBackUPP) NewRoutineDescriptor((ProcPtr)(userRoutine),        
  99.                        uppQCCallBackProcInfo, GetCurrentISA())
  100. #else
  101. typedef    ProcPtr    QCCallBackUPP;
  102. #define    NewQCCallBackProc(userRoutine)        \
  103.                 ((QCCallBackUPP) (userRoutine))
  104. #endif
  105.  
  106.  
  107. Appendix D
  108. QC Error Codes
  109.  
  110. The following are error codes that QC encounters and reports to an installed error handler routine in the 'errorID' field of the given QCParamPtr.
  111.  
  112. enum {
  113. // API error detection result codes (given to DebugCallback
  114. //   routine (if installed)
  115.     kErrorBase = 300,                 // base index of all errors
  116.     kBadBlockLenErr,                  // invalid physical block length
  117.     kBadRelHandErr,                   // Offset from zone start to  
  118.                                    //   masterPtr invalid
  119.     kLostMasterPtrErr,                // master pointer is not in the heap
  120.     kBadMasterPtrErr,                    // MasterPtr does not point to data
  121.     kBadNonRelocErr,                  // Bad Non-reloc block: heap addr 
  122.                                    //   must follow physSize.
  123.     kBadBlockTypeErr,                 // invalid block type (not reloc, 
  124.                                    //   non-reloc, or free)
  125.     kBadLastBlockErr,                 // invalid physical block length
  126.                                    //   (last block)
  127.     kWriteToZeroErr,                  // write to location zero detected
  128.     kNilHandleErr,                    // nil handle error
  129.     kHandleInFreeErr,                 // handle is in a free block
  130.     kBadHandleErr,                    // handle is bad - not at start of 
  131.                                    //   relocatable block
  132.     kBadPtrErr,                       // Ptr does not point to 
  133.                                    //   non-relocatable block
  134.     kNilPointerErr,                   // nil pointer detected
  135.     kUnused,
  136.     kHeapStartEndErr,                 // bkLim of heap has heap end before
  137.                                    //   it starts
  138.     kFreeByteHeapErr,                 // no. of free bytes exceeds heap     
  139.                                    //   size
  140.     kGrowZoneMismatchErr,          // grow zone function mistmatch!
  141.     kUnreasonableNewHandleErr,        // new handle size is questionable
  142.     kUnreasonableNewPtrErr,
  143.     kUnreasonableSetHandleSizeErr,
  144.     kUnreasonableReallocHandleErr,
  145.     kUnreasonableSetPtrSizeErr,
  146.     kReleaseHandleErr,                // called release resource on a                                    
  147.                                    //   handle
  148.     kDisposResourceErr,               // Trying to perform a DisposHandle  
  149.                                    //   on a resource
  150.     kBlockMoveDestFree,               // Destination ptr for BlockMove is  
  151.                                    //   in a free block
  152.     kBlockMoveDestMultiple,           // Destination ptr for BlockMove  
  153.                                    //   spans multiple blocks
  154.     kBlockMoveHeadOverwrite,          // Blockmove will overwrite a block 
  155.                                    //   header
  156.     kBlockMovePadOverwrite,           // Blockmove will overwrite padding  
  157.                                    //   in a block
  158.     kUnreasonableBlockMoveSize,       // Blockmove attempting to move an 
  159.                                    //   unreasonable size
  160.     kMemErrDetected,                  // a MemErr value has been detected  
  161.                                    //   after a call
  162.     kEmptyHandleErr                   // Empty handle used by routine that 
  163.                                    //   needs data
  164.     kPtrBoundsErr,                    // Write past end of non-relocatable 
  165.                                    //   block detected
  166.     kHandleBoundsErr,                    // Write past end of relocatable  
  167.                                    //   block detected
  168.     kFreeMemOverwrite,                // Write has been made to a free 
  169.                                    //   block
  170.     kGrowLock,                        // App is growing a locked block
  171.     kGrowPtr,                         // App is growing a non-relocatable 
  172.                                    //   block
  173.     kBlockMoveNilSrc,                                                        // source pointer is NIL!
  174.     kBlockMoveNilDest,                                                    // destination pointer is NIL!      
  175.  kErrorLimit                       // max error id place holder
  176. };
  177.  
  178.  
  179.  
  180. Appendix E
  181. QC Test Options
  182.  
  183. The following struct is used to get and set individual test options with the QCGetTestOptions() and QCSetTestOptions() calls.  Please note that use of these calls does not change the state (on/off) of the desired test.  For example, you can get and set AutoLaunch options without turning on or off the AutoLaunch test.  That would have to be done with QCGetTestState() and QCSetTestState().
  184.  
  185. // Specific test option structs for use in QCGetTestOptions()/QCSetTestOptions
  186. struct QCAutoLaunchRec {
  187.     short    which;                 // 1 = _InitGraf; 2 = _Get1Resource;
  188.     short    id;                    // id for useGet1Resource
  189.     OSType    type;                 // type for useGet1Resource
  190. };
  191. typedef struct QCAutoLaunchRec QCAutoLaunchRec;
  192.  
  193. // Reasonable Allocation data contained within each LaunchRec
  194. struct QCReasonAllocRec {
  195.     short    which;                 // 1 = use app heap; 2 = use specified
  196.     long    size;
  197. };
  198. typedef struct QCReasonAllocRec QCReasonAllocRec;
  199.  
  200. struct QCBlockBoundsRec {
  201.     short        tagSize;              // block bounds size to tag blocks with
  202. };
  203. typedef    struct QCBlockBoundsRec QCBlockBoundsRec;
  204.  
  205. union QCOptionData {
  206.     QCAutoLaunchRec        autoLaunch;                             // AutoLaunch info
  207.     QCReasonAllocRec    reasonableAlloc;   // Reasonable Allocation info
  208.     QCBlockBoundsRec    blockBounds;                // BlockBounds info
  209. };
  210. typedef    union QCOptionData QCOptionData;
  211.  
  212. struct QCTestOptions {
  213.     QCType    testID;               // the test this data belongs to
  214.     QCOptionData    optionData;
  215. };
  216. typedef struct QCTestOptions QCTestOptions;
  217. typedef QCTestOptions *QCTestOptionsPtr;
  218.  
  219.