diff options
Diffstat (limited to 'rts/eventlog')
-rw-r--r-- | rts/eventlog/EventLog.c | 69 |
1 files changed, 36 insertions, 33 deletions
diff --git a/rts/eventlog/EventLog.c b/rts/eventlog/EventLog.c index 4fd4b44d80..0080da630f 100644 --- a/rts/eventlog/EventLog.c +++ b/rts/eventlog/EventLog.c @@ -109,7 +109,7 @@ char *EventDesc[] = { [EVENT_HACK_BUG_T9003] = "Empty event for bug #9003", }; -// Event type. +// Event type. typedef struct _EventType { EventTypeNum etNum; // Event Type number. @@ -135,7 +135,7 @@ static StgBool hasRoomForVariableEvent(EventsBuf *eb, nat payload_bytes); static inline void postWord8(EventsBuf *eb, StgWord8 i) { - *(eb->pos++) = i; + *(eb->pos++) = i; } static inline void postWord16(EventsBuf *eb, StgWord16 i) @@ -248,24 +248,25 @@ initEventLogging(void) // We don't have a FMT* symbol for pid_t, so we go via Word64 // to be sure of not losing range. It would be nicer to have a // FMT* symbol or similar, though. - sprintf(event_log_filename, "%s.%" FMT_Word64 ".eventlog", prog, (StgWord64)event_log_pid); + sprintf(event_log_filename, "%s.%" FMT_Word64 ".eventlog", + prog, (StgWord64)event_log_pid); } stgFree(prog); /* Open event log file for writing. */ if ((event_log_file = fopen(event_log_filename, "wb")) == NULL) { sysErrorBelch("initEventLogging: can't open %s", event_log_filename); - stg_exit(EXIT_FAILURE); + stg_exit(EXIT_FAILURE); } - /* + /* * Allocate buffer(s) to store events. * Create buffer large enough for the header begin marker, all event * types, and header end marker to prevent checking if buffer has room * for each of these steps, and remove the need to flush the buffer to * disk during initialization. * - * Use a single buffer to store the header with event types, then flush + * Use a single buffer to store the header with event types, then flush * the buffer so all buffers are empty for writing events. */ #ifdef THREADED_RTS @@ -303,8 +304,9 @@ initEventLogging(void) break; case EVENT_STOP_THREAD: // (cap, thread, status) - eventTypes[t].size = - sizeof(EventThreadID) + sizeof(StgWord16) + sizeof(EventThreadID); + eventTypes[t].size = sizeof(EventThreadID) + + sizeof(StgWord16) + + sizeof(EventThreadID); break; case EVENT_STARTUP: // (cap_count) @@ -403,8 +405,9 @@ initEventLogging(void) break; case EVENT_TASK_CREATE: // (taskId, cap, tid) - eventTypes[t].size = - sizeof(EventTaskId) + sizeof(EventCapNo) + sizeof(EventKernelThreadId); + eventTypes[t].size = sizeof(EventTaskId) + + sizeof(EventCapNo) + + sizeof(EventKernelThreadId); break; case EVENT_TASK_MIGRATE: // (taskId, cap, new_cap) @@ -417,7 +420,7 @@ initEventLogging(void) break; case EVENT_BLOCK_MARKER: - eventTypes[t].size = sizeof(StgWord32) + sizeof(EventTimestamp) + + eventTypes[t].size = sizeof(StgWord32) + sizeof(EventTimestamp) + sizeof(EventCapNo); break; @@ -435,10 +438,10 @@ initEventLogging(void) // Mark end of event types in the header. postInt32(&eventBuf, EVENT_HET_END); - + // Write in buffer: the header end marker. postInt32(&eventBuf, EVENT_HEADER_END); - + // Prepare event buffer for events (data). postInt32(&eventBuf, EVENT_DATA_BEGIN); @@ -504,10 +507,10 @@ void freeEventLogging(void) { StgWord8 c; - + // Free events buffer. for (c = 0; c < n_capabilities; ++c) { - if (capEventBuf[c].begin != NULL) + if (capEventBuf[c].begin != NULL) stgFree(capEventBuf[c].begin); } if (capEventBuf != NULL) { @@ -518,7 +521,7 @@ freeEventLogging(void) } } -void +void flushEventLog(void) { if (event_log_file != NULL) { @@ -526,7 +529,7 @@ flushEventLog(void) } } -void +void abortEventLogging(void) { freeEventLogging(); @@ -539,9 +542,9 @@ abortEventLogging(void) * If the buffer is full, prints out the buffer and clears it. */ void -postSchedEvent (Capability *cap, - EventTypeNum tag, - StgThreadID thread, +postSchedEvent (Capability *cap, + EventTypeNum tag, + StgThreadID thread, StgWord info1, StgWord info2) { @@ -553,7 +556,7 @@ postSchedEvent (Capability *cap, // Flush event buffer to make room for new event. printAndClearEventBuf(eb); } - + postEventHeader(eb, tag); switch (tag) { @@ -637,7 +640,7 @@ postSparkEvent (Capability *cap, } void -postSparkCountersEvent (Capability *cap, +postSparkCountersEvent (Capability *cap, SparkCounters counters, StgWord remaining) { @@ -649,7 +652,7 @@ postSparkCountersEvent (Capability *cap, // Flush event buffer to make room for new event. printAndClearEventBuf(eb); } - + postEventHeader(eb, EVENT_SPARK_COUNTERS); /* EVENT_SPARK_COUNTERS (crt,dud,ovf,cnv,gcd,fiz,rem) */ postWord64(eb,counters.created); @@ -671,7 +674,7 @@ postCapEvent (EventTypeNum tag, // Flush event buffer to make room for new event. printAndClearEventBuf(&eventBuf); } - + postEventHeader(&eventBuf, tag); switch (tag) { @@ -807,7 +810,7 @@ void postWallClockTime (EventCapsetID capset) StgWord32 nsec; ACQUIRE_LOCK(&eventBufMutex); - + /* The EVENT_WALL_CLOCK_TIME event is intended to allow programs reading the eventlog to match up the event timestamps with wall clock time. The normal event timestamps measure time since the @@ -823,7 +826,7 @@ void postWallClockTime (EventCapsetID capset) the elapsed time vs the wall clock time. So to minimise the difference we just call them very close together. */ - + getUnixEpochTime(&sec, &nsec); /* Get the wall clock time */ ts = time_ns(); /* Get the eventlog timestamp */ @@ -837,7 +840,7 @@ void postWallClockTime (EventCapsetID capset) timestamp we already generated above. */ postEventTypeNum(&eventBuf, EVENT_WALL_CLOCK_TIME); postWord64(&eventBuf, ts); - + /* EVENT_WALL_CLOCK_TIME (capset, unix_epoch_seconds, nanoseconds) */ postCapsetID(&eventBuf, capset); postWord64(&eventBuf, sec); @@ -862,7 +865,7 @@ void postHeapEvent (Capability *cap, // Flush event buffer to make room for new event. printAndClearEventBuf(eb); } - + postEventHeader(eb, tag); switch (tag) { @@ -926,7 +929,7 @@ void postEventGcStats (Capability *cap, // Flush event buffer to make room for new event. printAndClearEventBuf(eb); } - + postEventHeader(eb, EVENT_GC_STATS_GHC); /* EVENT_GC_STATS_GHC (heap_capset, generation, copied_bytes, slop_bytes, frag_bytes, @@ -1069,7 +1072,7 @@ void postCapMsg(Capability *cap, char *msg, va_list ap) void postUserMsg(Capability *cap, char *msg, va_list ap) { postLogMsg(&capEventBuf[cap->no], EVENT_USER_MSG, msg, ap); -} +} void postEventStartup(EventCapNo n_caps) { @@ -1176,7 +1179,7 @@ void printAndClearEventBuf (EventsBuf *ebuf) if (ebuf->begin != NULL && ebuf->pos != ebuf->begin) { numBytes = ebuf->pos - ebuf->begin; - + written = fwrite(ebuf->begin, 1, numBytes, event_log_file); if (written != numBytes) { debugBelch( @@ -1184,7 +1187,7 @@ void printAndClearEventBuf (EventsBuf *ebuf) " doesn't match numBytes=%" FMT_Word64, written, numBytes); return; } - + resetEventsBuf(ebuf); flushCount++; @@ -1231,7 +1234,7 @@ StgBool hasRoomForVariableEvent(EventsBuf *eb, nat payload_bytes) } else { return 1; // Buf has enough space for the event. } -} +} void postEventType(EventsBuf *eb, EventType *et) { |