home *** CD-ROM | disk | FTP | other *** search
- /*________________________________________________________________________________
- QCAPI.h
-
- Application Programmer Interface (API) to QC™ development tool.
-
- Copyright 1993-1995 Onyx Technology. All rights reserved worldwide.
-
- revis: 06/04/93 dth - Date created
- 02/10/95 dth - Added 'testTrapPC' to QCPBRec.
- - Added PPC mixed mode for QCInstallHandler().
-
- ________________________________________________________________________________*/
-
- #ifndef _H_QCAPI
- #define _H_QCAPI
-
- #ifndef THINK_C
- #ifndef __TYPES__
- #include <Types.h>
- #endif
- #ifndef __MEMORY__
- #include <Memory.h>
- #endif
- #ifndef __OSUTILS__
- #include <OSUtils.h>
- #endif
- #endif //THINK_C
-
- typedef long QCErr; // QC error code type
- typedef long QCType; // QC type codes
- typedef Handle QCStateHandle; // QC save/restore state data
-
- // Parameter block for custom error handler
- struct QCPBRec {
- QCType testID; // the selector id of the test
- QCErr error; // error detected (see below)
- long data; // data/address from QCInstallHandler()
- char *errString; // error string being reported
- long lastTestedTrapPC; // PC of last trap QC detected error at
- long lastTrapPC; // PC of last trap executed from user code
- };
- typedef struct QCPBRec QCPBRec;
- typedef QCPBRec *QCPBPtr;
-
- // Test list handle returned by QCGetTestList(). Delete with DisposeHandle().
- struct QCTestRec {
- QCType testID;
- Str32 testName;
- };
- typedef struct QCTestRec QCTestRec;
- typedef QCTestRec *QCTestPtr, **QCTestHandle;
-
- // Specific test option structs for use in QCGetTestOptions()/QCSetTestOptions
- struct QCAutoLaunchRec {
- short which; // 1 = _InitGraf; 2 = _Get1Resource;
- short id; // id for useGet1Resource
- OSType type; // type for useGet1Resource
- };
- typedef struct QCAutoLaunchRec QCAutoLaunchRec;
-
- struct QCReasonAllocRec {
- short which; // 1 = use app heap; 2 = use specified
- long size; // alloc size to break on >=
- };
- typedef struct QCReasonAllocRec QCReasonAllocRec;
-
- struct QCBlockBoundsRec {
- short tagSize; // block bounds size to tag blocks with
- };
- typedef struct QCBlockBoundsRec QCBlockBoundsRec;
-
- union QCOptionData {
- QCAutoLaunchRec autoLaunch; // AutoLaunch information
- QCReasonAllocRec reasonableAlloc; // Reasonable Allocation information
- QCBlockBoundsRec blockBounds; // BlockBounds information
- };
- typedef union QCOptionData QCOptionData;
-
- struct QCTestOptions {
- QCType testID; // the test this data belongs to
- QCOptionData optionData; // union specific data belongs here
- };
- typedef struct QCTestOptions QCTestOptions;
- typedef QCTestOptions *QCTestOptionsPtr;
-
- enum {
- // API result codes
- kQCNoErr = 0,
- kQCInternalErr = 9,
- kQCNotInstalled, // QC extension not installed
- kQCNotActive, // QC is not testing; must be to complete
- kQCInvalidParam, // invalid parameter passed to routine
- kQCInvalidType, // invalid QCType given to a routine
- kQCPBRecMismatch, // QCPBRec size mismatch. QCAPI library in use
- // does not match API loaded extension needs.
- kQCAPIMismatch, // The QCAPI and loaded extension API's don't match!
- kQCErrHandlerNotFound, // QCRemoveHandler result when given proc was not
- // installed.
-
- // API error detection result codes (given to DebugCallback routine (if installed)
- kErrorBase = 300, // base index of all errors
- kBadBlockLenErr, // invalid physical block length
- kBadRelHandErr, // Offset from zone start to masterPtr invalid
- kLostMasterPtrErr, // master pointer is not in the heap
- kBadMasterPtrErr, // MasterPtr does not point to data
- kBadNonRelocErr, // Bad Non-reloc block: heap addr must follow physSize.
- kBadBlockTypeErr, // invalid block type (not reloc, non-reloc, or free)
- kBadLastBlockErr, // invalid physical block length (last block)
- kWriteToZeroErr, // write to location zero detected
- kNilHandleErr, // nil handle error
- /* 10 */
- kHandleInFreeErr, // handle is in a free block
- kBadHandleErr, // handle is bad - not at start of relocatable block
- kBadPtrErr, // Ptr does not point to non-relocatable block
- kNilPointerErr, // nil pointer detected
- kUnused,
- kHeapStartEndErr, // bkLim of heap has heap end before it starts
- kFreeByteHeapErr, // no. of free bytes exceeds heap size
- kGrowZoneMismatchErr, // grow zone function mistmatch!
- kUnreasonableNewHandleErr, // new handle size is questionable
- kUnreasonableNewPtrErr,
- /* 20 */
- kUnreasonableSetHandleSizeErr,
- kUnreasonableReallocHandleErr,
- kUnreasonableSetPtrSizeErr,
- kReleaseHandleErr, // called release resource on a handle
- kDisposResourceErr, // Trying to perform a DisposHandle on a resource
- kBlockMoveDestFree, // Destination ptr for BlockMove is in a free block
- kBlockMoveDestMultiple, // Destination ptr for BlockMove spans multiple blocks
- kBlockMoveHeadOverwrite, // Blockmove will overwrite a block header
- kBlockMovePadOverwrite, // Blockmove will overwrite padding in a block
- /* 30 */
- kUnreasonableBlockMoveSize, // Blockmove attempting to move an unreasonable size
- kMemErrDetected, // a MemErr value has been detected after a call
- kEmptyHandleErr, // Empty handle used by routine that needs data
- kPtrBoundsErr, // Write past end of non-relocatable block detected
- kHandleBoundsErr, // Write past end of relocatable block detected
- kFreeMemOverwrite, // Write has been made to a free block
- kGrowLock, // App is growing a locked block
- kGrowPtr, // App is growing a non-relocatable block
- kBlockMoveNilSrc, // source pointer is NIL!
- kBlockMoveNilDest, // destination pointer is NIL!
- kErrorLimit // max error id place holder
- };
-
- // The following constants are valid QCType selectors:
-
- #define qcAutoLaunch 'auto' // auto launch this app/file
- #define qcCheckSystemHeap 'cksh' // check system heap
- #define qcValidateMasterPointers 'vlmp' // validate master pointers
- #define qcValidateHandlePointers 'vlhp' // validate handles/pointers
- #define qcDetectWriteToZero 'dtwz' // detect write to zero
- #define qcDerefZeroCheck 'drzc' // detect deref zero
- #define qcReasonableAllocation 'rall' // reasonable allocation checks
- #define qcCheckDisposeRelease 'dprl' // check DisposeHandle/ReleaseResource
- #define qcScrambleHeap 'schp' // scramble heap
- #define qcPurgeHeap 'pghp' // purge heap
- #define qcCheckHeap 'ckhp' // check heap
- #define qcInvalidateFreeMemory 'infm' // trample (invalidate) free memory
- #define qcCheckSystemCode 'csys' // check system code
- #define qcErrorReporting 'erpt' // error reporting
- #define qcDebugBreaks 'dbrk' // debugger breaks
- #define qcBeepNotify 'beep' // beep on activate/deactivate
- #define qcIconNotify 'sicn' // rotate small icon when active
- #define qcBlockMoveChecking 'bkmv' // check BlockMove calls
- #define qcBlockBoundsChecking 'bbck' // block bounds checking
- #define qcMemErrDetection 'merr' // MemErr value checking
- #define qcGrowLockChecking 'grlk' // grow locked block checking
- #define qcGrowNonRelocChecking 'gron' // grow non-reloc block checking
-
- #define qcAllTestsMask 'mask' // all tests mask (activate/deactivate all)
-
- // PowerPC mixed mode support
- enum {
- uppQCCallBackProcInfo = kCStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(long)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(QCPBPtr)))
- };
-
- // QCCallBack routine descriptors
- #if GENERATINGCFM
- typedef UniversalProcPtr QCCallBackUPP;
- #define NewQCCallBackProc(userRoutine) \
- (QCCallBackUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppQCCallBackProcInfo, GetCurrentISA())
- #else
- typedef ProcPtr QCCallBackUPP;
- #define NewQCCallBackProc(userRoutine) \
- ((QCCallBackUPP) (userRoutine))
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
- // API Routines
-
- QCErr QCInstalled(void); // is QC extension loaded and usable?
- Boolean QCIsActive(void); // is QC currently testing an application?
- QCErr QCActivate(THz); // activate QC on a specific heap zone
- // or current heap if 0L is specified
- QCErr QCDeActivate(void); // deactivate QC testing
- THz QCTestingHeap(void); // get the heap being tested
-
- QCStateHandle QCGetState(void); // get the current testing state
- QCErr QCSetState(QCStateHandle); // restore the current testing state
- QCErr QCDisposeState(QCStateHandle); // dispose of state handle
- QCErr QCGetTestState(QCType, long *); // get state of a particular test
- QCErr QCSetTestState(QCType, long); // set state of a particular test
- QCErr QCGetTestOptions(QCTestOptionsPtr); // get specific test options
- QCErr QCSetTestOptions(QCTestOptionsPtr); // set specific test options
-
- QCErr QCInstallHandler(QCCallBackUPP, long); // install a error handler routine
- QCErr QCRemoveHandler(QCCallBackUPP); // remove an error handler routine
- QCErr QCGetErrorText(QCErr, StringPtr); // get error text for a particular error
-
- QCErr QCHeapCheckNow(void); // check the active heap now
- QCErr QCScrambleHeapNow(void); // scramble the active heap now
- QCErr QCBlockBoundsCheckNow(void); // perform a block bounds check now
- QCErr QCVerifyHandle(Handle); // verify the given handle
- QCErr QCVerifyPtr(Ptr); // verify the given pointer
-
- QCTestHandle QCGetTestList(long *); // Get a list of install/available tests
- // return # of tests in long*
- #ifdef __cplusplus
- }
- #endif
-
- #endif // _H_QCAPI
-