update submodules for GHC.HetMet.GArrow -> Control.GArrow renaming
[ghc-hetmet.git] / rts / eventlog / EventLog.c
index d2e3de3..cea313e 100644 (file)
@@ -80,10 +80,11 @@ char *EventDesc[] = {
   [EVENT_CAPSET_DELETE]       = "Delete capability set",
   [EVENT_CAPSET_ASSIGN_CAP]   = "Add capability to capability set",
   [EVENT_CAPSET_REMOVE_CAP]   = "Remove capability from capability set",
-  [EVENT_RTS_IDENTIFIER]      = "Identify the RTS version",
-  [EVENT_PROGRAM_ARGS]        = "Identify the program arguments",
-  [EVENT_PROGRAM_ENV]         = "Identify the environment variables",
-  [EVENT_OSPROCESS_PID]       = "Identify the process ID of a capability set"
+  [EVENT_RTS_IDENTIFIER]      = "RTS name and version",
+  [EVENT_PROGRAM_ARGS]        = "Program arguments",
+  [EVENT_PROGRAM_ENV]         = "Program environment variables",
+  [EVENT_OSPROCESS_PID]       = "Process ID",
+  [EVENT_OSPROCESS_PPID]      = "Parent process ID"
 };
 
 // Event type. 
@@ -288,9 +289,10 @@ initEventLogging(void)
                 sizeof(EventCapsetID) + sizeof(EventCapNo);
             break;
 
-        case EVENT_OSPROCESS_PID: // (cap, pid, parent pid)
+        case EVENT_OSPROCESS_PID:   // (cap, pid)
+        case EVENT_OSPROCESS_PPID:
             eventTypes[t].size =
-                sizeof(EventCapsetID) + 2*sizeof(StgWord32);
+                sizeof(EventCapsetID) + sizeof(StgWord32);
             break;
 
         case EVENT_SHUTDOWN:        // (cap)
@@ -333,10 +335,6 @@ initEventLogging(void)
     
     // Prepare event buffer for events (data).
     postInt32(&eventBuf, EVENT_DATA_BEGIN);
-    
-    // Post a STARTUP event with the number of capabilities
-    postEventHeader(&eventBuf, EVENT_STARTUP);
-    postCapNo(&eventBuf, n_caps);
 
     // Flush capEventBuf with header.
     /*
@@ -482,8 +480,7 @@ postSchedEvent (Capability *cap,
 
 void postCapsetModifyEvent (EventTypeNum tag,
                             EventCapsetID capset,
-                            StgWord32 other,
-                            StgWord32 other2)
+                            StgWord32 other)
 {
     ACQUIRE_LOCK(&eventBufMutex);
 
@@ -513,10 +510,10 @@ void postCapsetModifyEvent (EventTypeNum tag,
         postCapNo(&eventBuf, other /* capno */);
         break;
     }
-    case EVENT_OSPROCESS_PID:
+    case EVENT_OSPROCESS_PID:   // (capset, pid)
+    case EVENT_OSPROCESS_PPID:  // (capset, parent_pid)
     {
         postWord32(&eventBuf, other);
-        postWord32(&eventBuf, other2);
         break;
     }
     default:
@@ -531,7 +528,7 @@ void postCapsetStrEvent (EventTypeNum tag,
                          char *msg)
 {
     int strsize = strlen(msg);
-    int size = strsize + sizeof(EventCapsetID)
+    int size = strsize + sizeof(EventCapsetID);
 
     ACQUIRE_LOCK(&eventBufMutex);
 
@@ -645,6 +642,22 @@ void postUserMsg(Capability *cap, char *msg, va_list ap)
     postLogMsg(&capEventBuf[cap->no], EVENT_USER_MSG, msg, ap);
 }    
 
+void postEventStartup(EventCapNo n_caps)
+{
+    ACQUIRE_LOCK(&eventBufMutex);
+
+    if (!hasRoomForEvent(&eventBuf, EVENT_STARTUP)) {
+        // Flush event buffer to make room for new event.
+        printAndClearEventBuf(&eventBuf);
+    }
+
+    // Post a STARTUP event with the number of capabilities
+    postEventHeader(&eventBuf, EVENT_STARTUP);
+    postCapNo(&eventBuf, n_caps);
+
+    RELEASE_LOCK(&eventBufMutex);
+}
+
 void closeBlockMarker (EventsBuf *ebuf)
 {
     StgInt8* save_pos;