13 #define ASSERT(expr) \ 17 snprintf(msg, sizeof(msg), "ASSERT: \"%s\" " \ 18 "(%s, %d)\n", #expr, __FILE__, __LINE__); \ 21 } while (0) // requires terminating semi-colon 26 #ifndef MIN_DEBUG_LEVEL 27 #define MIN_DEBUG_LEVEL 0 29 #ifndef MAX_DEBUG_LEVEL 30 #define MAX_DEBUG_LEVEL 10 34 #define STDERR_LEVEL 5 59 #define DebugM(level,format) \ 61 if ((level >= MIN_DEBUG_LEVEL) && (level <= MAX_DEBUG_LEVEL)) \ 64 if (level >= STDERR_LEVEL) Dout << "[ERROR " << level << "] "; \ 65 else if (level > 0) Dout << "[Debug " << level << "] "; \ 66 Dout << iPE << ' ' << iFILE; \ 67 Dout << format << endi; \ 79 #ifdef PROCTRACE_DEBUG 88 inline static DebugFileTrace *Instance(
char *fn){
89 if(CkpvAccess(DebugFileTrace_instance)==0){
90 CkpvAccess(DebugFileTrace_instance) =
new DebugFileTrace(fn);
92 return CkpvAccess(DebugFileTrace_instance);
94 inline static DebugFileTrace *Object(){
95 return CkpvAccess(DebugFileTrace_instance);
97 DebugFileTrace(
char *fn){
104 memset(tmp, 0, 128*
sizeof(
char));
105 sprintf(tmp,
"%s.%d", fn, CkMyPe());
106 fname =
new char[strlen(tmp)+1];
107 memcpy(fname, tmp, strlen(tmp)+1);
108 fp = fopen(fname,
"w");
115 inline void writeTrace(
const char *msg, ...){
117 va_start(argList, msg);
118 vfprintf(fp, msg, argList);
121 inline int openTrace(){
122 if(fname==NULL)
return 0;
123 fp = fopen(fname,
"a");
129 inline int closeTrace(){
130 if(fname==NULL)
return 0;
133 inline int flushTrace(){
150 fprintf(stderr, "DEBUG: %s:%d: %s\n", __FILE__, __LINE__, t) 152 fprintf(stderr, "DEBUG: %s:%d: %s=\"%s\"\n", __FILE__, __LINE__, #t, t) 154 fprintf(stderr, "DEBUG: %s:%d: %s=%d\n", __FILE__, __LINE__, #n, n) 156 fprintf(stderr, "DEBUG: %s:%d: %s=%g\n", __FILE__, __LINE__, #r, double(r)) 158 fprintf(stderr, "DEBUG: %s:%d: %s=%e\n", __FILE__, __LINE__, #r, double(r)) 160 fprintf(stderr, "DEBUG: %s:%d: %s=%g %g %g\n", __FILE__, __LINE__, \ 161 #v, double(v.x), double(v.y), double(v.z))