00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 # include "incls/_precompiled.incl"
00025 # include "incls/_eventlog.cpp.incl"
00026
00027 EventLog* eventLog;
00028
00029 void eventlog_init() { eventLog = new EventLog; }
00030
00031 static char* noEvent = "no event";
00032
00033 void EventLog::init() {
00034 buf = next = NEW_C_HEAP_ARRAY( EL_Event, EventLogLength);
00035 bufEnd = buf + EventLogLength;
00036 for (EL_Event* e = buf; e < bufEnd; e++) e->name = noEvent;
00037 }
00038
00039 EventLog::EventLog() {
00040 nesting = 0;
00041 init();
00042 }
00043
00044 void EventLog::resize() {
00045 EL_Event* oldBuf = buf;
00046 EL_Event* oldEnd = bufEnd;
00047 EL_Event* oldNext = next;
00048 init();
00049
00050 for (EL_Event* e = nextEvent(oldNext, oldBuf, oldEnd); e != oldNext;
00051 e = nextEvent(e, oldBuf, oldEnd), next = nextEvent(next, buf, bufEnd)) {
00052 *next = *e;
00053 }
00054 FreeHeap( oldBuf);
00055 }
00056
00057 void EventLog::printPartial(int n) {
00058 EL_Event* e = next;
00059
00060 if (n >= EventLogLength) n = EventLogLength - 1;
00061 for (int i = 0; i < n; i++, e = prevEvent(e, buf, bufEnd)) ;
00062
00063
00064 i = 0;
00065 for (; e != next && e->name == noEvent; i++, e = nextEvent(e, buf, bufEnd)) ;
00066
00067 int indent = 0;
00068 for (; i < n && e != next; i++, e = nextEvent(e, buf, bufEnd)) {
00069 char* s;
00070 switch (e->status) {
00071 case starting: s = "[ "; break;
00072 case ending: s = "] "; indent--; break;
00073 case atomic: s = "- "; break;
00074 }
00075 lprintf("%*.s%s", 2*indent, " ", s);
00076 lprintf(e->name, e->args[0], e->args[1], e->args[2]);
00077 lprintf("\n");
00078 if (e->status == starting) indent++;
00079 }
00080 if (indent != nesting)
00081 lprintf("Actual event nesting is %ld greater than shown.\n",
00082 nesting - indent);
00083 }
00084