/* Simple Tracing Cedar Programs */ /* Christian Jacobi: December 7, 1987 4:35:09 pm PST */ #include <stdio.h> char tfName[] = "tracefile.tmp"; FILE *tf; int lastPos = 1000000; char *lastFile = 0; extern void XR←TraceSource(pos, leng, file) /*compiler generated calls*/ int pos, leng; char *file; { if (file!=lastFile) { lastPos = pos; lastFile = file; if (file!=0) { fprintf(tf, "\n["); fprintf(tf, file); fprintf(tf, "]* "); }; }; if (pos<lastPos){ fprintf(tf, "\n* "); }; lastPos = pos; fprintf(tf, "%d..%d ", pos, pos+leng); fflush(tf); }; extern void XR←C2CTrace(pos, leng, file) /*old version for compatibility*/ int pos, leng; char *file; { XR←TraceSource(pos, leng, file); }; extern void XR←TraceInit() { tf = fopen(tfName, "w"); printf("trace file "); printf(tfName); printf(" opened\n"); fprintf(tf, "Cedar program trace\n"); }; extern void XR←TraceClose() { if (fclose(tf) != 0) { printf("error while closing trace file"); } else { printf("trace file "); printf(tfName); printf(" closed\n"); }; }; extern void XR←TraceChar(ch) int ch; { (void) putc((ch % 0177), tf); fflush(tf); }; extern void XR←TraceInt(i) int i; { fprintf(tf, " %d", i); fflush(tf); }; extern void XR←TraceString(s) int s; { int *lp = (int*) s; char *cp = ((char*) s)+4; int cnt; int i = 0; if (lp!=0) { cnt = ((unsigned)*lp) >> 16; while (i < cnt) { (void) putc(*cp, tf); cp = cp+1; i = i+1; }; fflush(tf); }; }; static void XR←load←trace() { XR←TraceInit(); }; static void XR←run←trace() { XR←TraceInit(); }; static void XR←unload←trace() { printf("don't unload trace"); };