1 /***********************************************************************/ 2 /* Open Visualization Data Explorer */ 3 /* (C) Copyright IBM Corp. 1989,1999 */ 4 /* ALL RIGHTS RESERVED */ 5 /* This code licensed under the */ 6 /* "IBM PUBLIC LICENSE - Open Visualization Data Explorer" */ 7 /***********************************************************************/ 8 9 #include <dxconfig.h> 10 11 12 #ifndef hwDebug_h 13 #define hwDebug_h 14 /*---------------------------------------------------------------------------*\ 15 This file contains declarations and defines for hardware debugging 16 \*---------------------------------------------------------------------------*/ 17 18 19 #if defined(DEBUG) 20 21 #define ENTRY_CHAR "U" 22 #define EXIT_CHAR "U" 23 #define BODY_CHAR "V" 24 #define RESERVED_CHAR "W" 25 #define MESSAGE_CHAR "X" 26 27 #define DXHW_MESSAGE_NONE 0 28 #define DXHW_MESSAGE_VERBOSE 1 29 #define DXHW_MESSAGE_FROM_EXEC 2 30 #define DXHW_MESSAGE_FROM_UI 4 31 32 /* 33 * Abstract this call so we can change the meaning of debugging trace 34 * easily 35 */ 36 #define PRINT_FUNC printf 37 38 /* 39 * This allows us to make function calls when debugging and have 40 * them disappear when optimized. 41 */ 42 #define DEBUG_CALL(a) a 43 44 /* 45 * Enable debugging if the environment variable is set. 46 */ 47 #define ENABLE_DEBUG() \ 48 { \ 49 static int debug_enabled=FALSE; \ 50 if (!debug_enabled && getenv("DXHW_DEBUG")) {\ 51 DXEnableDebug(getenv("DXHW_DEBUG"),1); \ 52 debug_enabled = TRUE; \ 53 } \ 54 } 55 56 #define DEBUG_OFF() \ 57 { \ 58 if (getenv("DXHW_DEBUG")) {\ 59 DXEnableDebug((char *)getenv("DXHW_DEBUG"),0); \ 60 PRINT_FUNC("/************ trace off ***********/\n"); \ 61 } \ 62 } 63 64 #define DEBUG_ON() \ 65 { \ 66 if (getenv("DXHW_DEBUG")) {\ 67 DXEnableDebug((char *)getenv("DXHW_DEBUG"),1); \ 68 PRINT_FUNC("/************ trace on ***********/\n"); \ 69 } \ 70 } 71 72 /* 73 * Debug macros. Use these the same as using printf. ENTRY and EXIT 74 * insert special formating characters for use with indent (makes 75 * trace look like 'c' code. 76 */ 77 #define PRINT(a) \ 78 if (DXQueryDebug(BODY_CHAR)) \ 79 { \ 80 PRINT_FUNC a; \ 81 PRINT_FUNC (";\n"); \ 82 } 83 /* 84 #define FROMSERVER(a) \ 85 if(DXQueryDebug(MESSAGE_CHAR)) \ 86 { \ 87 PRINT_FUNC ("<<<=== Message( " a " " ) from server"); \ 88 } 89 90 #define TOSERVER(a) \ 91 if(DXQueryDebug(MESSAGE_CHAR)) \ 92 { \ 93 PRINT_FUNC ("===>>> Message( " a " ) to Server"); \ 94 } 95 */ 96 #define ENTRY(a) \ 97 if (DXQueryDebug(ENTRY_CHAR)) { \ 98 PRINT_FUNC ("{ "); \ 99 PRINT_FUNC a; \ 100 PRINT_FUNC (";\n"); \ 101 } 102 103 #define EXIT(a) \ 104 if (DXQueryDebug(EXIT_CHAR)) { \ 105 PRINT_FUNC a; \ 106 PRINT_FUNC (";"); \ 107 PRINT_FUNC ("}\n"); \ 108 } 109 110 /* 111 * Puts a marker to separate major sections of the trace (the marker 112 * looks like a 'c' comment). 113 */ 114 #define DEBUG_MARKER(text) \ 115 if (DXQueryDebug(ENTRY_CHAR)) { \ 116 int i; \ 117 PRINT_FUNC("/*"); \ 118 for (i=0;i<20;i++) PRINT_FUNC("="); \ 119 PRINT_FUNC(" %s ",text); \ 120 for (i=0;i<20;i++) PRINT_FUNC("="); \ 121 PRINT_FUNC("*/\n\n"); \ 122 fflush(stdout); \ 123 } 124 125 /* 126 * undef's are only temporary until all files are brought forward 127 * to use new debugging macros. 128 */ 129 #undef MPRINT 130 #define MPRINT(M) \ 131 PRINT(( "float MM[4][4] = {\n" \ 132 " { %12.6f, %12.6f, %12.6f, %12.6f },\n" \ 133 " { %12.6f, %12.6f, %12.6f, %12.6f },\n" \ 134 " { %12.6f, %12.6f, %12.6f, %12.6f },\n" \ 135 " { %12.6f, %12.6f, %12.6f, %12.6f },\n" \ 136 "}", \ 137 M[0][0], M[0][1], M[0][2], M[0][3], \ 138 M[1][0], M[1][1], M[1][2], M[1][3], \ 139 M[2][0], M[2][1], M[2][2], M[2][3], \ 140 M[3][0], M[3][1], M[3][2], M[3][3])); 141 142 #undef VPRINT 143 #define VPRINT(V) \ 144 PRINT(( "float VV[] = { %12.6f, %12.6f, %12.6f }", V[0], V[1], V[2])); 145 146 #undef SPRINT 147 #define SPRINT(S) \ 148 PRINT(( "float SS[] = { %12.6f, %12.6f, %12.6f }", S.x, S.y, S.z)); 149 150 #undef CPRINT 151 #define CPRINT(C) \ 152 PRINT(( "float CC[] = { %12.6f, %12.6f, %12.6f }", C.r, C.g, C.b)); 153 154 /* 155 * Used to turn on and off sections of code at run-time. 156 */ 157 #define RT_IFDEF(x) \ 158 if (getenv(#x)) { 159 160 #define RT_IFNDEF(x) \ 161 if (!getenv(#x)) { 162 163 #define RT_ELSE \ 164 } else { 165 166 #define RT_ENDIF \ 167 } 168 169 #else /* if defined(DEBUG) */ 170 171 #define DXHW_MESSAGE_NONE 0 172 #define DXHW_MESSAGE_VERBOSE 1 173 #define DXHW_MESSAGE_FROM_EXEC 2 174 #define DXHW_MESSAGE_FROM_UI 4 175 176 #define DEBUG_CALL(a) 177 #define ENABLE_DEBUG() 178 #define DEBUG_OFF() 179 #define DEBUG_ON() 180 #define ENTRY(a) 181 #define EXIT(a) 182 #define FROMSERVER(a) 183 #define TOSERVER(a) 184 #define PRINT(a) 185 #define CLIENT_MESSAGE(a) 186 #define DEBUG_MARKER(text) 187 #undef MPRINT 188 #define MPRINT(M) 189 #undef VPRINT 190 #define VPRINT(V) 191 #undef SPRINT 192 #define SPRINT(S) 193 #undef CPRINT 194 #define CPRINT(C) 195 #define RT_IFDEF(x) if(0) { 196 #define RT_IFNDEF(x) if(1) { 197 #define RT_ELSE } else { 198 #define RT_ENDIF } 199 200 #endif /* if defined(DEBUG) */ 201 202 #if !defined(TIMER) 203 #ifdef DX_NO_TIMER 204 #define TIMER(s) 205 #else 206 #define TIMER(s) DXMarkTime(s); 207 #endif 208 #endif 209 210 #endif 211