| | 1 | | #pragma rtGlobals=3 |
| | 2 | | #pragma TextEncoding="UTF-8" |
| | 3 | | #pragma rtFunctionErrors=1 |
| | 4 | | #pragma version=1.10 |
| | 5 | | #pragma ModuleName=IUTF_Debug |
| | 6 | |
|
| | 7 | | ///@cond HIDDEN_SYMBOL |
| | 8 | |
|
| | 9 | | /// @brief Set the debug mode at the start of the test run |
| 6 | 10 | | static Function SetDebugger(debugMode) |
| | 11 | | variable debugMode |
| | 12 | |
|
| 6 | 13 | | InitIgorDebugVariables() |
| 6 | 14 | | DFREF dfr = GetPackageFolder() |
| 6 | 15 | | NVAR/SDFR=dfr igor_debug_state |
| 6 | 16 | | NVAR/SDFR=dfr igor_debug_assertion |
| | 17 | |
|
| 6 | 18 | | if(!debugMode) |
| 6 | 19 | | igor_debug_state = SetIgorDebugger(IUTF_DEBUG_DISABLE) |
| 6 | 20 | | endif |
| 6 | 21 | | if(debugMode & (IUTF_DEBUG_ENABLE | IUTF_DEBUG_ON_ERROR | IUTF_DEBUG_NVAR_SVAR_WAVE | IUTF_DEBUG_FAILED_ASSERTION)) |
| 0 | 22 | | igor_debug_assertion = !!(debugMode & IUTF_DEBUG_FAILED_ASSERTION) |
| 0 | 23 | | igor_debug_state = SetIgorDebugger(debugMode | IUTF_DEBUG_ENABLE) |
| 6 | 24 | | endif |
| 6 | 25 | | End |
| | 26 | |
|
| | 27 | | /// @brief Restores the debugger to the state before SetDebugger(debugMode) |
| 5 | 28 | | static Function RestoreDebugger() |
| 5 | 29 | | DFREF dfr = GetPackageFolder() |
| 5 | 30 | | NVAR/SDFR=dfr igor_debug_state |
| 5 | 31 | | SetIgorDebugger(igor_debug_state) |
| 5 | 32 | | End |
| | 33 | |
|
| | 34 | | /// Create the variables igor_debug_state and igor_debug_assertion |
| | 35 | | /// in PKG_FOLDER and initialize it to zero |
| 6 | 36 | | static Function InitIgorDebugVariables() |
| 6 | 37 | | DFREF dfr = GetPackageFolder() |
| 6 | 38 | | variable/G dfr:igor_debug_state = 0 |
| 6 | 39 | | variable/G dfr:igor_debug_assertion = 0 |
| 6 | 40 | | End |
| | 41 | |
|
| | 42 | | /// Set the Igor Debugger, returns the previous state |
| | 43 | | /// @param state 3 bits to set |
| | 44 | | /// 0x01: debugger enable |
| | 45 | | /// 0x02: debug on error |
| | 46 | | /// 0x04: debug on NVAR SVAR WAVE reference error |
| 11 | 47 | | static Function SetIgorDebugger(state) |
| | 48 | | variable state |
| | 49 | |
|
| 11 | 50 | | variable prevState, enable, debugOnError, nvarSvarWave |
| | 51 | |
|
| 11 | 52 | | prevState = GetCurrentDebuggerState() |
| | 53 | |
|
| 11 | 54 | | enable = !!(state & IUTF_DEBUG_ENABLE) |
| 11 | 55 | | debugOnError = !!(state & IUTF_DEBUG_ON_ERROR) |
| 11 | 56 | | nvarSvarWave = !!(state & IUTF_DEBUG_NVAR_SVAR_WAVE) |
| | 57 | |
|
| 11 | 58 | | DebuggerOptions enable=enable, debugOnError=debugOnError, NVAR_SVAR_WAVE_Checking=nvarSvarWave |
| | 59 | |
|
| 11 | 60 | | return prevState |
| 11 | 61 | | End |
| | 62 | |
|
| | 63 | | /// Opens the Debugger if the assertion failed and the debugMode option is set |
| 355 | 64 | | static Function DebugFailedAssertion(result) |
| | 65 | | variable result |
| | 66 | |
|
| 355 | 67 | | DFREF dfr = GetPackageFolder() |
| 355 | 68 | | NVAR/SDFR=dfr igor_debug_assertion |
| | 69 | |
|
| 355 | 70 | | if(igor_debug_assertion && !result) |
| 0 | 71 | | Debugger |
| 355 | 72 | | endif |
| 355 | 73 | | End |
| | 74 | |
|
| | 75 | | /// Returns the current state of the Igor Debugger as ORed bitmask of IUTF_DEBUG_* constants |
| 11 | 76 | | static Function GetCurrentDebuggerState() |
| | 77 | |
|
| 11 | 78 | | DebuggerOptions |
| 11 | 79 | | return (!!V_enable) * IUTF_DEBUG_ENABLE | (!!V_debugOnError) * IUTF_DEBUG_ON_ERROR | (!!V_NVAR_SVAR_WAVE_Checking) * I |
| 11 | 80 | | End |
| | 81 | |
|
| | 82 | | ///@endcond // HIDDEN_SYMBOL |