sanity: fix places where we weren't filling fresh memory with 0xaa
[ghc-hetmet.git] / rts / eventlog / EventLog.c
index 65eff8a..ef51228 100644 (file)
@@ -13,7 +13,6 @@
 
 #include "Trace.h"
 #include "Capability.h"
-#include "Trace.h"
 #include "RtsUtils.h"
 #include "Stats.h"
 #include "EventLog.h"
@@ -64,6 +63,9 @@ char *EventDesc[] = {
   [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"
 };
 
@@ -233,12 +235,18 @@ 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;
 
@@ -283,6 +291,10 @@ initEventLogging(void)
     for (c = 0; c < n_caps; ++c) {
         postBlockMarker(&capEventBuf[c]);
     }
+
+#ifdef THREADED_RTS
+    initMutex(&eventBufMutex);
+#endif
 }
 
 void
@@ -393,6 +405,21 @@ 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, EventTypeNum type, char *msg, va_list ap)
@@ -428,9 +455,9 @@ void postCapMsg(Capability *cap, char *msg, va_list ap)
     postLogMsg(&capEventBuf[cap->no], EVENT_LOG_MSG, msg, ap);
 }
 
-void postUserMsg(Capability *cap, char *msg)
+void postUserMsg(Capability *cap, char *msg, va_list ap)
 {
-    postLogMsg(&capEventBuf[cap->no], EVENT_USER_MSG, msg, NULL);
+    postLogMsg(&capEventBuf[cap->no], EVENT_USER_MSG, msg, ap);
 }    
 
 void closeBlockMarker (EventsBuf *ebuf)