X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2Feventlog%2FEventLog.c;h=ef512281eca98bbaa2c13c8bb9076dc076fc2f36;hb=fff1f6194c3c39de53cd645bda9865fb131b1c68;hp=e5e71e65c83d462e141bf382c14b810ab50a39a0;hpb=22b7fd79aeafa9a6b58f8448633197e00cec3962;p=ghc-hetmet.git diff --git a/rts/eventlog/EventLog.c b/rts/eventlog/EventLog.c index e5e71e6..ef51228 100644 --- a/rts/eventlog/EventLog.c +++ b/rts/eventlog/EventLog.c @@ -13,7 +13,6 @@ #include "Trace.h" #include "Capability.h" -#include "Trace.h" #include "RtsUtils.h" #include "Stats.h" #include "EventLog.h" @@ -62,7 +61,11 @@ char *EventDesc[] = { [EVENT_REQUEST_PAR_GC] = "Request parallel GC", [EVENT_CREATE_SPARK_THREAD] = "Create spark thread", [EVENT_LOG_MSG] = "Log message", + [EVENT_USER_MSG] = "User message", [EVENT_STARTUP] = "Startup", + [EVENT_GC_IDLE] = "GC idle", + [EVENT_GC_WORK] = "GC working", + [EVENT_GC_DONE] = "GC done", [EVENT_BLOCK_MARKER] = "Block marker" }; @@ -82,7 +85,7 @@ static void printAndClearEventBuf (EventsBuf *eventsBuf); static void postEventType(EventsBuf *eb, EventType *et); -static void postLogMsg(EventsBuf *eb, char *msg, va_list ap); +static void postLogMsg(EventsBuf *eb, EventTypeNum type, char *msg, va_list ap); static void postBlockMarker(EventsBuf *eb); static void closeBlockMarker(EventsBuf *ebuf); @@ -232,16 +235,23 @@ initEventLogging(void) sizeof(EventThreadID) + sizeof(StgWord16); break; + case EVENT_STARTUP: // (cap count) + eventTypes[t].size = sizeof(EventCapNo); + break; + case EVENT_SHUTDOWN: // (cap) case EVENT_REQUEST_SEQ_GC: // (cap) case EVENT_REQUEST_PAR_GC: // (cap) case EVENT_GC_START: // (cap) case EVENT_GC_END: // (cap) - case EVENT_STARTUP: + case EVENT_GC_IDLE: + case EVENT_GC_WORK: + case EVENT_GC_DONE: eventTypes[t].size = 0; break; case EVENT_LOG_MSG: // (msg) + case EVENT_USER_MSG: // (msg) eventTypes[t].size = 0xffff; break; @@ -281,6 +291,10 @@ initEventLogging(void) for (c = 0; c < n_caps; ++c) { postBlockMarker(&capEventBuf[c]); } + +#ifdef THREADED_RTS + initMutex(&eventBufMutex); +#endif } void @@ -391,9 +405,24 @@ postSchedEvent (Capability *cap, } } +void +postEvent (Capability *cap, EventTypeNum tag) +{ + EventsBuf *eb; + + eb = &capEventBuf[cap->no]; + + if (!hasRoomForEvent(eb, tag)) { + // Flush event buffer to make room for new event. + printAndClearEventBuf(eb); + } + + postEventHeader(eb, tag); +} + #define BUF 512 -void postLogMsg(EventsBuf *eb, char *msg, va_list ap) +void postLogMsg(EventsBuf *eb, EventTypeNum type, char *msg, va_list ap) { char buf[BUF]; nat size; @@ -409,7 +438,7 @@ void postLogMsg(EventsBuf *eb, char *msg, va_list ap) printAndClearEventBuf(eb); } - postEventHeader(eb, EVENT_LOG_MSG); + postEventHeader(eb, type); postPayloadSize(eb, size); postBuf(eb,(StgWord8*)buf,size); } @@ -417,15 +446,20 @@ void postLogMsg(EventsBuf *eb, char *msg, va_list ap) void postMsg(char *msg, va_list ap) { ACQUIRE_LOCK(&eventBufMutex); - postLogMsg(&eventBuf, msg, ap); + postLogMsg(&eventBuf, EVENT_LOG_MSG, msg, ap); RELEASE_LOCK(&eventBufMutex); } void postCapMsg(Capability *cap, char *msg, va_list ap) { - postLogMsg(&capEventBuf[cap->no], msg, ap); + postLogMsg(&capEventBuf[cap->no], EVENT_LOG_MSG, msg, ap); } +void postUserMsg(Capability *cap, char *msg, va_list ap) +{ + postLogMsg(&capEventBuf[cap->no], EVENT_USER_MSG, msg, ap); +} + void closeBlockMarker (EventsBuf *ebuf) { StgInt8* save_pos;