Changeset 1640
- Timestamp:
- Aug 27, 2004, 11:45:01 AM (22 years ago)
- Location:
- trunk/psLib
- Files:
-
- 5 edited
-
src/sys/psTrace.c (modified) (15 diffs)
-
src/sys/psTrace.h (modified) (1 diff)
-
src/sysUtils/psTrace.c (modified) (15 diffs)
-
test/sysUtils/tst_psTrace03.c (modified) (1 diff)
-
test/sysUtils/tst_psTrace04.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psTrace.c
r1441 r1640 1 2 1 /** @file psTrace.c 3 2 * \brief basic run-time trace facilities … … 10 9 * @author George Gusciora, MHPCC 11 10 * 12 * @version $Revision: 1.1 7$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-08- 09 23:40:55$11 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-08-27 21:45:01 $ 14 13 * 15 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 44 43 #include "psString.h" 45 44 #include "psError.h" 46 47 static p_psComponent* p_psCroot = NULL; // The root of the trace component 48 static FILE *p_psTraceFP = NULL; // File destination for messages. 45 #include "psAbort.h" 46 47 static p_psComponent* cRoot = NULL; // The root of the trace component 48 static FILE *traceFP = NULL; // File destination for messages. 49 49 50 50 static void componentFree(p_psComponent* comp); … … 91 91 static void initTrace(void) 92 92 { 93 if ( p_psCroot == NULL) {94 p_psCroot = componentAlloc(".", PS_DEFAULT_TRACE_LEVEL);93 if (cRoot == NULL) { 94 cRoot = componentAlloc(".", PS_DEFAULT_TRACE_LEVEL); 95 95 } 96 96 } … … 124 124 void psTraceReset() 125 125 { 126 p_psTraceReset(p_psCroot); 126 componentFree(cRoot); 127 cRoot = NULL; 127 128 } 128 129 … … 132 133 void psTraceFree() 133 134 { 134 ps Free(p_psCroot);135 psTraceReset(); 135 136 } 136 137 … … 147 148 char *pname = name; 148 149 char *firstComponent = NULL; // first component of name 149 p_psComponent* currentNode = p_psCroot;150 p_psComponent* currentNode = cRoot; 150 151 int nodeExists = 0; 152 153 // XXX: Verify that this is the correct behavior. 154 if (strcmp("", addNodeName) == 0) { 155 psAbort(__func__, "Failed to add null component to trace tree.\n"); 156 } 151 157 152 158 // Is this the root node? If so, simply set level and return. 153 159 if (strcmp(".", addNodeName) == 0) { 154 p_psCroot->level = level;160 cRoot->level = level; 155 161 return; 156 162 } … … 185 191 currentNode->n = (currentNode->n) + 1; 186 192 187 currentNode->subcomp[(currentNode->n) - 1] = componentAlloc(firstComponent, level); 193 if (pname == NULL) { 194 currentNode->subcomp[(currentNode->n) - 1] = componentAlloc(firstComponent, level); 195 } else { 196 currentNode->subcomp[(currentNode->n) - 1] = componentAlloc(firstComponent, currentNode->level); 197 } 198 currentNode = currentNode->subcomp[(currentNode->n) - 1]; 188 199 } 189 200 } … … 205 216 { 206 217 // If the root component tree does not exist, then initialize it. 207 if ( p_psCroot == NULL) {218 if (cRoot == NULL) { 208 219 initTrace(); 209 220 } … … 234 245 char *pname = name; 235 246 char *firstComponent = NULL; // first component of name 236 p_psComponent* currentNode = p_psCroot;247 p_psComponent* currentNode = cRoot; 237 248 int i = 0; 238 249 … … 242 253 243 254 if (strcmp(".", aname) == 0) { 244 return ( p_psCroot->level);255 return (cRoot->level); 245 256 } 246 257 … … 284 295 int psTraceGetLevel(const char *name) 285 296 { 286 if ( p_psCroot == NULL) {297 if (cRoot == NULL) { 287 298 return (PS_UNKNOWN_TRACE_LEVEL); 288 299 } … … 335 346 void psTracePrintLevels(void) 336 347 { 337 if ( p_psCroot == NULL) {348 if (cRoot == NULL) { 338 349 return; 339 350 } 340 351 341 doPrintTraceLevels( p_psCroot, 0);352 doPrintTraceLevels(cRoot, 0); 342 353 } 343 354 … … 377 388 fmt = va_arg(ap, char *); 378 389 379 if ( p_psTraceFP != NULL) {390 if (traceFP != NULL) { 380 391 // We indent each message one space for each level of the message. 381 392 for (i = 0; i < level; i++) { 382 fprintf( p_psTraceFP, " ");383 } 384 vfprintf( p_psTraceFP, fmt, ap);393 fprintf(traceFP, " "); 394 } 395 vfprintf(traceFP, fmt, ap); 385 396 } else { 386 397 // We indent each message one space for each level of the message. … … 397 408 void psTraceSetDestination(FILE * fp) 398 409 { 399 p_psTraceFP = fp;410 traceFP = fp; 400 411 } 401 412 -
trunk/psLib/src/sys/psTrace.h
r1441 r1640 10 10 * @author George Gusciora, MHPCC 11 11 * 12 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-08- 09 23:40:55$12 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-08-27 21:45:01 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii -
trunk/psLib/src/sysUtils/psTrace.c
r1441 r1640 1 2 1 /** @file psTrace.c 3 2 * \brief basic run-time trace facilities … … 10 9 * @author George Gusciora, MHPCC 11 10 * 12 * @version $Revision: 1.1 7$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-08- 09 23:40:55$11 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-08-27 21:45:01 $ 14 13 * 15 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 44 43 #include "psString.h" 45 44 #include "psError.h" 46 47 static p_psComponent* p_psCroot = NULL; // The root of the trace component 48 static FILE *p_psTraceFP = NULL; // File destination for messages. 45 #include "psAbort.h" 46 47 static p_psComponent* cRoot = NULL; // The root of the trace component 48 static FILE *traceFP = NULL; // File destination for messages. 49 49 50 50 static void componentFree(p_psComponent* comp); … … 91 91 static void initTrace(void) 92 92 { 93 if ( p_psCroot == NULL) {94 p_psCroot = componentAlloc(".", PS_DEFAULT_TRACE_LEVEL);93 if (cRoot == NULL) { 94 cRoot = componentAlloc(".", PS_DEFAULT_TRACE_LEVEL); 95 95 } 96 96 } … … 124 124 void psTraceReset() 125 125 { 126 p_psTraceReset(p_psCroot); 126 componentFree(cRoot); 127 cRoot = NULL; 127 128 } 128 129 … … 132 133 void psTraceFree() 133 134 { 134 ps Free(p_psCroot);135 psTraceReset(); 135 136 } 136 137 … … 147 148 char *pname = name; 148 149 char *firstComponent = NULL; // first component of name 149 p_psComponent* currentNode = p_psCroot;150 p_psComponent* currentNode = cRoot; 150 151 int nodeExists = 0; 152 153 // XXX: Verify that this is the correct behavior. 154 if (strcmp("", addNodeName) == 0) { 155 psAbort(__func__, "Failed to add null component to trace tree.\n"); 156 } 151 157 152 158 // Is this the root node? If so, simply set level and return. 153 159 if (strcmp(".", addNodeName) == 0) { 154 p_psCroot->level = level;160 cRoot->level = level; 155 161 return; 156 162 } … … 185 191 currentNode->n = (currentNode->n) + 1; 186 192 187 currentNode->subcomp[(currentNode->n) - 1] = componentAlloc(firstComponent, level); 193 if (pname == NULL) { 194 currentNode->subcomp[(currentNode->n) - 1] = componentAlloc(firstComponent, level); 195 } else { 196 currentNode->subcomp[(currentNode->n) - 1] = componentAlloc(firstComponent, currentNode->level); 197 } 198 currentNode = currentNode->subcomp[(currentNode->n) - 1]; 188 199 } 189 200 } … … 205 216 { 206 217 // If the root component tree does not exist, then initialize it. 207 if ( p_psCroot == NULL) {218 if (cRoot == NULL) { 208 219 initTrace(); 209 220 } … … 234 245 char *pname = name; 235 246 char *firstComponent = NULL; // first component of name 236 p_psComponent* currentNode = p_psCroot;247 p_psComponent* currentNode = cRoot; 237 248 int i = 0; 238 249 … … 242 253 243 254 if (strcmp(".", aname) == 0) { 244 return ( p_psCroot->level);255 return (cRoot->level); 245 256 } 246 257 … … 284 295 int psTraceGetLevel(const char *name) 285 296 { 286 if ( p_psCroot == NULL) {297 if (cRoot == NULL) { 287 298 return (PS_UNKNOWN_TRACE_LEVEL); 288 299 } … … 335 346 void psTracePrintLevels(void) 336 347 { 337 if ( p_psCroot == NULL) {348 if (cRoot == NULL) { 338 349 return; 339 350 } 340 351 341 doPrintTraceLevels( p_psCroot, 0);352 doPrintTraceLevels(cRoot, 0); 342 353 } 343 354 … … 377 388 fmt = va_arg(ap, char *); 378 389 379 if ( p_psTraceFP != NULL) {390 if (traceFP != NULL) { 380 391 // We indent each message one space for each level of the message. 381 392 for (i = 0; i < level; i++) { 382 fprintf( p_psTraceFP, " ");383 } 384 vfprintf( p_psTraceFP, fmt, ap);393 fprintf(traceFP, " "); 394 } 395 vfprintf(traceFP, fmt, ap); 385 396 } else { 386 397 // We indent each message one space for each level of the message. … … 397 408 void psTraceSetDestination(FILE * fp) 398 409 { 399 p_psTraceFP = fp;410 traceFP = fp; 400 411 } 401 412 -
trunk/psLib/test/sysUtils/tst_psTrace03.c
r1638 r1640 9 9 int main() 10 10 { 11 (void)psTraceSetLevel(".A.B.C.D.E", 2);12 psTracePrintLevels();13 (void)psTraceSetLevel(".A.B", 5);14 psTracePrintLevels();15 psTraceReset();16 17 18 11 printPositiveTestHeader(stdout, 19 12 "psTrace functions", -
trunk/psLib/test/sysUtils/tst_psTrace04.c
r1638 r1640 29 29 psTraceReset(); 30 30 31 if ( psTraceGetLevel(".") ||32 psTraceGetLevel(".a") ||33 psTraceGetLevel(".b") ||34 psTraceGetLevel(".c") ||35 psTraceGetLevel(".a.a") ||36 psTraceGetLevel(".a.b") ||37 psTraceGetLevel(".b.a") ||38 psTraceGetLevel(".b.b") ||39 psTraceGetLevel(".c.a") ||40 psTraceGetLevel(".c.b") ||41 psTraceGetLevel(".c.c")) {31 if ((psTraceGetLevel(".")!=PS_DEFAULT_TRACE_LEVEL) || 32 (psTraceGetLevel(".a")!=PS_DEFAULT_TRACE_LEVEL) || 33 (psTraceGetLevel(".b")!=PS_DEFAULT_TRACE_LEVEL) || 34 (psTraceGetLevel(".c")!=PS_DEFAULT_TRACE_LEVEL) || 35 (psTraceGetLevel(".a.a")!=PS_DEFAULT_TRACE_LEVEL) || 36 (psTraceGetLevel(".a.b")!=PS_DEFAULT_TRACE_LEVEL) || 37 (psTraceGetLevel(".b.a")!=PS_DEFAULT_TRACE_LEVEL) || 38 (psTraceGetLevel(".b.b")!=PS_DEFAULT_TRACE_LEVEL) || 39 (psTraceGetLevel(".c.a")!=PS_DEFAULT_TRACE_LEVEL) || 40 (psTraceGetLevel(".c.b")!=PS_DEFAULT_TRACE_LEVEL) || 41 (psTraceGetLevel(".c.c")!=PS_DEFAULT_TRACE_LEVEL)) { 42 42 printFooter(stdout, 43 43 "psTrace functions",
Note:
See TracChangeset
for help on using the changeset viewer.
